#include <cstdio>
#include <iostream>
using namespace std;
int month[13][2]={
{0,0},{31,31},{28,29},{31,31},{30,30},{31,31},{30,30},
{31,31},{31,31},{30,30},{31,31},{30,30},{31,31}
};
bool isLeap(int year) //判断是否是闰年
{
// 普通年能被4整除且不能被100整除的为闰年。(如2004年就是闰年,1900年不是闰年)
// 世纪年能被400整除的是闰年。(如2000年是闰年,1900年不是闰年)
return (year%400 == 0 || ( year % 4 ==0 && year%100 != 0 ) );
}
int main()
{
int year,days,tag;
int m=1;
while(scanf("%d%d",&year,&days) != EOF)
{
m=1;
tag = isLeap(year);
//求出月
for(int i=1; days > month[i][tag];i++ )
{
days -= month[i][tag];
m++;
}
printf("%04d-%02d-%02d\n",year,m,days);
}
return 0;
}