P, Q, Y0, p0, q0, Y = map(int, input().split()) p = ((p0 - 1 + Y - Y0) % P + P) % P + 1 q = ((q0 - 1 + Y - Y0) % Q + Q) % Q + 1 print(p, q)