Sam lives in Awesomeburg, its downtown has a triangular shape. Also, the following is true about the triangle:

its vertices have integer coordinates,

the coordinates of vertices are non-negative, and

its vertices are not on a single line.

He calls a point on the downtown's border (that is the border of the triangle) safe if he can reach this point from at least one point of the line $y = 0$ walking along some straight line, without crossing the interior of the triangle.

In the picture the downtown is marked with grey color. The first path is invalid because it does not go along a straight line. The second path is invalid because it intersects with the interior of the downtown. The third and fourth paths are correct.

Find the total length of the unsafe parts of the downtown border. It can be proven that these parts are segments and their number is finite.


-----Input-----

Each test contains multiple test cases. The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases. Description of the test cases follows.

Each test case contains three lines, each of them contains two integers $x_i$, $y_i$ ($0 \le x_i, y_i \le 10^9$) — coordinates of the vertices of the downtown's border.


-----Output-----

For each test case print a single number — the answer to the problem.

Your answer will be considered correct if its absolute or relative error does not exceed $10^{-9}$. Formally let your answer be $a$, jury answer be $b$. Your answer will be considered correct if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-9}$.


-----Examples-----

Input
5
8 10
10 4
6 2
4 6
0 1
4 2
14 1
11 2
13 2
0 0
4 0
2 4
0 1
1 1
0 0
Output
0.0000000
0
2.0000
0.00
1


-----Note-----

In the picture, the downtowns of the first three test cases are illustrated. Triangles are enumerated according to the indices of test cases they belong to.

In the first two test cases, all points on the borders of the downtowns are safe, thus the answers are $0$.

In the following picture unsafe points for the third test case are marked with black color:

In the fourth test case, all points on the border of the downtown are safe.

Source: codeforces | Difficulty: EASY
Tags: Geometry


Solutions:
for _ in range(int(input())):
	d = []
	for i in range(3):
		(x, y) = list(map(int, input().split()))
		d.append([x, y])
	if d[0][1] == d[1][1] and d[2][1] < d[1][1]:
		print(abs(d[0][0] - d[1][0]))
	elif d[1][1] == d[2][1] and d[0][1] < d[1][1]:
		print(abs(d[1][0] - d[2][0]))
	elif d[2][1] == d[0][1] and d[1][1] < d[2][1]:
		print(abs(d[2][0] - d[0][0]))
	else:
		print(0)


t = int(input())
for _ in range(t):
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	if y1 == y2 and y1 != 0 and (y3 < y1):
		print(abs(x1 - x2))
	elif y2 == y3 and y2 != 0 and (y1 < y2):
		print(abs(x2 - x3))
	elif y1 == y3 and y3 != 0 and (y2 < y1):
		print(abs(x1 - x3))
	else:
		print(0)


t = int(input())
while t:
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	ans = 0
	if y1 == y2 and y3 < y1 and y1 and y2:
		ans += abs(x1 - x2)
	elif y1 == y3 and y2 < y1 and y1 and y3:
		ans += abs(x1 - x3)
	elif y2 == y3 and y1 < y2 and y3 and y2:
		ans += abs(x2 - x3)
	print(ans)
	t -= 1


t = int(input())
for i in range(t):
	l = []
	for j in range(3):
		(x, y) = map(int, input().split())
		l.append([x, y])
	m1 = l[1][1] - l[0][1]
	m2 = l[2][1] - l[0][1]
	m3 = l[2][1] - l[1][1]
	if m1 != 0 and m2 != 0 and (m3 != 0):
		print(0)
	else:
		if m1 == 0:
			if l[2][1] < l[1][1]:
				print(abs(l[1][0] - l[0][0]))
			else:
				print(0)
		if m2 == 0:
			if l[1][1] < l[0][1]:
				print(abs(l[2][0] - l[0][0]))
			else:
				print(0)
		if m3 == 0:
			if l[0][1] < l[1][1]:
				print(abs(l[2][0] - l[1][0]))
			else:
				print(0)


t = int(input())
for i in range(t):
	p1 = list(map(int, input().split()))
	p2 = list(map(int, input().split()))
	p3 = list(map(int, input().split()))
	if p1[1] == p2[1] and p3[1] < p1[1]:
		print(abs(p1[0] - p2[0]))
		continue
	elif p2[1] == p3[1] and p1[1] < p2[1]:
		print(abs(p2[0] - p3[0]))
		continue
	elif p3[1] == p1[1] and p2[1] < p3[1]:
		print(abs(p3[0] - p1[0]))
		continue
	else:
		print(0)


import sys
from sys import stdin, stdout
from math import ceil, floor, sqrt, log, log2, log10
from collections import Counter
int_max = float('inf')
int_min = -float('inf')
mod = 10 ** 9 + 7
ANS = []
input = stdin.readline

def solve():
	pass
t = int(input())
for i in range(t):
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	ans = 0
	if y1 == y2:
		if y3 < y1:
			ans = abs(x1 - x2)
	if y2 == y3:
		if y1 < y2:
			ans = abs(x2 - x3)
	if y3 == y1:
		if y2 < y1:
			ans = abs(x3 - x1)
	print(ans)


