counter-strike-12

Navi is a counter strike pro. He always say how good he is at counter strike. After being tired of Navi, his friends decided to test his skills at shooting.  They put M targets on a X-Y plane, each target is denoted by (X, Y) where X is x-coordinate and Y is y-coordinate. His friends also gave him N locations on X-Y plane from where Navi can shoot the targets. Navi knows that he can shoot a target if 
 Manhattan distance   between his location and target is ≤ D. If Navi can shoot more than half of the targets (for odd values of M check  only for the integral part of half of M, say M = 3,  \frac{2}{3} = 1) only then his friends believe that he is a pro at counter strike otherwise he is not. 

Input

First line of input contains an integers T denoting the number of test cases. First line of each test case consists of three integers N, M and D separated by a space. Next N lines of each test case contains a pair of integers denoting the X -co-ordinate and Y - co-ordinate. Next M lines of each test case contains a pair of integers denoting X -co-ordinate and Y - co-ordinate of each of the target.

N is number of shooting locations for Navi.  
M is number of targets. 
D is shooting range of Navi. 

Output
For each test case , Print "YES" if he is a pro else "NO" (without quotes) .
Constraints
 1 ≤ T ≤ 6  
 1 ≤ N ≤ 1000  
 1 ≤ M ≤ 1000  
  -50000 ≤ X, Y ≤ 50000 
  0 ≤ D ≤ 50000 
SAMPLE INPUT
1
3 3 5
1 1
2 2
3 3
1 0
0 0
2 0

SAMPLE OUTPUT
YES

Explanation

First location is at  (1, 1)  , we can shot any of the given targets  from here so  count >  \frac{3}{2} , therefore YES.

Source: hackerearth | Difficulty: EASY


Solutions:
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''

test = int(input())

for i in range(test):
	mat = input()
	[n,m,d] =  list(map(int, mat.split()))

	shoot_loc = []
	for j in range(n):
		loc = input()
		[x,y] = list(map(int,loc.split()))
		shoot_loc.append([x,y])
	
	tar_loc = []
	for k in range(m):
		loc = input()
		[x,y] = list(map(int,loc.split()))
		tar_loc.append([x,y])
	
	summ = 0
	for loc in tar_loc:
		dist = []
		for sho in shoot_loc:
			dist.append(abs(loc[0]-sho[0])+abs(loc[1]-sho[1]))
		if min(dist) <= d:
			summ = summ+1
			
	if summ > m/2:
		print("YES")
	else:
		print("NO")
	




	
	


def dist(x1,y1,x2,y2):
	return abs(x2-x1)+abs(y2-y1)
t=int(input())
for i in range(t):
	nar=[]
	mar=[]
	s=input().split()
	n=int(s[0])
	m=int(s[1])
	d=int(s[2])
	tar=m//2
	c=0
	for j in range(n):
		s=input().split()
		nar.append((int(s[0]),int(s[1])))
	for j in range(m):
		s=input().split()
		mar.append((int(s[0]),int(s[1])))
	for j in range(m):
		for k in range(n):
			if dist(mar[j][0],mar[j][1],nar[k][0],nar[k][1])<=d:
				c+=1
				break
	if c>tar:
		print("YES")
	else:
		print("NO")
		
		
		


import sys
for a in range(eval(input())):
	N,M,D=list(map(int,input().split()))
	ax=[0]*N; ay=[0]*N
	for i in range(N):
		st=input().split()
		ax[i]=int(st[0]); ay[i]=int(st[1])
	result=0;index=0	
	for i in range(M):
		x1,y1=list(map(int,sys.stdin.readline().split()))
		index=0
		for index in range(N):
			res=abs(x1-ax[index])+abs(y1-ay[index])
			if(res<=D):
				result+=1; break;
	if(result>M/2):
		print('YES')
	else:
		print('NO')
				


