#include <iostream>
#include <iomanip> // 为了 setw / setfill
using namespace std;
/* 判断闰年:400 留、100 丢、4 留 */
bool isLeap(int y) {
return (y % 400 == 0) || (y % 4 == 0 && y % 100 != 0);
}
/* 把第 n 天转换成 (month, day) */
void nthToDate(int y, int n, int& m, int& d) {
int days[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
if (isLeap(y)) days[1] = 29;
m = 1;
while (n > days[m - 1]) {
n -= days[m - 1];
++m;
}
d = n;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int y, n;
while (cin >> y >> n) { // 读到 EOF 结束
int limit = isLeap(y) ? 366 : 365;
if (n < 1 || n > limit) continue; // 题目保证合法,这里略过检查失败
int month, day;
nthToDate(y, n, month, day);
/* YYYY-MM-DD,月份/日期两位补零 */
cout << y << '-'
<< setw(2) << setfill('0') << month << '-'
<< setw(2) << setfill('0') << day << '\n';
}
return 0;
}