EPS/2024/03/25-03-24/a.py

14 lines
290 B
Python

def main():
w, d, h = [int(i) for i in input().split()]
a, b, f, g = [int(i) for i in input().split()]
return h+min([
abs(f-a)+b+g,
abs(f-a)+(d-b)+(d-g),
abs(b-g)+f+a,
abs(b-g)+(w-f)+(w-a)
])
for _ in range(int(input())):
print(main())