#include <iostream>
using namespace std;
int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool judge(int y){
    if(y % 400 == 0 || (y % 100 != 0 && y % 4 == 0))
        return true;
    return false;
}

int main() {
    int y, n;
    while (cin >> y >> n) { // 注意 while 处理多个 case
        if(judge(y)) month[2] = 29;
        else month[2] = 28;
        for(int i = 1; i <= 12; i ++){
            if(n > month[i])
                n -= month[i];
            else{
                printf("%4d-%02d-%02d\n", y, i, n);
                break;
            }
        }
    }

    return 0;
}
// 64 位输出请用 printf("%lld")