def main():
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	if y1 == y2:
		if y3 > y1:
			return 0
		else:
			return abs(x1 - x2)
	if y2 == y3:
		if y1 > y2:
			return 0
		else:
			return abs(x2 - x3)
	if y1 == y3:
		if y2 > y1:
			return 0
		else:
			return abs(x1 - x3)
	return 0
for _ in range(int(input())):
	print(main())


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(c, d) = map(int, input().split())
	(e, f) = map(int, input().split())
	if b == d and f < b:
		print(abs(a - c))
	elif b == f and d < b:
		print(abs(a - e))
	elif d == f and b < d:
		print(abs(c - e))
	else:
		print(0)


for _ in range(int(input())):
	(x1, y1) = list(map(int, input().split()))
	(x2, y2) = list(map(int, input().split()))
	(x3, y3) = list(map(int, input().split()))
	n = 0
	if y1 == y2 and y1 != 0 and (abs(y3) < abs(y2)):
		n = abs(x2 - x1)
	elif y2 == y3 and y2 != 0 and (abs(y1) < abs(y2)):
		n = abs(x3 - x2)
	elif y3 == y1 and y1 != 0 and (abs(y2) < abs(y3)):
		n = abs(x3 - x1)
	print(n)


t = int(input())
l = []
for i in range(t):
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = list(map(int, input().split()))
	if l1[1] == l2[1] and l1[1] > l3[1]:
		l += [abs(l1[0] - l2[0])]
	elif l2[1] == l3[1] and l2[1] > l1[1]:
		l += [abs(l3[0] - l2[0])]
	elif l1[1] == l3[1] and l1[1] > l2[1]:
		l += [abs(l1[0] - l3[0])]
	else:
		l += [0]
for i in l:
	print(i)


n = int(input())
for i in range(n):
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	if y1 == y2 and y3 < y1:
		print(abs(x1 - x2))
	elif y2 == y3 and y1 < y2:
		print(abs(x2 - x3))
	elif y1 == y3 and y2 < y3:
		print(abs(x1 - x3))
	else:
		print(0)


import sys
input = sys.stdin.readline

def solve(arr):
	arr.sort(key=lambda x: x[1])
	(a, b) = arr[0]
	(c, d) = arr[1]
	(e, f) = arr[2]
	if d == f and b < d:
		print(abs(float(c - e)))
	else:
		print(0)
for _ in range(int(input())):
	arr = []
	for _ in range(3):
		(x, y) = map(int, input().split())
		arr.append([x, y])
	solve(arr)


import math

def slope(a, b, c, d, e, f):
	if b == d and b != 0 and (f < b) and (f < d):
		return True
	else:
		return False

def distance(a, b, c, d):
	return abs(a - c)
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	(c, d) = map(int, input().split())
	(x, y) = map(int, input().split())
	if slope(a, b, c, d, x, y):
		print(distance(a, b, c, d))
	elif slope(a, b, x, y, c, d):
		print(distance(a, b, x, y))
	elif slope(x, y, c, d, a, b):
		print(distance(x, y, c, d))
	else:
		print(0)


import math
for i in range(int(input())):
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	if y1 == y2 and y3 < y2:
		res = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
	elif y2 == y3 and y1 < y2:
		res = math.sqrt((x3 - x2) ** 2 + (y3 - y2) ** 2)
	elif y1 == y3 and y2 < y3:
		res = math.sqrt((x3 - x1) ** 2 + (y3 - y1) ** 2)
	else:
		res = 0
	print(res)


for _ in range(int(input())):
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	c = [[y1, x1], [y2, x2], [y3, x3]]
	c.sort()
	if c[2][0] == c[1][0] == c[0][0]:
		print(0)
	elif c[2][0] == c[1][0]:
		print(abs(c[2][1] - c[1][1]))
	else:
		print(0)


t = int(input())
for i in range(t):
	lst = []
	for j in range(3):
		lst.append(list(map(int, input().split())))
	if lst[0][1] == lst[1][1] and lst[0][1] > lst[2][1]:
		print(abs(lst[0][0] - lst[1][0]))
	elif lst[0][1] == lst[2][1] and lst[0][1] > lst[1][1]:
		print(abs(lst[0][0] - lst[2][0]))
	elif lst[1][1] == lst[2][1] and lst[1][1] > lst[0][1]:
		print(abs(lst[1][0] - lst[2][0]))
	else:
		print(0)


def solve():
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	ans = 0
	if y1 != y2 and y2 != y3 and (y1 != y3):
		ans = 0
	elif y1 == y2 and y3 < y1:
		ans = abs(x2 - x1)
	elif y1 == y3 and y2 < y1:
		ans = abs(x3 - x1)
	elif y2 == y3 and y1 < y2:
		ans = abs(x3 - x2)
	print(ans)
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	(x1, y1) = list(map(int, input().split(' ')))
	(x2, y2) = list(map(int, input().split(' ')))
	(x3, y3) = list(map(int, input().split(' ')))
	ans = 0
	if y1 == y2 or y2 == y3 or y1 == y3:
		if y1 == y2 and y3 < y2:
			ans = abs(x2 - x1)
		if y3 == y2 and y1 < y2:
			ans = abs(x2 - x3)
		if y1 == y3 and y2 < y3:
			ans = abs(x3 - x1)
	else:
		ans = 0
	print(ans)


