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): if D>30+31+30+31+31+30+31+30+31+31+28: print(max(0, N-D), min(N, 365-D)) else: print(max(0, N-D), min(N, 366-D)) else: print(max(0, N-D), min(N, 365-D))