T=int(input())
while (T):
	N,M,D=input().split()
	N,M,D=int(N),int(M),int(D)
	sx=[0]*1007
	sy=[0]*1007
	cnt=0;
	for i in range (0,N):
		sx[i],sy[i]=input().split()
		sx[i],sy[i]=int(sx[i]),int(sy[i]);
	for i in range (0,M):
		x,y=input().split()
		x,y=int(x),int(y);
		for j in range (0,N):
			if (abs(sx[j]-x)+abs(sy[j]-y)<=D):
				cnt+=1
				break
	if (2*cnt>N):
		print("YES")
	else:
		print("NO")
	T-=1


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t=int(input())
while t>0:
	t=t-1
	n,m,d = list(map(int, input().split()))
	target = []
	location = []
	for i in range (0,n):
		x,y=list(map(int, input().split()))
		location.append((x,y))
	for i in range (0,m):
		x,y=list(map(int, input().split()))
		target.append((x,y))
	flag=0
	for hit in target:
		for loc in location:
			if abs(hit[0]-loc[0]) + abs(hit[1]-loc[1]) <=d :
				flag = flag+1
				break
	if flag > m/2:
		print("YES")
	else:
		print("NO")


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
def distance(a, b):
	return abs(a[0] - b[0]) + abs(a[1] - b[1])
	
for t in range(eval(input())):
	n, m, d = [int(x) for x in input().split()]
	req = m / 2
	
	pos = []
	for i in range(n):
		x, y = [int(s) for s in input().split()]
		pos.append((x, y))
		
	target = []
	for i in range(m):
		x, y = [int(s) for s in input().split()]
		target.append((x, y))
		
	
	count = 0
	for i in range(m):
		if count >= req:
			print("YES")
			break
		
		t = target[i]
		for j in pos:
			if distance(t, j) <= d:
				count += 1
				break
	else:
		if count < req:
			print("NO")
		else:
			print("YES")


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t= input()
t= int(t)
while t:
	arr= input()
	arr= arr.split(' ')
	n= int(arr[0])
	m= int(arr[1])
	d= int(arr[2])
	'''arr= raw_input()
	arr= arr.split(' ')'''
	nArrX= []
	nArrY= []
	mArrX= []
	mArrY= []
	shotArr= []
	count= 0
	target= m/2
	i= 0
	while i<n:
		arr= input()
		arr= arr.split(' ')
		nArrX.append(int(arr[0]))
		nArrY.append(int(arr[1]))
		i+=1
	i=0
	while i<m:
		arr= input()
		arr= arr.split(' ')
		mArrX.append(int(arr[0]))
		mArrY.append(int(arr[1]))
		shotArr.append(0)
		i+=1
	i=0
	while i<n:
		x1= nArrX[i]
		y1= nArrY[i]
		j=0
		while j<m:
			x2= mArrX[j]
			y2= mArrY[j]
			if (abs(x1-x2) + abs(y1-y2))<= d:
				if shotArr[j]==0:
					count += 1
					shotArr[j]=1
			j+=1
			if count>= target:
				break
		if count>= target:
			break
		i+=1
	if count>= target:
		print("YES")
	else:
		print("NO")
	t-=1


#Brute Force approach because constraints are small

import sys

for cases in range(int(sys.stdin.readline())):
	n,m,d = list(map(int, sys.stdin.readline().split()))
	loc = []
	for i in range(n):
		a,b = list(map(int, sys.stdin.readline().split()))
		loc.append((a,b))
	targets = []
	for i in range(m):
		a,b = list(map(int, sys.stdin.readline().split()))
		targets.append((a,b))
	count = 0
	flag = False
	for i in targets:
		for j in loc:
			dist = abs(i[0]-j[0]) + abs(i[1]-j[1])
			if dist <= d:
				count += 1
				break
		if count > m/2:
			flag = True
			break
	if flag:    print("YES")
	else:   print("NO")


import sys

for cases in range(int(sys.stdin.readline())):
	n,m,d = list(map(int, sys.stdin.readline().split()))
	loc = []
	for i in range(n):
		a,b = list(map(int, sys.stdin.readline().split()))
		loc.append((a,b))
	targets = []
	for i in range(m):
		a,b = list(map(int, sys.stdin.readline().split()))
		targets.append((a,b))
	count = 0
	flag = False
	for i in loc:
		length = len(targets)
		for j in range(length-1,-1,-1):
			dist = abs(i[0]-targets[j][0]) + abs(i[1]-targets[j][1])
			if dist <= d:
				count += 1
				del targets[j]
			if count > m/2:
				flag = True
				break
	if flag:    print("YES")
	else:   print("NO")