def dist(x1, y1, x2, y2):
	x = (x1 - x2) ** 2
	y = (y1 - y2) ** 2
	return (x + y) ** (1 / 2)
t = int(input())
for _ in range(t):
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	if y1 == y2 and y1 != 0 and (y3 < y1):
		ans = dist(x1, y1, x2, y2)
	elif y2 == y3 and y2 != 0 and (y1 < y2):
		ans = dist(x2, y2, x3, y3)
	elif y3 == y1 and y3 != 0 and (y2 < y3):
		ans = dist(x3, y3, x1, y1)
	else:
		ans = 0
	print(ans)


import math
for _ in range(int(input())):
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	if a[1] == b[1] and a[1] > c[1]:
		print(abs(a[0] - b[0]))
	elif a[1] == c[1] and a[1] > b[1]:
		print(abs(a[0] - c[0]))
	elif b[1] == c[1] and b[1] > a[1]:
		print(abs(b[0] - c[0]))
	else:
		print(0)


n = int(input())
l = []
for i in range(n):
	k = 0
	while k != 3:
		(x, y) = input().split()
		l.extend([int(x), int(y)])
		k = k + 1

def fun1(x):
	x1 = l[x]
	y1 = l[x + 1]
	x2 = l[x + 2]
	y2 = l[x + 3]
	x3 = l[x + 4]
	y3 = l[x + 5]
	if y1 == y2:
		if y3 < y1:
			print(float(abs(x1 - x2)))
		else:
			print(0)
	elif y1 == y3:
		if y2 < y1:
			print(float(abs(x1 - x3)))
		else:
			print(0)
	elif y2 == y3:
		if y1 < y2:
			print(float(abs(x2 - x3)))
		else:
			print(0)
	else:
		print(float(0))
for i in range(0, len(l), 6):
	fun1(i)


for _ in range(int(input())):
	A = [int(i) for i in input().split()]
	B = [int(i) for i in input().split()]
	C = [int(i) for i in input().split()]
	distance = 0
	if A[1] == B[1] and A[1] == 0:
		print(0)
		continue
	elif B[1] == C[1] and C[1] == 0:
		print(0)
		continue
	elif A[1] == C[1] and A[1] == 0:
		print(0)
		continue
	if A[1] == B[1] and B[1] > C[1]:
		print(abs(A[0] - B[0]))
		continue
	elif B[1] == C[1] and B[1] > A[1]:
		print(abs(B[0] - C[0]))
		continue
	elif A[1] == C[1] and A[1] > B[1]:
		print(abs(A[0] - C[0]))
		continue
	else:
		print(0)
		continue


T = int(input())
for _ in range(T):
	(x1, y1) = [int(x) for x in input().split(' ')]
	(x2, y2) = [int(x) for x in input().split(' ')]
	(x3, y3) = [int(x) for x in input().split(' ')]
	if y1 == y2 and y3 < y2:
		print(abs(x1 - x2))
	elif y2 == y3 and y1 < y3:
		print(abs(x2 - x3))
	elif y1 == y3 and y2 < y1:
		print(abs(x3 - x1))
	else:
		print(0)


import math
for _ in range(int(input())):
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	if y1 == y2 and y3 < y1:
		print(abs(x1 - x2))
		continue
	if y3 == y1 and y2 < y1:
		print(abs(x1 - x3))
		continue
	if y3 == y2 and y1 < y3:
		print(abs(x2 - x3))
		continue
	print(0)


a = int(input())
for i in range(a):
	b = input().split()
	c = input().split()
	d = input().split()
	if int(b[1]) == int(c[1]) and int(d[1]) < int(b[1]):
		print(abs(int(b[0]) - int(c[0])))
	elif int(b[1]) == int(d[1]) and int(c[1]) < int(b[1]):
		print(abs(int(b[0]) - int(d[0])))
	elif int(c[1]) == int(d[1]) and int(b[1]) < int(c[1]):
		print(abs(int(d[0]) - int(c[0])))
	else:
		print(0)


def length(x_1, y_1, x_2, y_2, x_3, y_3):
	total = 0
	if y_1 == y_2 and y_1 != 0 and (y_3 < y_2):
		total += abs(x_1 - x_2)
	elif y_2 == y_3 and y_2 != 0 and (y_1 < y_2):
		total += abs(x_2 - x_3)
	elif y_3 == y_1 and y_1 != 0 and (y_2 < y_3):
		total += abs(x_3 - x_1)
	return total
t = int(input())
lst = []
for i in range(0, t):
	(x_1, y_1) = map(float, input().split())
	(x_2, y_2) = map(float, input().split())
	(x_3, y_3) = map(float, input().split())
	lst.append(length(x_1, y_1, x_2, y_2, x_3, y_3))
print(*lst, sep='\n')


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	(c, d) = map(int, input().split())
	(e, f) = map(int, input().split())
	if b == d:
		if f < d:
			print(abs(a - c))
		else:
			print(0)
	elif d == f:
		if b < d:
			print(abs(e - c))
		else:
			print(0)
	elif f == b:
		if d < f:
			print(abs(a - e))
		else:
			print(0)
	else:
		print(0)


