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