T = int(input())
for t in range(T):
	N, M, D = list(map(int, input().split()))
	shoots = []
	targets = []
	for i in range(N):
		shoots.append( list(map(int, input().split())))
	for i in range(M):
		targets.append( list(map(int, input().split())))
	ans = 0
	for i in range(N):
		for j in range(M):
			if targets[j]:
				if abs(targets[j][0] - shoots[i][0]) + abs(targets[j][1] - shoots[i][1]) <= D:
					ans += 1
					targets[j] = None
	if ans > M/2:
		print("YES")
	else:
		print("NO")


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
import sys
t=input()
t=int(t)

while(t):
	t=t-1
	targ=[]
	loc=[]
	dist=[]
	numbers=list(map(int, sys.stdin.readline().split(' ')))
	n,m,d=numbers[0],numbers[1],numbers[2]
	for i in range(n):
		x,y=sys.stdin.readline().split(' ')
		x=int(x)
		y=int(y)
		loc=loc+[[x,y]]
	for i in range(m):
		x,y=sys.stdin.readline().split(' ')
		x=int(x)
		y=int(y)
		targ=targ+[[x,y]]
	#print targ
	#print loc
	
	c=0
	ma={}
	for i in range(n):
		for j in range(m):
			m_dist = abs(targ[j][0]-loc[i][0]) + abs(targ[j][1]-loc[i][1])
			if m_dist<=d:
				ma[j]=1
	if ( len(list(ma.keys())) > (m/2) ) :
		print("YES")
	else :
		print("NO")


def md(a,b,c):
	return abs(a[0]-b[0]) + abs(a[1]-b[1]) <= c

T = int(input())
for _ in range(0,T):
	l = list(map(int, input().split()))
	n,m,d = l[0],l[1],l[2]
	
	ns,ms = [],[]
	for _ in range(0,n): ns.append(tuple(map(int, input().split())))
	for _ in range(0,m): ms.append(tuple(map(int, input().split())))
	
	ns = sorted(ns, key=lambda c:c[0])
	ms = sorted(ms, key=lambda c:c[0])
	s = sum(any(md(position,target,d) for position in ns) for target in ms)
	if s>=m/2: print('YES')
	else: print('NO')
		


T = int(input())
for i in range(T):
	(N, M, D) = list(map(int, input().split(' ')))
	positions = [list(map(int, input().split(' '))) for j in range(N)]
	ctr = 0
	for k in range(M):
		inp = input()
		if ctr <= M/2:
			target = list(map(int, inp.split(' ')))
			hit = False
			for pos in positions:
				if abs(pos[0]-target[0]) + abs(pos[1]-target[1]) <= D:
					hit = True
					break
			if hit:
				ctr += 1
	print("YES" if ctr > M/2 else "NO")


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
import math
 
for _ in range(eval(input())):
	n, m, d = list(map(int, input().split()))
	shooters = []
	targets  = []
	region   = [0] * m
	
	for i in range(n):
		a, b = list(map(int,input().split()))
		shooters.append((a, b))
	for i in range(m):
		a, b = list(map(int, input().split()))
		targets.append((a, b))
	done = False
	cnt  = 0
	for i in range(n):
		j = 0
		while j < m:
			if region[j] == 0 and  (abs(shooters[i][0]-targets[j][0]) + abs(shooters[i][1]-targets[j][1])) <= d:
				cnt += 1
				region[j] = 1
				if cnt > m/2:
					done = True
					break
			j+=1
				
	print("YES" if done == True else "NO")           


import sys
t=input()
t=int(t)
 
while(t):
	t=t-1
	targ=[]
	loc=[]
	dist=[]
	numbers=list(map(int, sys.stdin.readline().split(' ')))
	n,m,d=numbers[0],numbers[1],numbers[2]
	for i in range(n):
		x,y=sys.stdin.readline().split(' ')
		x=int(x)
		y=int(y)
		loc=loc+[[x,y]]
	for i in range(m):
		x,y=sys.stdin.readline().split(' ')
		x=int(x)
		y=int(y)
		targ=targ+[[x,y]]

	c=0
	mapd={}
	for i in range(n):
		for j in range(m):
			m_dist = abs(targ[j][0]-loc[i][0]) + abs(targ[j][1]-loc[i][1])
			if m_dist<=d:
				mapd[j]=1
	if ( len(list(mapd.keys())) > (m/2) ) :
		print("YES")
	else :
		print("NO")


