#include <iostream>
#include <iomanip>
using namespace std;

int daytable[2][13]{
    {0,31,28,31,30,31,30,31,31,30,31,30,31},
    {0,31,29,31,30,31,30,31,31,30,31,30,31}
};

int main(){
    int year,days;
    while(cin>>year && cin>>days){
        int leap=((year%4==0 && year%100!=0) || (year%400==0));
        int month=0;
        while(days>daytable[leap][month]){
            days-=daytable[leap][month];
            month+=1;
        }
        cout<<year;
        cout<<'-';
        cout<<setw(2)<<setfill('0')<<month;
        cout<<'-';
        cout<<setw(2)<<setfill('0')<<days;
        cout<<endl;
    }
}