#if !__INCLUDE_LEVEL__ #include __FILE__ // using mint = modint; int div_floor(int a, int b) { if (b < 0) { a = -a; b = -b; } return a >= 0 ? a / b : (a + 1) / b - 1; } void solve(){ int a, b, sx, sy, tx, ty; in(a, b, sx, sy, tx, ty); sx = div_floor(sx, a); sy = div_floor(sy, b); tx = div_floor(tx, a); ty = div_floor(ty, b); outln(abs(sx - tx) + abs(sy - ty)); } /* 斜め移動がないので普通に属するタイルのインデックスの差の和 */ signed main(){ ios::sync_with_stdio(false); cin.tie(nullptr); out(fixed); out(setprecision(15)); err(fixed); err(setprecision(15)); int t = 1; cin >> t; while(t--) solve(); } #else // __INCLUDE_LEVEL #if __has_include() #include #else // no yoniha/all.h #include using namespace std; #if __has_include() #include using namespace atcoder; // ----------ACL用---------- // __has_include("atcoder/all")環境下に置く // ----------入力---------- template istream& operator>>(istream& is, static_modint& x) { signed w; is >> w; x = w; return is; } template istream& operator>>(istream& is, dynamic_modint& x) { signed w; is >> w; x = w; return is; } // ----------出力---------- template ostream& operator<<(ostream& os, static_modint& x) { return os << x.val(); } template ostream& operator<<(ostream& os, dynamic_modint& x) { return os << x.val(); } // ----------ACL用ここまで---------- #endif // atdoder/all // ----------bits/stdc++.h用---------- // yoniha/all.hがない環境下に置く // ----------マクロ、便利関数---------- #define int long long #define all(x) (x).begin(), (x).end() #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define rrep(i, n) for(int i = (int)((n) - 1); i >= 0; i--) template bool chmax(T& a, const T& b) { if(a < b) { a = b; return true; } return false; } template bool chmin(T& a, const T& b) { if(a > b) { a = b; return true; } return false; } template void sort(vector& a, Args&&... args) { sort(all(a), args...); } template void reverse(vector& a) { reverse(all(a)); } template void unique_erase(vector& a) { a.erase(unique(all(a)), a.end()); } template auto min_element(vector& a, auto&& comp = less()) { return min_element(all(a), comp); } template auto max_element(vector& a, auto&& comp = less()) { return max_element(all(a), comp); } template auto lower_bound(vector& a, Args&&... args) { return lower_bound(all(a), args...); } template auto upper_bound(vector& a, Args&&... args) { return upper_bound(all(a), args...); } template auto binary_search(vector& a, Args&&... args) { return binary_search(all(a), args...); } template auto next_permutation(vector& a) { return next_permutation(all(a)); } template auto reduce(vector& a, Args&&... args) { return reduce(all(a), args...); } // ----------定数やusing---------- template using Dijk = priority_queue, greater<>>; constexpr array, 4> dij{{{-1, 0}, {0, -1}, {1, 0}, {0, 1}}}; // 上から半時計周り constexpr int inf = 1ll << 60; // ----------ライブラリ---------- // ----------入力---------- istream& operator>>(istream& is, __int128_t& x) { int w; is >> w; assert(is); x = w; return is; } template istream& operator>>(istream& is, pair& p) { auto&& [p1, p2] = p; is >> p1 >> p2; return is; } template istream& operator>>(istream& is, tuple& t) { apply([&](auto&... xs) { ((is >> xs), ...); }, t); return is; } template istream& operator>>(istream& is, vector& v) { for(auto&& x : v) is >> x; return is; } template void in(Args&&... args) { ((cin >> args), ...); } // ----------出力---------- ostream& operator<<(ostream& os, __int128_t& x) { if(x == 0) return os << '0'; if(x < 0) os << '-'; string s; __int128_t w = x < 0 ? -x : x; while(w > 0) { s += char(w % 10 + '0'); w /= 10; } reverse(all(s)); return os << s; } template ostream& operator<<(ostream& os, pair& p) { auto&& [p1, p2] = p; return os << p1 << ' ' << p2; } template ostream& operator<<(ostream& os, tuple& t) { apply([&](auto&... xs) { ((os << xs), ...); }, t); return os; } template ostream& operator<<(ostream& os, vector& v) { for(size_t i = 0; i < v.size(); i++) os << v[i] << (i + 1 == v.size() ? "" : " "); return os; } void out() {} // 引数なしは何もしない(outln()がバグるのを防ぐ) template void out(T&& first, Args&&... args) { cout << first; ((cout << ' ' << args), ...); } template void outln(Args&&... args) { out(args...); cout << '\n'; } void err() {} // 引数なしは何もしない(errln()がバグるのを防ぐ) template void err(T&& first, Args&&... args) { cerr << first; ((cerr << ' ' << args), ...); } template void errln(Args&&... args) { err(args...); cerr << '\n'; } #endif // yoniha/all.h #endif // __INCLUDE_LEVEL__