n,y,r=map(int,raw_input().strip().split())
month=[31,28,31,30,31,30,31,31,30,31,30,31]
def runnian(a):
if a%4==0 and a%100 != 0 or a%400 ==0:
return 1
else:
return 0
if runnian(n)==1:
month[1]=29
if r<month[y-1]:
r=r+1
else:
if y<12:
y=y+1
r=1
else:
n=n+1
y=1
r=1
print n,y,r