#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool check(int year, int month, int day) {
if (day > 31 || day <= 0) return false;
if (month > 12 || month <= 0) return false;
if (month != 2 && day > days[month]) return false;
if (month == 2) {
int x = year % 100 != 0 && year % 4 == 0 || year % 400 == 0;
if (day > days[month] + x) return false;
}
return true;
}
int main() {
int a, b, c;
scanf("%d/%d/%d", &a, &b, &c);
vector<int> res;
if (check(2000 + a, b, c)) res.push_back(((2000 + a) * 100 + b) * 100 + c);
if (check(2000 + c, a, b)) res.push_back(((2000 + c) * 100 + a) * 100 + b);
if (check(2000 + c, b, a)) res.push_back(((2000 + c) * 100 + b) * 100 + a);
sort(res.begin(), res.end());
if (res[0] / 10000 > 2060) res[0] = res[0] - 1000000; // 判断年份是否>2060
printf("%d-%02d-%02d\n", res[0] / 10000, (res[0] / 100) % 100, res[0] % 100);
for (int i = 1; i < res.size(); i ++) {
if (res[i] == res[i - 1]) continue;
if (res[i] / 10000 > 2060) res[i] = res[i] - 1000000;
printf("%d-%02d-%02d\n", res[i] / 10000, (res[i] / 100) % 100, res[i] % 100);
}
return 0;
}