#include using namespace std; using ll = long long; bool chmax(auto &a, auto b) { return a < b ? a = b, 1 : 0; } bool chmin(auto &a, auto b) { return a > b ? a = b, 1 : 0; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int P, Q, y, p, q, Y; cin >> P >> Q >> y >> p >> q >> Y; --p, --q; int d = Y - y; if (d >= 0) { cout << (p + d) % P + 1 << ' ' << (q + d) % Q + 1 << '\n'; } else { d = -d; cout << (p + P - (d % P)) % P + 1 << ' ' << (q + Q - (d % Q)) % Q + 1 << '\n'; } }