#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define INF 0x3f3f3f3f
#define endl "\n"
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef long long LL;
const int N = 1e5+3,MOD = 100000007;
int n,m;
string s,t;
int a[3],mon[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int c[][3] = {{0,1,2},{2,0,1},{2,1,0}};//年/月/日,月/日/年,日/月/年.0:年,1:月,2:日
struct dt{
int y,m,d;
bool operator < (const dt& t_dt) const{//自定义排序规则
if(y != t_dt.y) return y < t_dt.y;
if(m != t_dt.m) return m < t_dt.m;
return d < t_dt.d;
}
};
set<dt> date;//set存储自动排序,并且防止重复日期
bool ck(int year,int month,int day){
if(year < 1960 || year >= 2060) return false;//判定年数
if(month < 1 || month > 12) return false;//判定月数
if(day < 1 || (month != 2 && day > mon[month])) return false;//判定天数
int leap = (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) ? 1 : 0;
if(month == 2 && day > mon[month] + leap) return false;//特判2月
return true;
}
void solve(){
while(cin >> s){
date.clear();
stringstream ssin(s);
int i = 0;
while(getline(ssin,t,'/')) a[i++] = stoi(t);//按照'/'分割存储到a数组中
for(int i = 0;i < 3;++i){
if(ck(1900+a[c[i][0]],a[c[i][1]],a[c[i][2]])) date.insert({1900+a[c[i][0]],a[c[i][1]],a[c[i][2]]});
if(ck(2000+a[c[i][0]],a[c[i][1]],a[c[i][2]])) date.insert({2000+a[c[i][0]],a[c[i][1]],a[c[i][2]]});
}
for(auto &p:date) printf("%d-%02d-%02d\n", p.y, p.m, p.d);
}
}
int main(){
#ifdef LOCAL
freopen(".w/ac.in","r",stdin);
freopen(".w/ac.out","w",stdout);
#endif
IOS;
int TT = 1;
// cin >> TT;
while(TT--) solve();
return 0;
}