import calendar
y,m,d=map(int,raw_input().strip().split())
d+=1
if d==32:
d=1
m+=1
if m==13:
m=1
y+=1
if d==31:
if m==4 or m==6 or m==9 or m==11:
d=1
m+=1
if d==30 and m==2:
d=1
m=3
if d==29 and m==2 and (not calendar.isleap(y)):
d=1
m=3
print y,m,d