#include <bits/stdc++.h>
using namespace std;

bool isrun(int n) {
    if ((n % 4 == 0 && n % 100 != 0) || n % 400 == 0)
        return true;
    else return false;
}

int main() {
    int m, n, i;
    int a1[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int a2[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; //闰年
    bool flag;
    while (cin >> m >> n) {
        flag = isrun(m);
        if (flag) { //闰年
            for (i = 1; i <= 12 && n > a2[i]; i++) {
                n -= a2[i];
            }
            printf("%d-%02d-%02d\n", m, i, n);
        } else {
            for (i = 1; i <= 12 && n > a1[i]; i++) {
                n -= a1[i];
            }
            printf("%d-%02d-%02d\n", m, i, n);
        }

    }

}