tests = int(input())
for test in range(tests):
	a = input().split()
	b = input().split()
	c = input().split()
	aX = int(a[0])
	aY = int(a[1])
	bX = int(b[0])
	bY = int(b[1])
	cX = int(c[0])
	cY = int(c[1])
	minY = min(aY, bY, cY)
	if bX - aX != 0:
		gradientAB = (bY - aY) / (bX - aX)
		if gradientAB == 0 and aY > minY:
			print(abs(bX - aX))
			continue
	if cX - bX != 0:
		gradientBC = (cY - bY) / (cX - bX)
		if gradientBC == 0 and bY > minY:
			print(abs(cX - bX))
			continue
	if aX - cX != 0:
		gradientCA = (aY - cY) / (aX - cX)
		if gradientCA == 0 and cY > minY:
			print(abs(aX - cX))
			continue
	print(0)


import sys
input = sys.stdin.readline
tcs = int(input())
res = []
for _ in range(tcs):
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	ans = -1
	if y1 == y2 and y3 < y1:
		ans = abs(x2 - x1)
	elif y3 == y2 and y1 < y3:
		ans = abs(x3 - x2)
	elif y3 == y1 and y2 < y1:
		ans = abs(x3 - x1)
	else:
		ans = 0
	res.append(ans)
print(*res, sep='\n')


for _ in range(int(input())):
	k = []
	for i in range(3):
		(x, y) = map(int, input().split())
		k.append([x, y])
	ans = 0
	if k[0][1] == k[1][1]:
		if k[2][1] < k[0][1]:
			ans = abs(k[0][0] - k[1][0])
	elif k[1][1] == k[2][1]:
		if k[0][1] < k[1][1]:
			ans = abs(k[1][0] - k[2][0])
	elif k[2][1] == k[0][1]:
		if k[1][1] < k[2][1]:
			ans = abs(k[2][0] - k[0][0])
	print(ans)


def solve():
	(a1, b1) = map(float, input().split())
	(a2, b2) = map(float, input().split())
	(a3, b3) = map(float, input().split())
	if b1 == b2 and b3 < b2:
		result = abs(a1 - a2)
		print(result)
	elif b1 == b3 and b2 < b1:
		result = abs(a1 - a3)
		print(result)
	elif b2 == b3 and b1 < b2:
		result = abs(a2 - a3)
		print(result)
	else:
		print(0)
t = int(input())
for i in range(t):
	solve()


for _ in range(int(input())):
	nm = [list(map(int, input().split())) for i in range(3)]
	nm = sorted(nm, key=lambda a: a[1])
	print(0 if nm[1][1] != nm[2][1] else abs(nm[1][0] - nm[2][0]))


from math import sqrt as sq
t = int(input())
while t != 0:
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	if y1 == y2 and y3 < y1:
		ans = abs(x2 - x1)
	elif y1 == y3 and y2 < y1:
		ans = abs(x3 - x1)
	elif y2 == y3 and y1 < y2:
		ans = abs(x3 - x2)
	else:
		ans = 0
	print(ans)
	t -= 1


nbTest = int(input())
for testN in range(nbTest):
	p1 = [int(i) for i in input().split()]
	p2 = [int(i) for i in input().split()]
	p3 = [int(i) for i in input().split()]
	maxy = max(p1[1], p2[1], p3[1])
	if p1[1] == p2[1] and p1[1] == maxy:
		print(abs(p1[0] - p2[0]))
	elif p1[1] == p3[1] and p1[1] == maxy:
		print(abs(p1[0] - p3[0]))
	elif p3[1] == p2[1] and p3[1] == maxy:
		print(abs(p3[0] - p2[0]))
	else:
		print(0)


for _ in range(int(input())):
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	x = [x1, x2, x3]
	y = [y1, y2, y3]
	min_y = min(y)
	dist = 0
	for (i, item) in enumerate(y):
		if y.count(item) > 1:
			new_y = y.copy()
			new_y[i] += 1
			index = new_y.index(item)
			j = x[index]
			if item > min_y:
				dist += abs(x[i] - j)
				break
	print(dist)


n = int(input())
for i in range(n):
	po = []
	for j in range(3):
		(x, y) = map(int, input().split())
		po.append((y, x))
	po.sort()
	if po[2][0] != po[1][0]:
		print(0)
		continue
	print(abs(po[2][1] - po[1][1]))


def find(x, y, z):
	if x[1] == y[1] and z[1] <= x[1]:
		return abs(x[0] - y[0])
	if x[1] == z[1] and y[1] <= x[1]:
		return abs(x[0] - z[0])
	if y[1] == z[1] and x[1] <= y[1]:
		return abs(y[0] - z[0])
	return 0
cases = int(input())
for _ in range(cases):
	x = input().split()
	y = input().split()
	z = input().split()
	x = (int(x[0]), int(x[1]))
	y = (int(y[0]), int(y[1]))
	z = (int(z[0]), int(z[1]))
	print(find(x, y, z))


n = int(input())
for i in range(n):
	s = []
	for j in range(3):
		(x, y) = [int(num) for num in input().split(' ')]
		s.append([x, y])
	found = False
	for pt1 in s:
		if found:
			break
		for pt2 in s:
			if found:
				break
			for pt3 in s:
				if pt1 == pt2 or pt2 == pt3 or pt1 == pt3:
					continue
				if pt1[1] == pt2[1] and pt3[1] < pt1[1]:
					print(abs(pt1[0] - pt2[0]))
					found = True
					break
	if not found:
		print(0)


