/* -*- coding: utf-8 -*- * * 3796.cc: No.3796 Fanmade Tile Distance - yukicoder */ #include #include using namespace std; /* constant */ /* typedef */ /* global variables */ /* subroutines */ int calc(int x, int a) { return (x >= 0) ? x / a : (x + 1) / a - 1; } /* main */ int main() { int tn; scanf("%d", &tn); while (tn--) { int a, b, sx, sy, tx, ty; scanf("%d%d%d%d%d%d", &a, &b, &sx, &sy, &tx ,&ty); int si = calc(sx, a); int sj = calc(sy, b); int ti = calc(tx, a); int tj = calc(ty, b); printf("%d\n", abs(ti - si) + abs(tj - sj)); } return 0; }