#include <iostream>
#include <string>
using namespace std;
int first;
int second;
int third;
int day[13]={0,31,0,31,30,31,30,31,31,30,31,30,31};
bool select (int i,int j,int k){
if ((i%100 == first) && (j == second) && (k == third))
return true;
if ((i%100 == third) && (j == first) && (k == second))
return true;
if ((i%100 == third) && (j == second) && (k == first))
return true;
return false;
}
int main(){
string s;
cin>>s;
getchar();
first = ((int)s[0] - 48)* 10 + ((int)s[1] - 48);
second = ((int)s[3] - 48)* 10 + ((int)s[4] - 48);
third = ((int)s[6] - 48)* 10 + ((int)s[7] - 48);
for (int i = 1960; i <= 2059; i++){
if ((i % 4 == 0 && i % 100 != 0) || (i % 400 == 0))
day[2] = 29;
else
day[2] = 28;
for (int j = 1;j <= 12;j++){
for (int k = 1;k <= day[j];k++){
if (select(i,j,k)){
if (i % 100 < 10) cout<< "200" << i % 100 << "-";
else if (i % 100 < 60) cout<< "20" << i % 100 << "-";
else cout<< "19"<<i % 100<<"-";
if (j < 10) cout<< "0"<< j <<"-";
else cout<< j <<"-";
if (k < 10) cout<< "0"<<k<<endl;
else cout<< k<<endl;
}
}
}
}
return 0;
}