The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.

The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.

There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.

------ Input ------ 

The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.

------ Output ------ 

For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".

To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.

----- Sample Input 1 ------ 
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
----- Sample Output 1 ------ 
yes
yes
no

Source: codechef | Difficulty: EASY
Tags: Geometry

Mathematics


Solutions:
for t in range(int(input())):
	r = int(input())
	(x1, y1) = [int(i) for i in input().split()]
	(x2, y2) = [int(i) for i in input().split()]
	(x3, y3) = [int(i) for i in input().split()]
	r1 = ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5
	r2 = ((x3 - x1) ** 2 + (y3 - y1) ** 2) ** 0.5
	r3 = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5
	flag = 0
	if r1 <= r and r2 <= r and (r3 <= r):
		flag = 1
	elif r1 > r and r2 <= r and (r3 <= r) or (r2 > r and r1 <= r and (r3 <= r)) or (r3 > r and r2 <= r and (r1 <= r)):
		flag = 1
	if flag == 1:
		print('yes')
	else:
		print('no')


import math
t = int(input())
for _ in range(t):
	r = int(input())
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	d1 = math.sqrt(abs(x1 - x2) ** 2 + abs(y1 - y2) ** 2)
	d2 = math.sqrt(abs(x1 - x3) ** 2 + abs(y1 - y3) ** 2)
	d3 = math.sqrt(abs(x2 - x3) ** 2 + abs(y2 - y3) ** 2)
	if d1 <= r and d2 <= r or (d1 <= r and d3 <= r) or (d2 <= r and d3 <= r):
		print('yes')
	else:
		print('no')


for i in range(int(input())):
	x = int(input())
	l = []
	f = 0
	for j in range(3):
		(a, b) = map(int, input().split())
		l.append((a, b))
	(a, b) = l[0]
	(c, d) = l[1]
	p = ((a - c) ** 2 + (b - d) ** 2) ** 0.5
	(a, b) = l[1]
	(c, d) = l[2]
	q = ((a - c) ** 2 + (b - d) ** 2) ** 0.5
	(a, b) = l[0]
	(c, d) = l[2]
	r = ((a - c) ** 2 + (b - d) ** 2) ** 0.5
	if p <= x and q <= x or (q <= x and r <= x) or (r <= x and p <= x):
		print('yes')
	else:
		print('no')


t = int(input())
for _ in range(t):
	r = int(input())
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	s1 = ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5
	s2 = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5
	s3 = ((x3 - x1) ** 2 + (y3 - y1) ** 2) ** 0.5
	if s1 <= r and s3 <= r or (s1 <= r and s2 <= r) or (s2 <= r and s3 <= r):
		print('yes')
	else:
		print('no')


T = int(input())
for i in range(T):
	R = int(input())
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	d1 = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
	d2 = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5
	d3 = ((x3 - x1) ** 2 + (y3 - y1) ** 2) ** 0.5
	if d1 > R and d2 > R or (d2 > R and d3 > R) or (d3 > R and d1 > R):
		print('no')
	else:
		print('yes')


import math
t = int(input())
for i in range(t):
	r = int(input())
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	d1 = math.dist([x1, y1], [x2, y2])
	d2 = math.dist([x2, y2], [x3, y3])
	d3 = math.dist([x1, y1], [x3, y3])
	if d1 <= r and d2 <= r:
		print('yes')
	elif d2 <= r and d3 <= r:
		print('yes')
	elif d1 <= r and d3 <= r:
		print('yes')
	else:
		print('no')


for t in range(int(input())):
	r = int(input())
	(a1, a2) = map(int, input().split())
	(b1, b2) = map(int, input().split())
	(c1, c2) = map(int, input().split())
	d1 = ((a1 - b1) ** 2 + (a2 - b2) ** 2) ** 0.5
	d2 = ((c1 - b1) ** 2 + (c2 - b2) ** 2) ** 0.5
	d3 = ((a1 - c1) ** 2 + (a2 - c2) ** 2) ** 0.5
	if d1 > r and d2 > r or (d3 > r and d2 > r) or (d1 > r and d3 > r):
		print('no')
	else:
		print('yes')


from math import dist
for _ in range(int(input())):
	r = int(input())
	c = list(map(int, input().split()))
	hs = list(map(int, input().split()))
	sc = list(map(int, input().split()))
	a = dist(c, hs)
	b = dist(hs, sc)
	k = dist(sc, c)
	g = len([x for x in [a, b, k] if x <= r])
	if g >= 2:
		print('yes')
	else:
		print('no')


