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