Y, N, D = map(int, input().split()) u = True if (Y + 1) % 400 == 0 \ else False if (Y + 1) % 100 == 0 \ else (Y + 1) % 4 == 0 print(max(0, N - D), min(N, 365 + u - D))