import math
t = int(input())
for tc in range(t):
	r = int(input())
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	d1 = (x2 - x1) ** 2 + (y2 - y1) ** 2
	d2 = (x3 - x2) ** 2 + (y3 - y2) ** 2
	d3 = (x3 - x1) ** 2 + (y3 - y1) ** 2
	c1 = math.sqrt(d1)
	c2 = math.sqrt(d2)
	c3 = math.sqrt(d3)
	if c1 <= r and c2 <= r or (c1 <= r and c3 <= r) or (c2 <= r and c3 <= r):
		print('yes')
	else:
		print('no')


for i in range(int(input())):
	a = int(input())
	l = []
	for k in range(3):
		l.append(list(map(int, input().split())))
	cnt = 0
	for k in range(3):
		x = (l[k][0] - l[(k + 1) % 3][0]) ** 2
		y = (l[k][1] - l[(k + 1) % 3][1]) ** 2
		d = (x + y) ** 0.5
		if d > a:
			cnt += 1
	if cnt > 1:
		print('no')
	else:
		print('yes')


for i in range(int(input())):
	n = int(input())
	(a, b) = map(int, input().split())
	(c, d) = map(int, input().split())
	(e, f) = map(int, input().split())
	count = 0
	x = ((a - c) ** 2 + (b - d) ** 2) ** 0.5
	y = ((c - e) ** 2 + (d - f) ** 2) ** 0.5
	z = ((a - e) ** 2 + (b - f) ** 2) ** 0.5
	if x > n:
		count += 1
	if y > n:
		count += 1
	if z > n:
		count += 1
	if count > 1:
		print('no')
	else:
		print('yes')


import math
for i in range(int(input())):
	r = int(input())
	x = []
	y = []
	c = 0
	for i in range(3):
		(n, m) = map(int, input().split())
		x.append(n)
		y.append(m)
	dch = math.sqrt((x[0] - x[1]) ** 2 + (y[0] - y[1]) ** 2)
	dcs = math.sqrt((x[0] - x[2]) ** 2 + (y[0] - y[2]) ** 2)
	dsh = math.sqrt((x[2] - x[1]) ** 2 + (y[2] - y[1]) ** 2)
	if dch <= r or (dcs <= r and dsh <= r):
		c = c + 1
	if dcs <= r or (dch <= r and dsh <= r):
		c = c + 1
	if dsh <= r or (dcs <= r and dch <= r):
		c = c + 1
	if c == 3:
		print('yes')
	else:
		print('no')


from math import sqrt
n = int(input())
for i in range(n):
	maxdist = int(input())
	chef = input().split()
	head = input().split()
	sous = input().split()
	head_dist = sqrt((int(chef[0]) - int(head[0])) ** 2 + (int(chef[1]) - int(head[1])) ** 2)
	sous_dist = sqrt((int(chef[0]) - int(sous[0])) ** 2 + (int(chef[1]) - int(sous[1])) ** 2)
	if head_dist <= maxdist and sous_dist <= maxdist:
		print('yes')
	elif head_dist <= maxdist or sous_dist <= maxdist:
		head_sous_dist = sqrt((int(head[0]) - int(sous[0])) ** 2 + (int(head[1]) - int(sous[1])) ** 2)
		if head_sous_dist <= maxdist:
			print('yes')
		else:
			print('no')
	else:
		print('no')


import math
for _ in range(int(input())):
	rangevalue = int(input())
	count = 0
	(cx, cy) = map(int, input().split())
	(hx, hy) = map(int, input().split())
	(sx, sy) = map(int, input().split())
	ch = math.sqrt((cx - hx) ** 2 + (cy - hy) ** 2)
	hs = math.sqrt((sx - hx) ** 2 + (sy - hy) ** 2)
	sc = math.sqrt((cx - sx) ** 2 + (cy - sy) ** 2)
	if ch <= rangevalue or (sc <= rangevalue and hs <= rangevalue):
		count += 1
	if hs <= rangevalue or (sc <= rangevalue and ch <= rangevalue):
		count += 1
	if sc <= rangevalue or (hs <= rangevalue and ch <= rangevalue):
		count += 1
	if count == 3:
		print('yes')
	else:
		print('no')