t = int(input())
for case in range(t):
	(a1, a2) = map(int, input().split())
	(b1, b2) = map(int, input().split())
	(c1, c2) = map(int, input().split())
	if a2 == b2 and c2 < a2:
		print(abs(a1 - b1))
	elif a2 == c2 and b2 < a2:
		print(abs(a1 - c1))
	elif c2 == b2 and a2 < c2:
		print(abs(c1 - b1))
	else:
		print(0)


for i in range(int(input())):
	m = []
	for i in range(3):
		(x, y) = map(int, input().split())
		m.append(x)
		m.append(y)
	if m[1] == m[3] and m[5] < m[1]:
		print(abs(m[2] - m[0]))
	elif m[3] == m[5] and m[1] < m[3]:
		print(abs(m[4] - m[2]))
	elif m[1] == m[5] and m[3] < m[1]:
		print(abs(m[4] - m[0]))
	else:
		print(0)


t = int(input())
for i in range(t):
	s = input()
	(x1, y1) = (int(s[:s.find(' ')]), int(s[s.find(' '):]))
	s = input()
	(x2, y2) = (int(s[:s.find(' ')]), int(s[s.find(' '):]))
	s = input()
	(x3, y3) = (int(s[:s.find(' ')]), int(s[s.find(' '):]))
	ans = 0
	if y1 == y2 and y3 < y1:
		ans = abs(x1 - x2)
	elif y1 == y3 and y2 < y1:
		ans = abs(x1 - x3)
	elif y2 == y3 and y1 < y2:
		ans = abs(x2 - x3)
	print(ans)


t = int(input())
for _ in range(t):
	a = []
	ans = 0
	for i in range(3):
		a.append(tuple(map(int, input().split())))
	for i in range(2):
		for j in range(i + 1, 3):
			if a[i][1] == a[j][1]:
				if a[3 - i - j][1] < a[i][1]:
					ans = abs(a[i][0] - a[j][0])
	print(ans)


def fun(a):
	if a > 0:
		return a
	else:
		return -a
for i in range(int(input())):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	if a[1] == b[1] and c[1] < b[1]:
		print(fun(b[0] - a[0]))
	elif b[1] == c[1] and a[1] < b[1]:
		print(fun(b[0] - c[0]))
	elif c[1] == a[1] and b[1] < c[1]:
		print(fun(c[0] - a[0]))
	else:
		print(0)


import sys

def get_int():
	return int(sys.stdin.readline())

def get_string():
	return sys.stdin.readline().strip()
FILE = False
if FILE:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
t = get_int()
for i in range(0, t):
	(x, y) = map(int, get_string().split())
	delta_one = [x, y]
	(x, y) = map(int, get_string().split())
	delta_two = [x, y]
	(x, y) = map(int, get_string().split())
	delta_three = [x, y]
	if delta_one[1] == delta_two[1] and delta_three[1] < delta_one[1]:
		dist = abs(delta_two[0] - delta_one[0])
	elif delta_two[1] == delta_three[1] and delta_one[1] < delta_two[1]:
		dist = abs(delta_two[0] - delta_three[0])
	elif delta_three[1] == delta_one[1] and delta_two[1] < delta_three[1]:
		dist = abs(delta_three[0] - delta_one[0])
	else:
		dist = 0
	sys.stdout.write(str(dist) + '\n')


import math

def isHorizontalLine(p1, p2):
	return p1[1] == p2[1]

def calcDistance(p1, p2):
	(x1, y1) = p1
	(x2, y2) = p2
	return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
t = int(input())
for _ in range(t):
	p1 = list(map(int, input().split()))
	p2 = list(map(int, input().split()))
	p3 = list(map(int, input().split()))
	(h1, h2, p) = ([], [], [])
	if isHorizontalLine(p1, p2):
		(h1, h2, p) = (p1, p2, p3)
	elif isHorizontalLine(p1, p3):
		(h1, h2, p) = (p1, p3, p2)
	elif isHorizontalLine(p2, p3):
		(h1, h2, p) = (p2, p3, p1)
	if len(h1) == 0 or h1[1] <= p[1]:
		print(0)
		continue
	print(calcDistance(h1, h2))


t = int(input())
for _ in range(t):
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())

	def solve(x1, y1, x2, y2, x3, y3):
		if y1 == y2:
			if y3 < y1:
				return abs(x2 - x1)
		if y2 == y3:
			if y1 < y2:
				return abs(x2 - x3)
		if y1 == y3:
			if y2 < y1:
				return abs(x1 - x3)
		return 0
	print(solve(x1, y1, x2, y2, x3, y3))


import sys
import bisect
inp = sys.stdin.readline

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)
for _ in range(int(inp())):
	(a, b) = map(int, input().split())
	(c, d) = map(int, input().split())
	(e, f) = map(int, input().split())
	if b == d and f < d:
		print(abs(a - c))
	elif d == f and b < f:
		print(abs(c - e))
	elif b == f and d < f:
		print(abs(a - e))
	else:
		print(0)


import sys
for _ in range(int(input())):
	(e, f) = map(int, input().split())
	(c, d) = map(int, input().split())
	(a, b) = map(int, input().split())
	if not any([f == d, d == b, f == b]):
		print(0)
	elif f == d:
		print(abs(c - e) * (f > b))
	elif d == b:
		print(abs(a - c) * (b > f))
	else:
		print(abs(a - e) * (f > d))


