s=list(map(int,input().split()))
yy=s[0]
mm=s[1]
dd=s[2]
m1=(1,3,5,7,8,10)
m2=[4,6,9,11]
def runnian(x):
tmp=False
if x % 400==0 or x % 4==0 and x %100 !=0:
tmp=True
return tmp
dd+=1
if dd==32:
dd=1
if mm==12:
mm=1
yy+=1
else:
mm+=1
elif mm in m2:
if dd==31:
dd=1
mm+=1
elif mm==2:
if runnian(yy):
if dd==30:
dd=1
mm+=1
else:
if dd==29:
dd=1
mm+=1
print(yy,mm,dd)