import math
for _ in range(int(input())):
	R = int(input())
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	d1 = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
	d2 = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5
	d3 = ((x3 - x1) ** 2 + (y3 - y1) ** 2) ** 0.5
	if d1 > R and d2 > R or (d2 > R and d3 > R) or (d3 > R and d1 > R):
		print('no')
	else:
		print('yes')


import math

def dist(a, b):
	return ((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2) ** 0.5
T = int(input())
for _ in range(T):
	r = float(input())
	a = list(map(float, input().split()))
	b = list(map(float, input().split()))
	c = list(map(float, input().split()))
	if dist(a, b) <= r and dist(b, c) <= r or (dist(a, b) <= r and dist(a, c) <= r) or (dist(a, c) <= r and dist(b, c) <= r):
		print('yes')
	else:
		print('no')


T = int(input())
for _ in range(T):
	R = int(input())
	((X1, Y1), (X2, Y2), (X3, Y3)) = (map(int, input().split()), map(int, input().split()), map(int, input().split()))
	D12 = (X1 - X2) ** 2 + (Y1 - Y2) ** 2 <= R ** 2
	D13 = (X1 - X3) ** 2 + (Y1 - Y3) ** 2 <= R ** 2
	D23 = (X2 - X3) ** 2 + (Y2 - Y3) ** 2 <= R ** 2
	d1 = D12 and D13
	d2 = D12 and D23
	d3 = D13 and D23
	if d1 or d2 or d3:
		print('yes')
	else:
		print('no')


t = int(input())
for i in range(t):
	r = int(input())
	l = []
	for j in range(3):
		(x, y) = map(int, input().split())
		l.append([x, y])
	b = ((l[1][0] - l[0][0]) ** 2 + (l[1][1] - l[0][1]) ** 2) ** 0.5
	a = ((l[2][0] - l[1][0]) ** 2 + (l[2][1] - l[1][1]) ** 2) ** 0.5
	c = ((l[0][0] - l[2][0]) ** 2 + (l[0][1] - l[2][1]) ** 2) ** 0.5
	if a <= r and b <= r:
		print('yes')
	elif b <= r and c <= r:
		print('yes')
	elif a <= r and c <= r:
		print('yes')
	else:
		print('no')


t = int(input())
for i in range(t):
	r = int(input())
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	a = ((x3 - x1) ** 2 + (y3 - y1) ** 2) ** 0.5
	b = ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5
	c = ((x3 - x2) ** 2 + (y3 - y2) ** 2) ** 0.5
	if a <= r or (b <= r and c <= r):
		print('yes')
	else:
		print('no')


import math
for t in range(int(input())):
	r = int(input())
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	d12 = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
	d23 = math.sqrt((x3 - x2) ** 2 + (y3 - y2) ** 2)
	d13 = math.sqrt((x3 - x1) ** 2 + (y3 - y1) ** 2)
	if d12 <= r and d23 <= r or (d23 <= r and d13 <= r) or (d12 <= r and d13 <= r):
		print('yes')
	else:
		print('no')


import math
for T in range(int(input())):
	r = int(input())
	chef = list(map(int, input().split()))
	h_server = list(map(int, input().split()))
	s_chef = list(map(int, input().split()))
	d1 = math.sqrt((h_server[0] - chef[0]) ** 2 + (h_server[1] - chef[1]) ** 2)
	d2 = math.sqrt((s_chef[0] - chef[0]) ** 2 + (s_chef[1] - chef[1]) ** 2)
	d3 = math.sqrt((h_server[0] - s_chef[0]) ** 2 + (h_server[1] - s_chef[1]) ** 2)
	if d1 <= r and d2 <= r:
		print('yes')
	elif d2 <= r and d3 <= r:
		print('yes')
	elif d1 <= r and d3 <= r:
		print('yes')
	else:
		print('no')


from math import dist
for _ in range(int(input())):
	r = int(input())
	chef = tuple(map(int, input().split()))
	head = tuple(map(int, input().split()))
	sous = tuple(map(int, input().split()))
	ch = dist(chef, head)
	cs = dist(chef, sous)
	hs = dist(head, sous)
	in_range = len([x for x in [ch, cs, hs] if x <= r])
	print('yes' if in_range >= 2 else 'no')


from math import dist
for i in range(int(input())):
	r = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	k = dist(a, b)
	u = dist(b, c)
	v = dist(c, a)
	g = len([x for x in [k, u, v] if x <= r])
	print('yes' if g >= 2 else 'no')


import math
for i in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	if math.dist(a, b) <= n and math.dist(c, b) <= n or math.dist(a, c) <= n:
		print('yes')
	else:
		print('no')


import math as m
for i in range(int(input())):
	n = int(input())
	(a, b) = map(int, input().split())
	(c, d) = map(int, input().split())
	(e, f) = map(int, input().split())
	count = 0
	x = m.sqrt((a - c) ** 2 + (b - d) ** 2)
	y = m.sqrt((c - e) ** 2 + (d - f) ** 2)
	z = m.sqrt((a - e) ** 2 + (b - f) ** 2)
	if x > n:
		count += 1
	if y > n:
		count += 1
	if z > n:
		count += 1
	if count > 1:
		print('no')
	else:
		print('yes')


import math
t = int(input())
for i in range(t):
	t_range = int(input())
	(x1, y1) = list(map(int, input().split()))
	(x2, y2) = list(map(int, input().split()))
	(x3, y3) = list(map(int, input().split()))
	d12 = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
	d23 = math.sqrt((x3 - x2) ** 2 + (y3 - y2) ** 2)
	d31 = math.sqrt((x3 - x1) ** 2 + (y3 - y1) ** 2)
	d_max = max(d12, d23, d31)
	if d_max == d12 and (d31 <= t_range and d23 <= t_range):
		print('yes')
	elif d_max == d23 and (d31 <= t_range and d12 <= t_range):
		print('yes')
	elif d_max == d31 and (d12 <= t_range and d23 <= t_range):
		print('yes')
	else:
		print('no')


t = int(input())
for i in range(t):
	r = int(input())
	chef = input().split(' ')
	head = input().split(' ')
	sous = input().split(' ')
	if ((int(chef[0]) - int(sous[0])) ** 2 + (int(chef[1]) - int(sous[1])) ** 2) ** 0.5 <= r:
		print('yes')
	elif ((int(chef[0]) - int(head[0])) ** 2 + (int(chef[1]) - int(head[1])) ** 2) ** 0.5 <= r and ((int(head[0]) - int(sous[0])) ** 2 + (int(head[1]) - int(sous[1])) ** 2) ** 0.5 <= r:
		print('yes')
	else:
		print('no')


for i in range(int(input())):
	r = int(input())
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	d1 = ((x3 - x1) ** 2 + (y3 - y1) ** 2) ** 0.5
	d2 = ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5
	d3 = ((x3 - x2) ** 2 + (y3 - y2) ** 2) ** 0.5
	if d1 <= r:
		print('yes')
	elif d2 <= r and d3 <= r:
		print('yes')
	else:
		print('no')


t = int(input())
while t:
	R = int(input())
	(x, y) = map(int, input().split())
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	A = ((x - x1) ** 2 + (y - y1) ** 2) ** (1 / 2)
	B = ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** (1 / 2)
	C = ((x - x2) ** 2 + (y - y2) ** 2) ** (1 / 2)
	if A <= R:
		if B <= R or C <= R:
			print('yes')
		else:
			print('no')
	elif B <= R:
		if A <= R or C <= R:
			print('yes')
		else:
			print('no')
	elif C <= R:
		if A <= R or B <= R:
			print('yes')
		else:
			print('no')
	elif A >= R and (B >= R and C >= R):
		print('no')
	t = t - 1


from math import sqrt

def dist(x1, y1, x2, y2):
	return sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
for _ in range(int(input())):
	r = int(input())
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	a = dist(x1, y1, x2, y2)
	b = dist(x2, y2, x3, y3)
	c = dist(x3, y3, x1, y1)
	if a <= r and b <= r or (c <= r and b <= r) or (a <= r and c <= r):
		print('yes')
	else:
		print('no')


for t in range(int(input())):
	n = int(input())
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	(i, j) = map(int, input().split())
	_ = ((i - x) ** 2 + (j - y) ** 2) ** 0.5
	__ = ((a - x) ** 2 + (b - y) ** 2) ** 0.5
	___ = ((i - a) ** 2 + (j - b) ** 2) ** 0.5
	if _ <= n:
		print('yes')
	elif __ <= n and ___ <= n:
		print('yes')
	else:
		print('no')


import math
t = int(input())
for i in range(t):
	r = int(input())
	(a, b) = map(int, input().split())
	(p, q) = map(int, input().split())
	(x, y) = map(int, input().split())
	dis_chef_head = (a - p) ** 2 + (b - q) ** 2
	dis_chef_sous = (a - x) ** 2 + (b - y) ** 2
	dis_sous_head = (p - x) ** 2 + (q - y) ** 2
	a = math.sqrt(dis_chef_head)
	b = math.sqrt(dis_chef_sous)
	c = math.sqrt(dis_sous_head)
	if a <= r and b <= r:
		print('yes')
	elif b <= r and c <= r:
		print('yes')
	elif a <= r and c <= r:
		print('yes')
	else:
		print('no')


import math
t = int(input())
for i in range(t):
	r = int(input())
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	x = math.dist([x1, y1], [x2, y2])
	y = math.dist([x1, y1], [x3, y3])
	z = math.dist([x3, y3], [x2, y2])
	if x <= r and y <= r:
		print('yes')
	elif x <= r and y > r:
		if z <= r:
			print('yes')
		else:
			print('no')
	elif x > r and y <= r:
		if z <= r:
			print('yes')
		else:
			print('no')
	else:
		print('no')


import math
for _ in range(int(input())):
	n = int(input())
	(a, b) = map(int, input().split())
	(c, d) = map(int, input().split())
	(e, f) = map(int, input().split())
	g = math.dist([a, b], [c, d])
	h = math.dist([c, d], [e, f])
	i = math.dist([e, f], [a, b])
	if g <= n and h <= n:
		print('yes')
	elif h <= n and i <= n:
		print('yes')
	elif g <= n and i <= n:
		print('yes')
	else:
		print('no')


import math
s = int(input())
for i in range(s):
	a = int(input())
	(b, c) = map(int, input().split(' '))
	(n, m) = map(int, input().split(' '))
	(p, q) = map(int, input().split(' '))
	x = math.sqrt((n - b) ** 2 + (m - c) ** 2)
	y = math.sqrt((b - p) ** 2 + (c - q) ** 2)
	z = math.sqrt((n - p) ** 2 + (m - q) ** 2)
	c = 0
	if x <= a or (y <= a and z <= a):
		c += 1
	if y <= a or (x <= a and z <= a):
		c += 1
	if z <= a or (x <= a and y <= a):
		c += 1
	if c == 3:
		print('yes')
	else:
		print('no')


import math

def func1(x1, y1, x2, y2):
	v = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
	if v <= r:
		return True
	else:
		return False
for _ in range(int(input())):
	r = int(input())
	(x1, y1) = list(map(int, input().split()))
	(x2, y2) = list(map(int, input().split()))
	(x3, y3) = list(map(int, input().split()))
	if func1(x2, y2, x1, y1) == True and func1(x3, y3, x2, y2) == True or func1(x3, y3, x1, y1) == True:
		print('yes')
	else:
		print('no')


for i in range(int(input())):
	n = int(input())
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	a = ((x3 - x1) ** 2 + (y3 - y1) ** 2) ** 0.5
	b = ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5
	c = ((x3 - x2) ** 2 + (y3 - y2) ** 2) ** 0.5
	if a <= n:
		print('yes')
	elif b <= n and c <= n:
		print('yes')
	else:
		print('no')


for _ in range(int(input())):
	r = int(input())
	(cx, cy) = map(int, input().strip().split())
	(hx, hy) = map(int, input().strip().split())
	(sx, sy) = map(int, input().strip().split())
	ctoh = (cx - hx) * (cx - hx) + (cy - hy) * (cy - hy)
	htos = (hx - sx) * (hx - sx) + (sy - hy) * (sy - hy)
	ctos = (cx - sx) * (cx - sx) + (sy - cy) * (sy - cy)
	if ctoh <= r * r and htos <= r * r or (ctos <= r * r and htos <= r * r) or (ctos <= r * r and ctoh <= r * r):
		print('yes')
	else:
		print('no')


for _ in range(int(input())):
	x = int(input())
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	dist1 = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** (1 / 2)
	dist2 = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** (1 / 2)
	dist3 = ((x3 - x1) ** 2 + (y3 - y1) ** 2) ** (1 / 2)
	count = 0
	if dist1 <= x:
		count += 1
	if dist2 <= x:
		count += 1
	if dist3 <= x:
		count += 1
	if count >= 2:
		print('yes')
	if count == 1 or count == 0:
		print('no')


import math
for i in range(int(input())):
	check = 'no'
	dif = float(input())
	d = list(map(float, input().split()))
	e = list(map(float, input().split()))
	f = list(map(float, input().split()))

	def functionW(a, b):
		r = ((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2) ** 0.5
		return r
	if functionW(d, e) <= dif and functionW(d, f) <= dif or (functionW(d, e) <= dif and functionW(e, f) <= dif) or (functionW(d, f) <= dif and functionW(e, f) <= dif):
		check = 'yes'
	print(check)


import math
for _ in range(int(input())):
	r = int(input())
	(a, b) = map(int, input().split())
	(c, d) = map(int, input().split())
	(e, f) = map(int, input().split())
	distance_1 = math.sqrt((a - c) ** 2 + (b - d) ** 2)
	distance_2 = math.sqrt((c - e) ** 2 + (d - f) ** 2)
	distance_3 = math.sqrt((a - e) ** 2 + (b - f) ** 2)
	list1 = [distance_3, distance_2, distance_1]
	ans = 0
	for i in range(3):
		if list1[i] <= r:
			ans += 1
	if ans >= 2:
		print('yes')
	else:
		print('no')


import math
for _ in range(int(input())):
	r = int(input())
	(c1, c2) = map(int, input().split())
	(h1, h2) = map(int, input().split())
	(s1, s2) = map(int, input().split())
	c = math.dist([c1, c2], [h1, h2])
	h = math.dist([h1, h2], [s1, s2])
	s = math.dist([s1, s2], [c1, c2])
	if c <= r and h <= r:
		print('yes')
	elif h <= r and s <= r:
		print('yes')
	elif c <= r and s <= r:
		print('yes')
	else:
		print('no')


import math
t = int(input())
for _ in range(t):
	n = int(input())
	(a, s) = map(int, input().split())
	(d, f) = map(int, input().split())
	(g, h) = map(int, input().split())
	x = math.sqrt((a - d) ** 2 + (s - f) ** 2)
	y = math.sqrt((d - g) ** 2 + (f - h) ** 2)
	z = math.sqrt((g - a) ** 2 + (h - s) ** 2)
	if (x <= n or y <= n) and (y <= n or z <= n) and (z <= n or x <= n):
		print('yes')
	else:
		print('no')


import math as m
for _ in range(int(input())):
	r = int(input())
	(x1, y1) = map(int, input().split(' '))
	(x2, y2) = map(int, input().split(' '))
	(x3, y3) = map(int, input().split(' '))
	if m.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2) <= r and (m.sqrt((x1 - x3) ** 2 + (y1 - y3) ** 2) <= r or m.sqrt((x3 - x2) ** 2 + (y3 - y2) ** 2) <= r):
		print('yes')
	elif m.sqrt((x1 - x3) ** 2 + (y1 - y3) ** 2) <= r and (m.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2) <= r or m.sqrt((x3 - x2) ** 2 + (y3 - y2) ** 2) <= r):
		print('yes')
	elif m.sqrt((x3 - x2) ** 2 + (y3 - y2) ** 2) <= r and (m.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2) <= r or m.sqrt((x1 - x3) ** 2 + (y1 - y3) ** 2) <= r):
		print('yes')
	else:
		print('no')


def func(x1, y1, x2, y2):
	d = ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5
	return d
for _ in range(int(input())):
	d1 = int(input())
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	b = func(x1, y1, x2, y2)
	a = func(x2, y2, x3, y3)
	c = func(x3, y3, x1, y1)
	if a <= d1 and b <= d1:
		print('yes')
	elif b <= d1 and c <= d1:
		print('yes')
	elif a <= d1 and c <= d1:
		print('yes')
	else:
		print('no')


import math
for _ in range(int(input())):
	r = int(input())
	comm = []
	(x1, y1) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	(x3, y3) = map(int, input().split())
	s12 = math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
	s23 = math.sqrt((x3 - x2) ** 2 + (y3 - y2) ** 2)
	s13 = math.sqrt((x1 - x3) ** 2 + (y1 - y3) ** 2)
	lis = [s12, s23, s13]
	for ele in lis:
		if ele <= r:
			comm.append(1)
		else:
			comm.append(0)
	if comm.count(1) >= 2:
		print('yes')
	else:
		print('no')