y,m,d=map(int,input().split())
if m==12 and d==31:
y+=1
m=1
d=1
elif (y%4==0 and y%100!=0 or y%400==0) and m==2 and d==29 or m%2==0 and m!=2 and d==30:
m+=1
d=1
elif not(y%4==0 and y%100!=0 or y%400==0) and m==2 and d==28 or m%2==1 and m!=2 and d==31:
m+=1
d=1
else:
d+=1
print(y,m,d)