#include using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int t; cin >> t; while (t--) { ll a, b, sx, sy, tx, ty; cin >> a >> b >> sx >> sy >> tx >> ty; sx += 1e8 * a; tx += 1e8 * a; sy += 1e8 * b; ty += 1e8 * b; cout << abs(sx / a - tx / a) + abs(sy / b - ty / b) << endl; } return 0; }