#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
#include <set>
using namespace std;
const int styear = 19600101;
const int edyear = 20591231;
typedef pair<int , pair<int , int> > PIPII;
int Month[13] = {0 , 31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31};
int d[3];
int length;
int frontYear[2] = {19 , 20};
vector<PIPII> date;
bool compare(PIPII a , PIPII b){
if (a.first != b.first) return a.first < b.first;
if (a.second.first != b.second.first) return a.second.first < b.second.first;
return a.second.second < b.second.second;
}
bool check_valid(int y , int m , int da){
int val = y * 10000 + m * 100 + da;
if (val < styear || val > edyear) return false;
if (m < 1 || m > 13 || da < 1) return false;
if (m != 2){
if (da > Month[m]) return false;
}//if
else{
int t = (y % 400 == 0) || (y % 100 != 0 && y % 4 == 0);
if (da > Month[2] + t) return false;
}
return true;
}
int main (){
set<int> s;
string str;
cin >> str;
stringstream ssin(str);
while(getline(ssin , str , '/')) d[length++] = atoi(str.c_str());
//for (int i = 0;i < length;i++) cout << d[i];
for (int i = 0;i < 2;i++){
int y1 = frontYear[i] * 100 + d[0];
int y2 = frontYear[i] * 100 + d[2];
int m1 = d[1];
int da1 = d[2];
int m2 = d[1];
int da2 = d[0];
int m3 = d[0];
int da3 = d[1];
//printf ("%d-%02d-%02d\n" , y1 , m1 , da1);
//printf ("%d-%02d-%02d\n" , y2 , m1 , da1);
//printf ("%d-%02d-%02d\n" , y2 , m2 , da2);
int val = 0;
if (check_valid(y1 , m1 , da1)){
val = y1 * 10000 + m1 * 100 + da1;
if (s.find(val) == s.end()){
s.insert(val);
date.push_back({y1 , {m1 , da1}});
}
}//if
if (check_valid(y2 , m2 , da2)){
val = y2 * 10000 + m2 * 100 + da2;
if (s.find(val) == s.end()){
s.insert(val);
date.push_back({y2 , {m2 , da2}});
}
}//if
if (check_valid(y2 , m3 , da3)){
val = y2 * 10000 + m3 * 100 + da3;
//cout << val << endl;
if (s.find(val) == s.end()){
s.insert(val);
date.push_back({y2 , {m3 , da3}});
}
}
}
sort(date.begin() , date.end() , compare);
for (int i = 0;i < date.size();i++){
printf ("%d-%02d-%02d\n" , date[i].first , date[i].second.first , date[i].second.second);
}
return 0;
}