from array import *
n = int(input())
x = array('i', [])
y = array('i', [])
for i in range(n):
	a1 = list(map(int, input().split()))
	x.append(a1[0])
	y.append(a1[1])
	a2 = list(map(int, input().split()))
	x.append(a2[0])
	y.append(a2[1])
	a3 = list(map(int, input().split()))
	x.append(a3[0])
	y.append(a3[1])
for i in range(n):
	r = 0
	r1 = 0
	r2 = 0
	if y[3 * i] == y[3 * i + 1] and y[3 * i + 2] < y[3 * i + 1]:
		r = abs(x[3 * i] - x[3 * i + 1])
	else:
		r = 0
	if y[3 * i + 1] == y[3 * i + 2] and y[3 * i] < y[3 * i + 1]:
		r1 = abs(x[3 * i + 1] - x[3 * i + 2])
	else:
		r1 = 0
	if y[3 * i] == y[3 * i + 2] and y[3 * i + 1] < y[3 * i]:
		r2 = abs(x[3 * i] - x[3 * i + 2])
	else:
		r2 = 0
	print(r + r1 + r2)


import math
t = int(input())
end_result = ''
for _t in range(t):
	(ax, ay) = map(int, input().split())
	(bx, by) = map(int, input().split())
	(cx, cy) = map(int, input().split())
	x_points = [ax, bx, cx]
	y_points = [ay, by, cy]
	same_y = []
	same_y_x = []
	result = '0\n'
	if ay == by or by == cy or cy == ay:
		odd_y = None
		for (i, _y) in enumerate(y_points):
			if _y in y_points[:i] + y_points[i + 1:]:
				same_y.append(_y)
				same_y_x.append(x_points[i])
			else:
				odd_y = _y
		if len(same_y) == 2:
			if odd_y < ay or odd_y < by or odd_y < cy:
				result = str(abs(same_y_x[0] - same_y_x[-1])) + '\n'
	end_result += result
print(end_result.strip())


import sys

def _input_iter():
	for line in sys.stdin:
		for part in line.strip().split(' '):
			stripped = part.strip()
			if stripped:
				yield stripped
stream = _input_iter()

def read_int():
	return int(next(stream))

def read_str():
	return next(stream)

def run():
	(x1, y1, x2, y2, x3, y3) = (read_int(), read_int(), read_int(), read_int(), read_int(), read_int())
	result = 0
	if y1 == y2 and y3 < y1:
		result = x1 - x2 if x1 > x2 else x2 - x1
	elif y2 == y3 and y1 < y2:
		result = x2 - x3 if x2 > x3 else x3 - x2
	elif y3 == y1 and y2 < y3:
		result = x3 - x1 if x3 > x1 else x1 - x3
	print(result)
test_cases = read_int()
for _ in range(test_cases):
	run()


R = lambda : [*map(int, input().split())]
for m in [0] * R()[0]:
	(x, y) = zip(R(), R(), R())
	r = 0
	for i in (0, 1, 2):
		j = (i + 1) % 3
		r += y[i] == y[j] and y[(i - 1) % 3] < y[i] and ((x[i] - x[j]) ** 2 + (y[i] - y[j]) ** 2) ** 0.5
	print(r)


from sys import stdin
from math import log, floor, ceil, gcd
from collections import defaultdict as dd
input = stdin.readline
inp = lambda : int(stdin.readline())
rs = lambda : stdin.readline().strip()

def ra(typ):
	return list(map(typ, stdin.readline().split()))

def rv(typ):
	return map(typ, stdin.readline().split())

def main():
	for _ in range(inp()):
		(x1, y1) = rv(int)
		(x2, y2) = rv(int)
		(x3, y3) = rv(int)
		c = [[x1, y1], [x2, y2], [x3, y3]]
		c.sort(key=lambda x: x[1])
		if c[1][1] == c[2][1]:
			print(abs(c[1][0] - c[2][0]))
		else:
			print(0)
main()


num_cases = int(input())
for _ in range(num_cases):
	(x1, y1) = [int(each) for each in input().split(' ')]
	(x2, y2) = [int(each) for each in input().split(' ')]
	(x3, y3) = [int(each) for each in input().split(' ')]
	max_y = max(y1, y2, y3)
	l = [x for (x, y) in [(x1, y1), (x2, y2), (x3, y3)] if y == max_y]
	if len(l) == 1:
		print(0)
	else:
		print(max(l) - min(l))


p = int(input())
while p:
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	if a[1] == b[1] and a[1] != 0 and (c[1] < a[1]):
		print(abs(a[0] - b[0]))
	elif c[1] == b[1] and b[1] != 0 and (a[1] < c[1]):
		print(abs(c[0] - b[0]))
	elif a[1] == c[1] and a[1] != 0 and (b[1] < a[1]):
		print(abs(a[0] - c[0]))
	else:
		print('0')
	p -= 1


N = int(input())
for x in range(N):
	init = input().split()
	v1x = int(init[0])
	v1y = int(init[1])
	init = input().split()
	v2x = int(init[0])
	v2y = int(init[1])
	init = input().split()
	v3x = int(init[0])
	v3y = int(init[1])
	if v1y == v2y and v3y < v1y:
		print(abs(v2x - v1x))
	elif v2y == v3y and v1y < v2y:
		print(abs(v3x - v2x))
	elif v1y == v3y and v2y < v1y:
		print(abs(v3x - v1x))
	else:
		print(0)


