#include <iostream>
using namespace std;
int main() {
int d;
int m;
int y;
bool x = false;
cin >> d >> m >> y;
d = d + 2;
if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) {
x = true;
}
if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10) {
if (d > 31) {
d = d % 31;
m++;
}
} else if (m == 2) {
if (x) {
if (d > 29) {
d = d % 29;
m++;
}
} else {
if (d > 28) {
d = d % 28;
m++;
}
}
} else if (m == 12) {
if (d > 31) {
d = d % 31;
m = 1;
y++;
}
} else {
if (d > 30) {
d = d % 30;
m++;
}
}
cout << d << " " << m << " " << y;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CmludCBkOwppbnQgbTsKaW50IHk7CmJvb2wgeCA9IGZhbHNlOwpjaW4gPj4gZCA+PiBtID4+IHk7CmQgPSBkICsgMjsKaWYgKCh5ICUgNCA9PSAwICYmIHkgJSAxMDAgIT0gMCkgfHwgeSAlIDQwMCA9PSAwKSB7CnggPSB0cnVlOwp9CmlmIChtID09IDEgfHwgbSA9PSAzIHx8IG0gPT0gNSB8fCBtID09IDcgfHwgbSA9PSA4IHx8IG0gPT0gMTApIHsKaWYgKGQgPiAzMSkgewpkID0gZCAlIDMxOwptKys7Cn0KfSBlbHNlIGlmIChtID09IDIpIHsKaWYgKHgpIHsKaWYgKGQgPiAyOSkgewpkID0gZCAlIDI5OwptKys7Cn0KfSBlbHNlIHsKaWYgKGQgPiAyOCkgewpkID0gZCAlIDI4OwptKys7Cn0KfQp9IGVsc2UgaWYgKG0gPT0gMTIpIHsKaWYgKGQgPiAzMSkgewpkID0gZCAlIDMxOwptID0gMTsKeSsrOwp9Cn0gZWxzZSB7CmlmIChkID4gMzApIHsKZCA9IGQgJSAzMDsKbSsrOwp9Cn0KY291dCA8PCBkIDw8ICIgIiA8PCBtIDw8ICIgIiA8PCB5OwpyZXR1cm4gMDsKfQ==