test_cases = eval(input())
while test_cases!=0 :
	user = input()
	inputs =[];
	inputs = user.split()
	N_shooting_loc = int(inputs[0])
	M_targets = int(inputs[1])
	D_distance = int(inputs[2])
	M_count=M_targets
	N=[]
	while N_shooting_loc!=0:
		temp=[]
		N_cordinates=input()
		temp=N_cordinates.split()
		x=int(temp[0])
		y=int(temp[1])
		N.append((x,y))
		N_shooting_loc=N_shooting_loc-1
	M=[]
	while M_targets!=0:
		temp=[]
		M_cordinates=input()
		temp=M_cordinates.split()
		x=int(temp[0])
		y=int(temp[1])
		M.append((x,y))
		M_targets=M_targets-1
	count=0
	for target in M:
		x=target[0]
		y=target[1]
		for loc in N:
			a=loc[0]
			b=loc[1]
			if(abs(x-a)+abs(y-b)<=D_distance):
				count=count+1
				break
	if(count > (M_count/2)):
		print('YES')
	else:
		print('NO')
	test_cases=test_cases-1
	
	


t=int(input())
for k in range(t):
	l = input().split()
	n,m,d=l[0],l[1],l[2]
	n,m,d=int(n),int(m),int(d)
	a,b,h=[],[],[]
	for i in range(n):
		tt=input().split()
		x,y=int(tt[0]),int(tt[1])
		z=(x,y)
		a.append(z)
	for i in range(m):
		tt=input().split()
		x,y=int(tt[0]),int(tt[1])
		z=(x,y)
		b.append(z)
		h.append(0)
	cnt,f=0,0
	for i in range(n):
		for j in range(m):
			av,bv=a[i],b[j]
			x1,y1,x2,y2=av[0],av[1],bv[0],bv[1]
			
			dd=abs(x1-x2)+abs(y1-y2)
			if dd<=d and h[j]==0:
				cnt = cnt + 1
				h[j]=1
				if cnt>=m//2:
					f=1
					break
	if f is 1:
		print('YES')
	else:
		print('NO')




'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
test=int(input())
while (test!=0):
	inp = input()
	arr=inp.split(" ")
	n=int(arr[0])
	m=int(arr[1])
	d=int(arr[2])
	win=(int)(m/2)
	lp1=n
	lp2=m
	tmp=[]
	while lp1!=0:
		#inp = raw_input()
		arr3=list(map(int,input().split()))
		tmp.append(arr3)
		lp1=lp1-1
	while lp2!=0:	
		arr2=[]
		arr2=list(map(int,input().split()))
		lp1=0
		if(win>0):
			while lp1<n:
				dist=abs(arr2[0]-(tmp[lp1])[0])+abs(arr2[1]-(tmp[lp1])[1])
				if(dist<=d):
					win=win-1
					break
				
				lp1=lp1+1
		lp2=lp2-1		
	if(win==0):
		print('YES')
	else:
		print('NO')
	test=test-1


T=int(input())
for _ in range(0,T):
	lists=[int(_) for _ in input().split()]
	N,M,D=lists[0],lists[1],lists[2]
	pos=[]
	del pos[:]
	for _ in range(0,N):
		lists=[int(_) for _ in input().split()]
		x=lists[0]
		y=lists[1]
		pos.append([x,y])
	tar=[]
	del tar[:]
	for _ in range(0,M):
		lists=[int(_) for _ in input().split()]
		x=lists[0]
		y=lists[1]
		tar.append([x,y])
	shots=[0 for _ in range(0,M)]
	for i in pos:
		count=0
		for j in tar:
			if((abs(i[0]-j[0])+abs(i[1]-j[1]))<=D):
				shots[count]=1
			count+=1
	if(shots.count(1)>=int(M/2)):
		print("YES")
	else:
		print("NO")


import sys

for cases in range(int(sys.stdin.readline())):
	n,m,d = list(map(int, sys.stdin.readline().split()))
	loc = []
	for i in range(n):
		a,b = list(map(int, sys.stdin.readline().split()))
		loc.append((a,b))
	targets = []
	for i in range(m):
		a,b = list(map(int, sys.stdin.readline().split()))
		targets.append((a,b))
	count = 0
	flag = False
	for i in targets:
		for j in loc:
			dist = abs(i[0]-j[0]) + abs(i[1]-j[1])
			if dist <= d:
				count += 1
				break
		if count > m/2:
			flag = True
			break
	if flag:    print("YES")
	else:   print("NO")