z = lambda : map(int, input().split())
for t in range(int(input())):
	(a_1, b_1) = z()
	(a_2, b_2) = z()
	(a_3, b_3) = z()
	ans = 0
	if b_1 == b_2 and b_3 < b_1:
		ans = ((a_1 - a_2) ** 2 + (b_1 - b_2) ** 2) ** (1 / 2)
	elif b_1 == b_3 and b_2 < b_1:
		ans = ((a_1 - a_3) ** 2 + (b_1 - b_3) ** 2) ** (1 / 2)
	elif b_2 == b_3 and b_1 < b_2:
		ans = ((a_2 - a_3) ** 2 + (b_2 - b_3) ** 2) ** (1 / 2)
	print(ans)


out = []
for _ in range(int(input())):
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	if y1 == y2 and y3 < y1:
		out.append(abs(x1 - x2))
	elif y3 == y2 and y1 < y3:
		out.append(abs(x2 - x3))
	elif y3 == y1 and y2 < y1:
		out.append(abs(x1 - x3))
	else:
		out.append(0)
for i in out:
	print(i)


t = int(input())
for _ in range(t):
	(ax, ay) = (int(x) for x in input().split())
	(bx, by) = (int(x) for x in input().split())
	(cx, cy) = (int(x) for x in input().split())
	points = [(ax, ay), (bx, by), (cx, cy)]
	points.sort(key=lambda p: p[1])
	if points[1][1] == points[2][1]:
		print(abs(points[1][0] - points[2][0]))
		continue
	print(0)
	continue


t = int(input())
for i in range(t):
	(a1, b1) = map(int, input().split())
	(a2, b2) = map(int, input().split())
	(a3, b3) = map(int, input().split())
	if b1 == b2:
		if b3 < b2:
			print(abs(a1 - a2))
		else:
			print(0)
	elif b1 == b3:
		if b3 > b2:
			print(abs(a1 - a3))
		else:
			print(0)
	elif b3 == b2:
		if b1 < b2:
			print(abs(a3 - a2))
		else:
			print(0)
	else:
		print(0)


def dis(a, b):
	di = (b[1] - a[1]) ** 2 + (b[0] - a[0]) ** 2
	return di ** (1 / 2)
for tc in range(int(input())):
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	a3 = list(map(int, input().split()))
	if a1[1] == a2[1] and a1[1] != 0 and (a3[1] < a1[1]):
		print(dis(a1, a2))
	elif a2[1] == a3[1] and a2[1] != 0 and (a1[1] < a3[1]):
		print(dis(a2, a3))
	elif a3[1] == a1[1] and a3[1] != 0 and (a2[1] < a3[1]):
		print(dis(a3, a1))
	else:
		print(0)


import math

def lent(x1, y1, x2, y2):
	return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)

def solve():
	xy = []
	for i in range(0, 3):
		xy.append([int(x) for x in input().split()])
		(xy[i][0], xy[i][1]) = (xy[i][1], xy[i][0])
	tots = 0
	xy.sort()
	if xy[1][0] == xy[2][0]:
		tots += lent(xy[1][0], xy[1][1], xy[2][0], xy[2][1])
	print(tots)
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	a = tuple(map(int, input().split()))
	b = tuple(map(int, input().split()))
	c = tuple(map(int, input().split()))
	if a[1] == b[1] and c[1] < b[1]:
		print(abs(a[0] - b[0]))
	elif a[1] == c[1] and b[1] < c[1]:
		print(abs(a[0] - c[0]))
	elif b[1] == c[1] and a[1] < b[1]:
		print(abs(b[0] - c[0]))
	else:
		print(0)


T = int(input())
for t in range(T):
	li = []
	for i in range(3):
		li.append(list(map(int, input().split())))
	if li[0][1] == li[1][1] != 0 and li[2][1] < li[0][1]:
		print(abs(li[0][0] - li[1][0]))
	elif li[1][1] == li[2][1] != 0 and li[0][1] < li[1][1]:
		print(abs(li[1][0] - li[2][0]))
	elif li[0][1] == li[2][1] != 0 and li[1][1] < li[0][1]:
		print(abs(li[0][0] - li[2][0]))
	else:
		print(0)


for t in range(int(input())):
	coors = []
	for i in range(3):
		(x, y) = map(int, input().split())
		coors.append([x, y])
	if coors[0][1] == coors[1][1] and coors[0][1] != 0 and (coors[2][1] < coors[0][1]):
		print(abs(coors[0][0] - coors[1][0]))
	elif coors[0][1] == coors[2][1] and coors[0][1] != 0 and (coors[1][1] < coors[0][1]):
		print(abs(coors[0][0] - coors[2][0]))
	elif coors[1][1] == coors[2][1] and coors[1][1] != 0 and (coors[0][1] < coors[1][1]):
		print(abs(coors[1][0] - coors[2][0]))
	else:
		print(0)


import copy

def pp(A):
	for x in range(len(A) - 1):
		print(A[x], end=' ')
	print(A[-1])
