def uruu(y): if y%4==0: if y%100==0 and y%400!=0: return False return True else: return False Y, N, D = map(int, input().split()) if uruu(Y-12) and uruu(Y): print(max(0, N-D), min(N, 366-D)) else: print(max(0, N-D), min(N, 365-D))