P, Q, Y0, p0, q0, Y1 = map(int, input().split()) Y = Y1 - Y0 p0 += Y q0 += Y a = p0 % P b = q0 % Q if a == 0: a = P if b == 0: b = Q print(a, b)