P, Q, Yo, po, qo, Y = map(int, input().split()) ansp = (Y -Yo)%P + po ansq = (Y -Yo)%Q + qo print(ansp, ansq)