#include #ifdef LOCAL #include #else #define debug(...) #endif using namespace std; namespace rv = std::views; // NOLINT // clang-format off using lint = long long; using P = pair; #define ALL(a) (a).begin(), (a).end() template inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } inline void Yes(bool b = true) { println("{}",(b ? "Yes" : "No")); } inline void No() { println("{}", "No");} // clang-format on int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int P, Q, Y, p, q, y; cin >> P >> Q >> Y >> p >> q >> y; int diff = y - Y; p += diff; q += diff; p %= P; q %= Q; if (p == 0) p = P; if (q == 0) q = Q; println("{} {}", p, q); }