#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; if(sx > tx) swap(sx,tx); if(sy > ty) swap(sy,ty); if(sx < 0){ ll ad = (-sx+a-1)/a*a; sx += ad,tx += ad; } if(sy < 0){ ll ad = (-sy+b-1)/b*b; sy += ad,ty += ad; } //cout << sx << " " << tx << " " << sy << " " << ty << endl; sx++,sy++; sx = (sx+a-1)/a; sy = (sy+b-1)/b; tx /= a; ty /= b; //cout << sx << " " << tx << " " << sy << " " << ty << endl; cout << tx-sx+ty-sy+2 << endl; } }