#include #include #include using namespace std; int main() { int inf = 1e8; int t; cin >> t; while (t--) { int a, b, sx, sy, tx, ty; cin >> a >> b >> sx >> sy >> tx >> ty; int bx = inf / a + 1, by = inf / b + 1; sx += bx * a; tx += bx * a; sy += by * b; ty += by * b; sx /= a; tx /= a; sy /= b; ty /= b; int ans = abs(sx - tx) + abs(sy - ty); cout << ans << endl; } }