t=eval(input());
while(t):
	t=t-1
	#count=0
	tar=[]
	loc=[]
	x=input().split()
	n=int(x[0])
	m=int(x[1])
	d=int(x[2])
	for i in range(n):
            x=input().split()
            xc=int(x[0])
            yc=int(x[1])
            loc.append([xc,yc])
        for i in range(m):
            x=input().split()
            xc=int(x[0])
            yc=int(x[1])
            tar.append([xc,yc])
        count=m
        #out='YES'
        for i in range(m):
            for j in range(n):
                if((abs(tar[i][0]-loc[j][0])+abs(tar[i][1]-loc[j][1]))<=d):
                    break
                if(j==n-1):
                    count=count-1
        if(count>int(m/2)):
            print("YES")
        else:
            print("NO")

        #print out
            
	


def dis(x1,y1,x2,y2):
	return abs(x1-x2) + abs(y1-y2)

t=int(input())
while(t>0) :
	t=t-1
	b=input().split()
	n,m,d=[int(x) for x in b]
	navi_x=[]
	navi_y=[]
	#print "n = " + str(n)
	for i in range(n):
	#	print i
		input=input().split()
		navi_x.append(int(input[0]))
		navi_y.append(int(input[1]))
		
	target_x=[]
	target_y=[]
	target_hit=[]
	#print "m = " + str(m)
	for i in range(m):
		input=input().split()
		target_x.append(int(input[0]))
		target_y.append(int(input[1]))
		target_hit.append(0)
	
	target_count=0
	for i in range(n):
		for j in range(m):
			if target_hit[j]==0:
				if dis(navi_x[i],navi_y[i],target_x[j],target_y[j])<=d:
					target_hit[j]=1
					target_count=target_count+1
	
	if target_count>int(m/2):
		print("YES")
	else:
		print("NO")
		
		
		


t=eval(input())
while(t):
	t=t-1
	s=input()
	inp=s.split()
	inp=list(map(int,inp))
	n=inp[0]
	m=inp[1]
	d=inp[2]
	shoot,target=[],[]
	flag=[0]*m
	c=0
	for i in range(n):
		s=list(map(int,input().split()))
		'''shoot.append(s[0])
		shoot.append(s[1])'''
		shoot.append(s)

	for i in range(m):
		s=list(map(int,input().split()))
		'''target.append(s[0])
		target.append(s[1])'''
		target.append(s)
	
	for i in range(n):
		for j in range(m):
			dis=abs(shoot[i][0]-target[j][0]) + abs(shoot[i][1]-target[j][1])
			if(dis<=d and flag[j]==0):
				'''print(i)
				print(j)
				print('y')'''
				c=c+1
				flag[j]=1
	if(c>m/2):
		print("YES")
	else:
		print("NO")
			


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
import math

def calculate_distance(x1,y1,x2,y2):
	#dist = math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
	dist = abs(x1-x2) + abs(y1-y2)
	return dist

tc = int(input())
for i in range(0,tc):
	n,m,d = inp_arr = list(map(int, input().split(' ')))
	min_shoot = m/2
	targets_shoot  = 0    #targets to be shooted
	is_eligible = False
	locations = []
	targets = []
	for j in range(0,n):
			locations.append(list(map(int, input().split(' '))))
	for j in range(0,m):
			targets.append(list(map(int, input().split(' '))))
	#print targets
	#print locations
	#print targets[0][0]

	for j in range(0,m):    #targets loop
		for k in range(0,n):	#location loop
			if calculate_distance(targets[j][0],targets[j][1],locations[k][0],locations[k][1])  <= d:
				targets_shoot	+= 1
				break
		if targets_shoot >= min_shoot:
			is_eligible = True
			break

	if is_eligible:
		print("YES")
	else:
		print("NO")
	
	
	


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''

def getMD(X1, Y1, X2, Y2):
	dX = X2 - X1
	dY = Y2 - Y1
	
	if(dX < 0):
		dX = -dX
	if(dY < 0):
		dY = -dY
	
	return dX + dY
		
T = int(input());

