#include #include #include using namespace std; int main() { int P, Q, Y, p, q, y; cin >> P >> Q >> Y >> p >> q >> y; int d = y - Y; --p, --q; p += d; q += d; p = (p % P + P) % P; q = (q % Q + Q) % Q; ++p; ++q; cout << p << ' ' << q << endl; }