#include<iostream>

using namespace std;

bool isLeap(int year){
    return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
}

// 输入 
int main(){
    int year = 0;
    int day_in_year = 0;
    int month[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}};
        while(cin>>year>>day_in_year){
            int row = isLeap(year) ? 1:0; 
            int index = 1;
            while(day_in_year > month[row][index]){
                day_in_year -= month[row][index];
                index++;
            }
            cout<<year;
            if(index > 9){
                cout<<"-"<<index;
            }else {
                cout<<"-"<<0<<index;
            }
            if(day_in_year > 9){
                cout<<"-"<<day_in_year;
            }else {
                cout<<"-"<<0<<day_in_year;
            }
            cout<<endl;
        }
    return 0;
}