for i in range(1, T + 1):
	line = input()
	NMD = line.split(" ")
	N = int(NMD[0])
	M = int(NMD[1])
	D = int(NMD[2])
	
	LOCATIONS = []
	TARGETS = []
	
	for j in range(1, N + 1):
		line = input()
		X, Y = line.split(" ")
		X = int(X)
		Y = int(Y)
		LOCATIONS.append((X,Y))
	for j in range(1, M + 1):
		line = input()
		X, Y = line.split(" ")
		X = int(X)
		Y = int(Y)
		TARGETS.append((X,Y))
	
	count = 0
	halfT = int(len(TARGETS)/2)
	
	for X1,Y1 in LOCATIONS:
		for X2,Y2 in TARGETS[:]:
			if getMD(X1, Y1, X2, Y2) <= D:				
				count = count + 1;
				TARGETS.remove((X2,Y2))			
		
	if count >= halfT:
		print("YES")
	else:
		print("NO")


def man(p1,p2):
	return  abss(p1[0] - p2[0]) + abss(p1[1] - p2[1]);

def abss(a):
	if a>0 :
		return a;
	return -a;
#print 3/2;

t = int(input());

for aa in range(t):
	
	arr = list(map(int , input().split(" ")));

	n = arr[0]
	m = arr[1]
	d = arr[2]
	places = [];
	target = [];
	done = [0] * m;

   # print done;

	for x in range(n) :
		arr = list(map(int , input().split(" ")));
		places.append([arr[0] , arr[1] ]);
		
	for x in range(m) :
		arr = list(map(int , input().split(" ")));
		target.append([arr[0] , arr[1] ]);

	for x in range(m):
		for y in range(n):
			if( man( target[x] , places[y] ) <= d ):
				done[x] = 1;
			
	ans= 0;
	for x in range(m) :
		if(done[x] == 0 ):
			ans = ans +1;

	ans = m -ans;

	if(ans > m/2):
		print("YES")
	else:
		print("NO")
	

	

		



		


from math import sqrt
t = int(input())
while t>0:
	l = list(map(int,input().split(' ')))
	n = l[0]
	m = l[1]
	d = l[2]
	k = list()
	z = list()
	for i in range(0,n):
		f = list(map(int,input().split(' ')))
		k.append(f)
	for i in range(0,m):
		f = list(map(int,input().split(' ')))
		z.append(f)
	c = 0
	i = 0
	fal = [False]*(n+1)
	while i < len(k):
		j = 0
		f = list()
		while j < len(z):
			if fal[j]==False and abs(k[i][0]-z[j][0])+abs(k[i][1]-z[j][1]) <= d:
				c = c+1
				fal[j] = True
			j = j+1
		i = i+1
	t = t-1
	if c > n//2:
		print("YES")
	else:
		print("NO")


t=eval(input());
while(t):
	t=t-1	
	tar=[]
	loc=[]
	x=input().split()
	n=int(x[0])
	m=int(x[1])
	d=int(x[2])
	for i in range(n):
            x=input().split()
            xc=int(x[0])
            yc=int(x[1])
            loc.append([xc,yc])
        for i in range(m):
            x=input().split()
            xc=int(x[0])
            yc=int(x[1])
            tar.append([xc,yc])
        count=m        
        for i in range(m):
            for j in range(n):
                if((abs(tar[i][0]-loc[j][0])+abs(tar[i][1]-loc[j][1]))<=d):
                    break
                if(j==n-1):
                    count=count-1
        if(count>int(m/2)):
            print("YES")
        else:
            print("NO")

        
            
	


def compute_game_result(targets, positions, max_distance):
	half_mark = len(targets)/2
	ctr = 0
	for target in targets:
		hit = False
		for pos in positions:
			if abs(pos[0]-target[0]) + abs(pos[1]-target[1]) <= max_distance:
				hit = True
				break
		if hit:
			ctr += 1
			if ctr > half_mark:
				return "YES"
	return "NO"

T = int(input())
for i in range(T):
	(N, M, D) = list(map(int, input().split(' ')))
	positions = [list(map(int, input().split(' '))) for j in range(N)]
	targets = [list(map(int, input().split(' '))) for j in range(M)]
	print(compute_game_result(targets, positions, D))


