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