P, Q, y, p, q, Y = map(int, input().split()) for _ in range(y + 1, Y + 1): p += 1 p %= P q += 1 q %= Q print(p, q)