for _ in range(int(input())): a, b, sx, sy, tx, ty = map(int, input().split()) ans = abs(sx // a - tx // a) + abs(sy // b - ty // b) print(ans)