# https://github.com/robe2222555/atcoder-lib/blob/main/template/python/main.py import sys input = lambda: sys.stdin.readline().rstrip() def LI(): return list(map(int, input().split())) def II(): return int(input()) INF = 1<<60 def solve(): A,B,sx,sy,tx,ty = LI() sx += A*(10**8) sy += B*(10**8) tx += A*(10**8) ty += B*(10**8) sx -= sx%A sy -= sy%B tx -= tx%A ty -= ty%B print(abs(sx-tx)//A + abs(sy-ty)//B) return def main(): T = II() for _ in range(T): solve() return if __name__ == '__main__': main()