s=list(map(int,input().split()))
while True:
if (s[1]==1 or s[1]==3 or s[1]==5 or s[1]==7 or s[1]==8 or s[1]==10) and s[2]==31:
s[1]=s[1]+1
s[2]=1
break
if (s[1]==4 or s[1]==6 or s[1]==9 or s[1]==11) and s[2]==30:
s[1]=s[1]+1
s[2]=1
break
if s[1]==12 and s[2]==31:
s[0]=s[0]+1
s[1]=1
s[2]=1
break
if (s[0]%4==0 and not s[0]%100==0 or s[0]%400==0) and s[2]==29:
s[1]=s[1]+1
s[2]=1
break
if (s[0]%4==0 and not s[0]%100==0 or s[0]%400==0) and s[2]==28:
s[2]=s[2]+1
break
if (s[0]%4!=0 and not s[0]%100!=0 or s[0]%400!=0) and s[2]==28:
s[1]=s[1]+1
s[2]=1
break
else:
s[2]=s[2]+1
break
if (s[1]==1 or s[1]==3 or s[1]==4 or s[1]==5 or s[1]==6 or s[1]==7 or s[1]==8 or s[1]==9 or s[1]==10 or s[1]==11 or s[1]==12) and (s[2]!=31 or s[2]!=30):
s[2]=s[2]+1
break
print(s[0],s[1],s[2])