P, Q, Y_0, p, q, Y = [int(s) for s in input().split()] Y -= Y_0 p -= 1 q -= 1 print((p + Y) % P + 1, (q + Y) % Q + 1)