t = int(input())
for i in range(t):
	(x1, y1) = [int(x) for x in input().split()]
	(x2, y2) = [int(x) for x in input().split()]
	(x3, y3) = [int(x) for x in input().split()]
	if y1 == y2 and y1 != 0 and (y3 < y1):
		print(abs(x2 - x1))
	elif y1 == y3 and y1 != 0 and (y2 < y1):
		print(abs(x3 - x1))
	elif y3 == y2 and y2 != 0 and (y1 < y2):
		print(abs(x2 - x3))
	else:
		print(0)


def solve(a, b, c):
	if a[1] == b[1]:
		if c[1] < a[1]:
			return abs(a[0] - b[0])
	if a[1] == c[1]:
		if b[1] < a[1]:
			return abs(a[0] - c[0])
	if b[1] == c[1]:
		if a[1] < b[1]:
			return abs(b[0] - c[0])
	return 0
t = int(input())
while t:
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	print(solve(a, b, c))
	t -= 1


def nCr(n, r):
	return fact(n) / (fact(r) * fact(n - r))

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res = res * i
	return res
mod = 10 ** 4
ans = 0

def nextPowerOf2(n):
	count = 0
	if n and (not n & n - 1):
		return n
	while n != 0:
		n >>= 1
		count += 1
	return 1 << count
from collections import defaultdict
import math
for _ in range(int(input())):
	(x1, y1) = list(map(int, input().split()))
	(x2, y2) = list(map(int, input().split()))
	(x3, y3) = list(map(int, input().split()))
	if y1 == y2 and y3 < y1:
		print(((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5)
	elif y1 == y3 and y2 < y1:
		print(((x1 - x3) ** 2 + (y1 - y3) ** 2) ** 0.5)
	elif y2 == y3 and y1 < y2:
		print(((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5)
	else:
		print(0)


for _ in range(int(input())):
	l = []
	for i in range(3):
		(x, y) = map(int, input().split())
		l += [[x, y]]
	t = 0
	for i in range(3):
		for j in range(3):
			if i != j:
				if l[i][1] == l[j][1]:
					(q, w) = (i, j)
					t = 1
					break
	if t:
		for i in range(3):
			if i != w and i != q:
				if l[i][1] < l[w][1]:
					print(abs(l[w][0] - l[q][0]))
					t = 0
					break
		if t:
			print(0)
	else:
		print(0)


for _ in range(int(input())):
	(lx, ly) = ([], [])
	for i in range(3):
		(x, y) = map(int, input().strip().split())
		lx.append(x)
		ly.append(y)
	if ly[0] == ly[1] and ly[2] < ly[0]:
		print(abs(lx[1] - lx[0]))
	elif ly[1] == ly[2] and ly[0] < ly[1]:
		print(abs(lx[2] - lx[1]))
	elif ly[2] == ly[0] and ly[1] < ly[0]:
		print(abs(lx[2] - lx[0]))
	else:
		print(0)


t = int(input())
for i in range(t):
	a = []
	a += [list(map(int, input().split()))[::-1]]
	a += [list(map(int, input().split()))[::-1]]
	a += [list(map(int, input().split()))[::-1]]
	a.sort()
	if a[1][0] == a[2][0]:
		print(a[2][1] - a[1][1])
	else:
		print(0)


import sys
from math import *
from functools import *

def f(x, y):
	for i in range(3):
		for j in range(i + 1, 3):
			if y[i] == y[j]:
				return (i, j)
	return -1
for _ in range(int(input())):
	x = []
	y = []
	for _ in range(3):
		(a, b) = map(int, input().split())
		x.append(a)
		y.append(b)
	if y[0] == y[1] and y[0] > y[2]:
		print(abs(x[0] - x[1]))
	elif y[0] == y[2] and y[0] > y[1]:
		print(abs(x[0] - x[2]))
	elif y[2] == y[1] and y[0] < y[2]:
		print(abs(x[2] - x[1]))
	else:
		print(0)


T = int(input())
for _ in range(T):
	X = [int(c) for c in input().split(' ')]
	Y = [int(c) for c in input().split(' ')]
	Z = [int(c) for c in input().split(' ')]
	ctr = 0
	for (V, W, E) in [[X, Y, Z], [X, Z, Y], [Y, Z, X]]:
		if V[1] == W[1]:
			if E[1] < V[1]:
				ctr += abs(V[0] - W[0])
				break
	print(ctr)


import math, sys
input = sys.stdin.readline
S = lambda : input().rstrip()
I = lambda : int(S())
M = lambda : map(int, S().split())
L = lambda : list(M())
mod1 = 1000000007
mod2 = 998244353
for _ in range(I()):
	(x1, y1) = M()
	(x2, y2) = M()
	(x3, y3) = M()
	ans = 0
	if y1 == y2 and y1 > 0 and (y3 < y1) or (y1 == y2 and y1 < 0 and (y3 > y1)):
		ans += abs(x1 - x2)
	if y1 == y3 and y1 > 0 and (y2 < y1) or (y1 == y3 and y1 < 0 and (y2 > y1)):
		ans += abs(x3 - x1)
	if y2 == y3 and y2 > 0 and (y1 < y2) or (y2 == y3 and y2 < 0 and (y1 > y2)):
		ans += abs(x3 - x2)
	print(ans)