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