#include #define ull unsigned ll #define ll long long #define ld long double #define INFL (ll)3e18 #define INF (int)2e9 #define MOD (ll)998244353 #define MODO (ll)(1e9+7) using namespace std; templateistream&operator>>(istream&is,vector&v); templateistream&operator>>(istream&is,tuple& t); templateistream&operator>>(istream&is,pair&p){is>>p.first>>p.second;return is;} templateistream&operator>>(istream&is,vector&v){for(T&in:v)is>>in;return is;} templateistream& operator>>(istream& is, tuple& t) {apply([&](auto&... args) {((is >> args), ...);},t);return is;} int main(void){ ios::sync_with_stdio(false); cin.tie(nullptr); int q; cin >> q; while(q--){ ll a,b,sx,sy,tx,ty; cin >> a >> b >> sx >> sy >> tx >> ty; sx++,sy++,tx++,ty++; sx = (sx+a-1)/a; sy = (sy+b-1)/b; tx = (tx+a-1)/a; ty = (ty+b-1)/b; //cout << sx << " " << sy << " " << tx << " " << ty << endl; cout << abs(tx-sx)+abs(ty-sy) << endl; } }