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