#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int N = 1e6+10;
int t,n,m,k,l,r,op,x,y;
int f[N];
bool flag;
//int dp[N][N];
bool isLeapYear(int y){
return (y%4==0) and ((y%100)!=0 or y%400==0);
}
void solve(){
int months[13] = {-1,31,28,31,30,31,30,31,31,30,31,30,31};
while(cin>>x>>y){
if(isLeapYear(x)){
months[2]=29;
}else{
months[2]=28;
}
int m = 1;
while(y>months[m]){
y-=months[m];
m++;
}
printf("%04d-%02d-%02d\n",x,m,y);
// cout<<x<<"-"<<m<<"-"<<y<<"\n";
}
}
int main(){
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// cout.tie(nullptr);
solve();
return 0;
}