tc=int(input())
while tc:
	tc=tc-1
	N,M,D=list(map(int,input().split(" ")))
	#N1=[[0 for x in xrange(N)] for x in xrange(N)]
	N1=[]
	M1=[]
	for i in range(N):
		N1.append(list(map(int,input().split(" "))))
	for i in range(M):
		M1.append(list(map(int,input().split(" "))))
	#print N1,M1
	c=M/2
	C=0
	for i in M1:
		#if C>c:
		 #   print 'YES'
		  #  break
		for j in N1:
			#if abs(i[0]-j[0]+i[1]-j[1])<=D:
			#if abs(i[0])+abs(j[0])+abs(i[1])+abs(j[1])<=D:
			if abs(i[0]-j[0])+abs(i[1]-j[1])<=D:
				C+=1
				break
			#    if C>c:
					#print 'YES'
		   #         break
	if C>c:
		print('YES')
	else:
		print('NO')


import sys
for _ in range(eval(input())):
	n,m,d=list(map(int,sys.stdin.readline().split()))
	arrx=[0]*n
	arry=[0]*n
	visted=[]
	for i in range(n):
		s=input()
		ss=s.split()
		x= int(ss[0])
		y= int(ss[1])
		arrx[i]=x
		arry[i]=y
	ans=0;idx=0	
	for i in range(m):
		x1,y1=list(map(int,sys.stdin.readline().split()))
		idx=0
		for idx in range(n):
			res=abs(x1-arrx[idx])+abs(y1-arry[idx])
			if(res<=d):
				ans+=1
				break
	if(ans>m/2):
		print('YES')
	else:
		print('NO')
				


t=eval(input())
while(t>0):
	line=input()
	line=line.split();
	n=int(line[0]);
	m=int(line[1]);
	d=int(line[2]);
	lp=[]; #List of points
	for i in range(n):
		line=input()
		line=line.split();
		x=int(line[0]);
		y=int(line[1]);
		temp=[x,y]
		lp.append(temp);
	#~ print lp
	ld=[];#list of target points
	for i in range(m):
		line=input()
		line=line.split();
		x=int(line[0]);
		y=int(line[1]);
		temp=[x,y]
		ld.append(temp);
	#~ print ld
	target=m/2 #Target to impress friends
	#~ print target
	mylist=[];
	for i in range(m):
		mylist.append(0);
	for i in range(n):
		x1=lp[i][0]
		y1=lp[i][1]
		for j in range(m):
			x2=ld[j][0]
			y2=ld[j][1]
			temp=abs(x2-x1) +abs(y2-y1)
			if(temp<=d):
				mylist[j]=1
	flag=1
	mc=0;
	for i in range(m):
		if(mylist[i]==1):
			mc+=1;
	if(mc>=target):
		print("YES")
	else:
		print("NO")	
	t-=1;


import sys
t=input()
t=int(t)
while(t):
	t=t-1
	loc=[]
	tt=[]
	dis=[]
	num=list(map(int, sys.stdin.readline().split(' ')))
	n0,n1,n2=num[0],num[1],num[2]
	for i in range(n0):
		x,y=sys.stdin.readline().split(' ')
		x=int(x)
		y=int(y)
		loc=loc+[[x,y]]
	for j in range(n1):
		x,y=sys.stdin.readline().split(' ')
		x=int(x)
		y=int(y)
		tt=tt+[[x,y]]
	
	c=0
	ma={}
	for i in range(n0):
		for j in range(n1):
			n1_dis = abs(tt[j][0]-loc[i][0]) + abs(tt[j][1]-loc[i][1])
			if n1_dis<=n2:
				ma[j]=1
	if ( len(list(ma.keys())) > (n1/2) ) :
		print("YES")
	else :
		print("NO")


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
t=input()
t=int(t)
while (t>0):
	var=input()
	mylist=var.split(" ")
	n=int(mylist[0])
	m=int(mylist[1])
	d=int(mylist[2])
	count=0
	ans=0
	arr=Matrix = [[0 for x in range(2)] for x in range(1002)] 
	while (count<n):
		var=input()
		mylist2=var.split(" ")
		arr[count][0]=int(mylist2[0])
		arr[count][1]=int(mylist2[1])
		count+=1
	count=0
	while (count<m):
		var=input()
		mylist3=var.split(" ")
		point=[0,0]
		point[0]=int(mylist3[0])
		point[1]=int(mylist3[1])
		temp=0
		count+=1
		while (temp<n):
			if ((abs(arr[temp][0]-point[0])+abs(arr[temp][1]-point[1]))<=d):
				ans+=1
				break
			temp+=1
	t-=1
	if (ans>m/2):
		print("YES")
	else:
		print("NO")