#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
const int MAXN = 100 + 10;
int a, b, c;
int m1[] = {31,28,31,30,31,30,31,31,30,31,30,31};
int m2[] = {31,29,31,30,31,30,31,31,30,31,30,31};
struct Node{
int y, m, d;
bool operator < (const Node&rhs)const{
return y < rhs.y || (y == rhs.y && m < rhs.m) || (y == rhs.y && m == rhs.m && d < rhs.d);
}
}num[10];
set st;
int cnt;
bool judge(int y){
if(y % 400 == 0) return true;
if(y % 100 != 0 && y % 4 == 0) return true;
return false;
}
bool judge1(){
if(a < 60){
num[cnt].y = 2000 + a;
}
else{
num[cnt].y = 1900 + a;
}
if(b < 1 || b > 12) return false;
if(judge(num[cnt].y)){
if(c >= 1 && c <= m2[b - 1]){
num[cnt].m = b;
num[cnt].d = c;
return true;
}
return false;
}
else{
if(c >= 1 && c <= m1[b - 1]){
num[cnt].m = b;
num[cnt].d = c;
return true;
}
return false;
}
}
bool judge2(){
if(c < 60){
num[cnt].y = 2000 + c;
}
else{
num[cnt].y = 1900 + c;
}
if(a < 1 || a > 12) return false;
if(judge(num[cnt].y)){
if(b >= 1 && b <= m2[a - 1]){
num[cnt].m = a;
num[cnt].d = b;
return true;
}
return false;
}
else{
if(b >= 1 && b <= m1[a - 1]){
num[cnt].m = a;
num[cnt].d = b;
return true;
}
return false;
}
}
bool judge3(){
if(c < 60){
num[cnt].y = 2000 + c;
}
else{
num[cnt].y = 1900 + c;
}
if(b < 1 || b > 12) return false;
if(judge(num[cnt].y)){
if(a >= 1 && a <= m2[b - 1]){
num[cnt].m = b;
num[cnt].d = a;
return true;
}
return false;
}
else{
if(a >= 1 && a <= m1[b - 1]){
num[cnt].m = b;
num[cnt].d = a;
return true;
}
return false;
}
}
int main(){
scanf("%d/%d/%d", &a, &b, &c);
cnt = 0;
if(judge1()){
++cnt;
}
if(judge2()){
++cnt;
}
if(judge3()){
++cnt;
}
sort(num, num + cnt);
for(int i = 0; i < cnt; ++i){
st.insert(num[i]);
}
for(set::iterator it = st.begin(); it != st.end(); ++it){
printf("%d-%02d-%02d\n", (*it).y, (*it).m, (*it).d);
}
return 0;
}