#include<iostream>
#include<set>
#include<iterator>
using namespace std;
int t[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int l[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
struct node {
int yy;
int mm;
int dd;
bool operator <(const node x) const{
if(x.yy==yy){
if(x.mm==mm){
return x.dd>dd;
}
return x.mm>mm;
}
return x.yy>yy;
}
}a[6];
set <node> ss;
int check(int i){
if(a[i].yy>2059||a[i].yy<1960) return 0;
int flag=0;
if(a[i].yy%400==0||a[i].yy%4==0&&a[i].yy%100!=0) flag=1;
if(a[i].mm<1||a[i].mm>12) return 0;
else{
if(flag==1){
return a[i].dd<=l[a[i].mm]&&a[i].dd>=1;
}
else return a[i].dd<=t[a[i].mm]&&a[i].dd>=1;
}
}
void iinsert(int i){
ss.insert(a[i]);
}
int main(){
int yys,mms,dds;
scanf("%d/%d/%d",&yys,&mms,&dds);
a[0]={1900+yys,mms,dds};
a[1]={2000+yys,mms,dds};
a[2]={1900+dds,yys,mms};
a[3]={2000+dds,yys,mms};
a[4]={1900+dds,mms,yys};
a[5]={2000+dds,mms,yys};
// for(int i=0;i<=5;i++){
// printf("*%d-%02d-%02d\n",a[i].yy,a[i].mm,a[i].dd);
// }
for(int i=0;i<=5;i++){
if(check(i)){
iinsert(i);
}
}
set<node>::iterator it=ss.begin();
for(;it!=ss.end();++it){
printf("%d-%02d-%02d\n",(*it).yy,(*it).mm,(*it).dd);
}
return 0;
}