//#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // #define OLD_JUDGE #ifdef OLD_JUDGE # define USE_ISTREAM # define USE_OSTREAM #else # define USE_ISTREAM # define USE_PRINT #endif #if defined(USE_ISTREAM) || defined(USE_OSTREAM) # include # include #endif #ifdef USE_PRINT # include # include #endif namespace tomolatoon { using namespace std::views; namespace rng = std::ranges; #ifdef USE_ISTREAM using std::cin; #endif #ifdef USE_OSTREAM using std::cout; using std::endl; #endif #ifdef USE_PRINT using std::format; using std::print; using std::println; template void pr(T&& t) { print("{}", std::forward(t)); } template void prn(T&& t) { println("{}", std::forward(t)); } #endif using rng::subrange; using std::array; using std::deque; using std::list; using std::map; using std::multimap; using std::multiset; using std::pair; using std::queue; using std::set; using std::span; using std::stack; using std::string; using std::string_view; using std::tuple; using std::vector; template using vec = vector; using uint = std::uint32_t; using ull = std::uint64_t; using ll = std::int64_t; using std::size_t; // clang-format off using rng::all_of; using rng::any_of; #ifndef OLD_JUDGE using rng::none_of; using rng::contains; using rng::contains_subrange; #endif using rng::for_each; using rng::for_each_n; using rng::find; using rng::find_if; using rng::find_if_not; #ifndef OLD_JUDGE using rng::find_last; using rng::find_last_if; using rng::find_last_if_not; #endif using rng::find_end; using rng::find_first_of; using rng::adjacent_find; using rng::count; using rng::count_if; using rng::mismatch; using rng::equal; using rng::search; using rng::search_n; // clang-format on using rng::sort; using rng::stable_sort; using rng::unique; using rng::max_element; using rng::min_element; using rng::binary_search; using rng::equal_range; using rng::lower_bound; using rng::upper_bound; using rng::next_permutation; using rng::prev_permutation; using rng::begin; using rng::distance; using rng::end; using rng::ssize; using rng::swap; using std::abs; using std::midpoint; using std::back_inserter; using std::front_inserter; using std::inserter; using namespace std::placeholders; void yn(bool f) { #ifdef USE_OSTREAM cout << (f ? "Yes" : "No") << "\n"; #elifdef USE_PRINT print("{}", (f ? "Yes" : "No")); #endif } string yns(bool f) { return f ? "Yes" : "No"; } // clang-format off struct P { using type = ll; type i; type j; P moved(type id, type jd) const { return {i + id, j + jd}; } P moved(P pd) const { return moved(pd.i, pd.j); } template T& operator[](vec>& v) const { return v[i][j]; } char& operator[](vec& v) const { return v[i][j]; } friend P operator+(const P& lhs, const P& rhs) { return lhs.moved(rhs); } friend P operator-(const P& lhs, const P& rhs) { return lhs.moved(-rhs); } P operator-() const { return P{-i, -j}; } friend bool operator==(const P& lhs, const P& rhs) { return lhs.i == rhs.i && lhs.j == rhs.j; } friend auto operator<=>(const P& lhs, const P& rhs) { return lhs.i != rhs.i ? lhs.i <=> rhs.i : lhs.j <=> rhs.j; } ll L1() const { return std::abs(i) + std::abs(j); } friend ll ip(const P& lhs, const P& rhs) { return lhs.i * rhs.i + lhs.j * rhs.j; } }; const auto in_f = [](P::type h, P::type w) { return [=](P p) { return 0 <= p.i && p.i < h && 0 <= p.j && p.j < w; }; }; static const auto P4 = array{P{-1, 0}, P{ 0, -1}, P{ 1, 0}, P{ 0, 1}}; static const auto P8 = array{P{-1, 0}, P{-1, -1}, P{ 0, -1}, P{ 1, -1}, P{ 1, 0}, P{ 1, 1}, P{ 0, 1}, P{-1, 1}}; // clang-format on ll pow(ll base, size_t n) { assert(not(base == 0 && n == 0)); if (n == 0) return 1; if (n == 1) return base; ll prev = pow(base, n / 2); return prev * prev * (n % 2 ? base : 1); } ll pow(ll base, size_t n, ll mod) { assert(not(base == 0 && n == 0)); constexpr auto modf = [](ll x, ll mod) { return (x % mod + mod) % mod; }; if (base >= mod) base %= mod; if (n == 0) return 1; if (n == 1) return base; ll prev = pow(base, n / 2); ll pp = modf(prev * prev, mod); return (n % 2 ? modf(pp * base, mod) : pp); } template T shared_length_signed(T l1, T r1, T l2, T r2) { return rng::min(r1, r2) - rng::max(l1, l2); } template T shared_length(T l1, T r1, T l2, T r2) { return rng::max(0, rng::min(r1, r2) - rng::max(l1, l2)); } /// @brief ランレングス圧縮(RLE: Run Length Encoding)を行い,出力イテレータへ書き込む /// @note vec>をreserveし,それのback_inserter(back_insert_iterator)を渡すことが想定される /// @param r ランレングス圧縮したいrange /// @param out 出力イテレータ template , size_t>> I> requires std::copyable> && std::equality_comparable> void rle(R&& r, I out) { using pair = std::pair, size_t>; auto it = begin(r); auto e = end(r); if (it == e) { return; } size_t size = 1; rng::range_value_t prev = *it; ++it; for (; it != e; ++it) { if (*it == prev) { ++size; } else { *out++ = pair(std::move(prev), size); prev = *it; size = 1; } } *out++ = pair(std::move(prev), size); } namespace detail { template struct get { template // static constexpr decltype(auto) operator()(T&& t) noexcept(noexcept(std::get(t))) { return std::get(t); } }; } // namespace detail template inline constexpr auto get = detail::get{}; constexpr ll INF = 3e18; } // namespace tomolatoon namespace tomolatoon { void solve() { ll p, q; cin >> p >> q; ll y0, p0, q0, y; cin >> y0 >> p0 >> q0 >> y; auto d = y - y0; auto pd = ((p0 + d) % p + p) % p; auto qd = ((q0 + d) % q + q) % q; println("{} {}", pd != 0 ? pd : p, qd != 0 ? qd : q); } } // namespace tomolatoon int main() { #ifdef USE_ISTREAM std::cin.tie(nullptr); std::ios::sync_with_stdio(false); #endif #ifdef USE_OSTREAM std::cout << std::fixed << std::setprecision(16); #endif tomolatoon::solve(); #ifdef USE_OSTREAM std::cout << std::flush; #endif }