AtCoder Beginner Contest 057 - Checkpoints

There are N students and M checkpoints on the xy-plane.

The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j).

When the teacher gives a signal, each student has to go to the nearest checkpoint measured in Manhattan distance. 

The Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is |x_1-x_2|+|y_1-y_2|.

Here, |x| denotes the absolute value of x.

If there are multiple nearest checkpoints for a student, he/she will select the checkpoint with the smallest index.

Which checkpoint will each student go to?

-----Constraints-----
 - 1 \leq N,M \leq 50
 - -10^8 \leq a_i,b_i,c_j,d_j \leq 10^8
 - All input values are integers.

-----Input-----
The input is given from Standard Input in the following format:
N M
a_1 b_1
:  
a_N b_N
c_1 d_1
:  
c_M d_M

-----Output-----
Print N lines.

The i-th line (1 \leq i \leq N) should contain the index of the checkpoint for the i-th student to go.

-----Sample Input-----
2 2
2 0
0 0
-1 0
1 0

-----Sample Output-----
2
1

The Manhattan distance between the first student and each checkpoint is:
 - For checkpoint 1: |2-(-1)|+|0-0|=3
 - For checkpoint 2: |2-1|+|0-0|=1
The nearest checkpoint is checkpoint 2. Thus, the first line in the output should contain 2.
The Manhattan distance between the second student and each checkpoint is:
 - For checkpoint 1: |0-(-1)|+|0-0|=1
 - For checkpoint 2: |0-1|+|0-0|=1
When there are multiple nearest checkpoints, the student will go to the checkpoint with the smallest index. Thus, the second line in the output should contain 1.

Difficulty: EASY

Starter code:

Solutions:
(n, m) = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]
res = []
for (a, b) in ab:
	tmp = []
	for (c, d) in cd:
		tmp.append(abs(a - c) + abs(b - d))
	res.append(tmp.index(min(tmp)) + 1)
for r in res:
	print(r)


(n, m) = map(int, input().split())
(ab, cd) = ([list(map(int, input().split())) for _ in range(n)], [list(map(int, input().split())) for _ in range(m)])
for i in ab:
	r = []
	for j in cd:
		r.append(abs(i[0] - j[0]) + abs(i[1] - j[1]))
	print(r.index(min(r)) + 1)


(n, m) = map(int, input().split())
ans = []
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]
for (a, b) in ab:
	anss = 0
	mm = 10 ** 20
	for i in range(m):
		mmm = abs(a - cd[i][0]) + abs(b - cd[i][1])
		if mm > mmm:
			anss = i + 1
			mm = mmm
	ans.append(anss)
print(*ans)


(n, m) = map(int, input().split())
abes = [list(map(int, input().split())) for _ in range(n)]
cdes = [list(map(int, input().split())) for _ in range(m)]
for (a, b) in abes:
	mi = sorted(cdes, key=lambda x: abs(x[0] - a) + abs(x[1] - b))
	print(cdes.index(mi[0]) + 1)


(n, m) = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(n)]
c = [list(map(int, input().split())) for _ in range(m)]
ans = []
INF = 10 ** 9 + 7
for x in s:
	d = INF
	ind = INF
	for (i, y) in enumerate(c):
		exd = d
		d = min(d, abs(x[0] - y[0]) + abs(x[1] - y[1]))
		if d != exd:
			ind = i
	ans.append(ind + 1)
for x in ans:
	print(x)


(N, M) = [int(i) for i in input().split()]
student = [[int(i) for i in input().split()] for j in range(N)]
check = [[int(i) for i in input().split()] + [j + 1] for j in range(M)]
print('\n'.join(map(str, [min(check, key=lambda x: abs(i[0] - x[0]) + abs(i[1] - x[1]))[-1] for i in student])))


(n, m) = map(int, input().split())
P = [list(map(int, input().split())) for _ in range(n)]
C = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
	d = 10 ** 18
	t = 0
	for j in range(m):
		dist = abs(P[i][0] - C[j][0]) + abs(P[i][1] - C[j][1])
		if d > dist:
			t = j
			d = dist
	print(t + 1)


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
	shortest = 4 * 10 ** 8 + 5
	for j in range(m):
		distance = abs(a[i][0] - b[j][0]) + abs(a[i][1] - b[j][1])
		if distance < shortest:
			idx = j
			shortest = distance
	print(idx + 1)


(n, m) = map(int, input().split())
a = []
b = []
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(m):
	b.append(list(map(int, input().split())))
for i in range(n):
	now = 10 ** 9 + 90000
	idx = 0
	for j in range(m):
		d = abs(a[i][0] - b[j][0]) + abs(a[i][1] - b[j][1])
		if d < now:
			now = d
			idx = j + 1
	print(idx)


(n, m) = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(n)]
CD = [list(map(int, input().split())) for i in range(m)]
for (a, b) in AB:
	dist = [[abs(a - c) + abs(b - d)] for (c, d) in CD]
	print(dist.index(min(dist)) + 1)


(n, m) = map(int, input().split())
a = []
c = []
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(m):
	c.append(list(map(int, input().split())))
for k in range(n):
	tmp = []
	for j in range(m):
		tmp.append(abs(a[k][0] - c[j][0]) + abs(a[k][1] - c[j][1]))
	print(tmp.index(min(tmp)) + 1)


(n, m) = map(int, input().split())
std = []
for i in range(n):
	std.append(list(map(int, input().split())))
chk = []
for j in range(m):
	chk.append(list(map(int, input().split())))
for i in range(n):
	can = []
	for j in range(m):
		can.append([abs(std[i][0] - chk[j][0]) + abs(std[i][1] - chk[j][1]), j + 1])
	print(min(can)[1])


(N, M) = [int(c) for c in input().split()]
ab = [list(map(int, input().split())) for c in range(N)]
cd = [list(map(int, input().split())) for c in range(M)]
for i in range(N):
	mi = 2 * 10 ** 9
	for j in range(M):
		tmp = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
		if mi > tmp:
			mi = tmp
			ans = j + 1
	print(ans)


(N, M) = map(int, input().split())
S = [list(map(int, input().split())) for n in range(N)]
C = [list(map(int, input().split())) for m in range(M)]
for s in S:
	l = []
	for c in C:
		l.append(abs(s[0] - c[0]) + abs(s[1] - c[1]))
	print(l.index(min(l)) + 1)


(N, M) = map(int, input().split())
students = [list(map(int, input().split())) for i in range(N)]
checkpoints = [list(map(int, input().split())) for i in range(M)]
for i in range(N):
	A = [abs(students[i][0] - checkpoints[j][0]) + abs(students[i][1] - checkpoints[j][1]) for j in range(M)]
	print(A.index(min(A)) + 1)


(n, m) = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(n)]
q = [list(map(int, input().split())) for _ in range(m)]
for (a, b) in p:
	l = []
	for (c, d) in q:
		l.append(abs(a - c) + abs(b - d))
	print(l.index(min(l)) + 1)


(n, m) = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]
for per in ab:
	diff = []
	for check in cd:
		diff.append(abs(per[0] - check[0]) + abs(per[1] - check[1]))
	print(diff.index(min(diff)) + 1)


(n, m) = map(int, input().split())
AB = [tuple(map(int, input().split())) for i in range(n)]
CD = [tuple(map(int, input().split())) for i in range(m)]
for (a, b) in AB:
	minv = p = float('inf')
	for (i, (c, d)) in enumerate(CD):
		dist = abs(a - c) + abs(b - d)
		if dist < minv:
			minv = dist
			p = i + 1
	print(p)


(n, m) = map(int, input().split())
(a, b) = ([0] * n, [0] * n)
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
(c, d) = ([0] * m, [0] * m)
for i in range(m):
	(c[i], d[i]) = map(int, input().split())
for i in range(n):
	res = min(range(m), key=lambda j: abs(a[i] - c[j]) + abs(b[i] - d[j]))
	print(res + 1)


(n, m) = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
cd = [list(map(int, input().split())) for j in range(m)]
for x in range(n):
	e = []
	for y in range(m):
		e.append(abs(ab[x][0] - cd[y][0]) + abs(ab[x][1] - cd[y][1]))
	print(e.index(min(e)) + 1)


(N, M) = map(int, input().split())
p_s = [list(map(int, input().split())) for _ in range(N)]
p_f = [list(map(int, input().split())) for _ in range(M)]
length = []
for s in p_s:
	for f in p_f:
		length.append(abs(s[0] - f[0]) + abs(s[1] - f[1]))
	print(length.index(min(length)) + 1)
	length = []


(n, m) = map(int, input().split())
s = [list(map(int, input().split())) for i in range(n)]
c = [list(map(int, input().split())) for i in range(m)]
for a in s:
	l = [abs(a[0] - b[0]) + abs(a[1] - b[1]) for b in c]
	print(l.index(min(l)) + 1)


(N, M) = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(N)]
cd = [tuple(map(int, input().split())) for _ in range(M)]
for (a, b) in ab:
	n = 10 ** 9
	m = 0
	for (i, (c, d)) in enumerate(cd):
		x = abs(a - c) + abs(b - d)
		if x < n:
			n = x
			m = i + 1
	print(m)


(a, b) = map(int, input().split())
p = [list(map(int, input().split())) for i in range(a)]
q = [list(map(int, input().split())) for i in range(b)]
for i in range(a):
	r = []
	for j in range(b):
		r.append([abs(p[i][0] - q[j][0]) + abs(p[i][1] - q[j][1]), j + 1])
	else:
		r.sort()
		print(r[0][1])


(n, m) = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]
y = [list(map(int, input().split())) for i in range(m)]
for (a, b) in x:
	l = [abs(a - c) + abs(b - d) for (c, d) in y]
	print(l.index(min(l)) + 1)


(N, M) = map(int, input().split())
students = [list(map(int, input().split())) for _ in range(N)]
c_points = [list(map(int, input().split())) for _ in range(M)]
for (a, b) in students:
	m_dis = [abs(a - c) + abs(b - d) for (c, d) in c_points]
	print(m_dis.index(min(m_dis)) + 1)


(n, m) = list(map(int, input().split()))
al = list((list(map(int, input().split())) for _ in range(n)))
cl = list((list(map(int, input().split())) for _ in range(m)))
for a in al:
	ans = 1001001001
	no = 0
	for i in range(m):
		dis = abs(a[0] - cl[i][0]) + abs(a[1] - cl[i][1])
		if dis < ans:
			ans = dis
			no = i
	print(no + 1)


(n, m) = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(n)]
C = [list(map(int, input().split())) for _ in range(m)]
for i in A:
	D = [abs(i[0] - j[0]) + abs(i[1] - j[1]) for j in C]
	print(D.index(min(D)) + 1)


(n, m) = map(int, input().split())
student = []
man = []
for i in range(n):
	(x, y) = map(int, input().split())
	student.append([x, y])
for i in range(m):
	(x, y) = map(int, input().split())
	man.append([x, y])
for i in student:
	ans = []
	for j in man:
		ans.append(abs(i[0] - j[0]) + abs(i[1] - j[1]))
	print(ans.index(min(ans)) + 1)


(N, M) = list(map(int, input().split()))
P = []
for _ in range(N):
	(a, b) = list(map(int, input().split()))
	P.append([a, b])
C = []
for _ in range(M):
	(c, d) = list(map(int, input().split()))
	C.append([c, d])
for i in range(N):
	ans = float('inf')
	num = float('inf')
	for j in range(M):
		if num > abs(P[i][0] - C[j][0]) + abs(P[i][1] - C[j][1]):
			num = abs(P[i][0] - C[j][0]) + abs(P[i][1] - C[j][1])
			ans = j + 1
	print(ans)


(N, M) = map(int, input().split())
n = []
m = []
for i in range(N):
	n.append(list(map(int, input().split())))
for l in range(M):
	m.append(list(map(int, input().split())))
L = []
for i in n:
	M = []
	for l in m:
		A = abs(i[0] - l[0]) + abs(i[1] - l[1])
		M.append(A)
	print(M.index(min(M)) + 1)


(n, m) = map(int, input().split())
lx = []
ly = []
for i in range(n + m):
	(x, y) = map(int, input().split())
	lx.append(x)
	ly.append(y)
for i in range(n):
	r = []
	for j in range(n, m + n):
		r.append(abs(lx[i] - lx[j]) + abs(ly[i] - ly[j]))
	print(r.index(min(r)) + 1)


def main():
	(n, m) = map(int, input().split())
	a_b = [input().split() for i in range(n)]
	c_d = [input().split() for i in range(m)]
	for i in range(n):
		temp = []
		for j in range(m):
			temp.append(abs(int(a_b[i][0]) - int(c_d[j][0])) + abs(int(a_b[i][1]) - int(c_d[j][1])))
		else:
			print(temp.index(min(temp)) + 1)

def __starting_point():
	main()
__starting_point()


(n, m) = map(int, input().split())
ab = [list(map(int, input().split())) for p in range(n)]
cd = [list(map(int, input().split())) for q in range(m)]
for i in range(n):
	x = 10 ** 10
	ans = 0
	for j in range(m):
		if abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]) < x:
			ans = j + 1
			x = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
	print(ans)


def dis(a, b, c, d):
	num = abs(a - c) + abs(b - d)
	return num
(n, m) = list(map(int, input().split()))
a = [0] * n
b = [0] * n
c = [0] * m
d = [0] * m
for i in range(n):
	(a[i], b[i]) = list(map(int, input().split()))
for i in range(m):
	(c[i], d[i]) = list(map(int, input().split()))
for i in range(n):
	ans = []
	for j in range(m):
		ans.append(dis(a[i], b[i], c[j], d[j]))
	print(ans.index(min(ans)) + 1)


(n, m) = map(int, input().split())
ab = [[int(x) for x in input().split()] for _ in range(n)]
cd = [[int(x) for x in input().split()] for _ in range(m)]
for (a, b) in ab:
	ans = list()
	for (c, d) in cd:
		ans.append(abs(a - c) + abs(b - d))
	print(ans.index(min(ans)) + 1)


(N, M) = map(int, input().split())
A_B = [list(map(int, input().split())) for _ in range(N)]
C_D = [list(map(int, input().split())) for _ in range(M)]
for (a, b) in A_B:
	temp_distance = 10 ** 10
	temp_checkpoint = -1
	checkpoint_count = 1
	for (c, d) in C_D:
		manhattan_distance = abs(a - c) + abs(b - d)
		if temp_distance > manhattan_distance:
			temp_distance = manhattan_distance
			temp_checkpoint = checkpoint_count
		checkpoint_count += 1
	print(temp_checkpoint)


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for A in range(n)]
c = [list(map(int, input().split())) for C in range(m)]
for i in range(n):
	ans = []
	for j in range(m):
		ans.append(abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1]))
	print(ans.index(min(ans)) + 1)


(N, M) = map(int, input().split())
X = []
for i in range(N):
	(a, b) = map(int, input().split())
	X.append((a, b))
C = []
for i in range(M):
	(c, d) = map(int, input().split())
	C.append((c, d))
ans = [0 for _ in range(N)]
INF = float('inf')
for i in range(N):
	MIN = INF
	check = -1
	for y in range(M):
		temp = abs(X[i][0] - C[y][0]) + abs(X[i][1] - C[y][1])
		if temp < MIN:
			MIN = temp
			check = y + 1
	ans[i] = check
print(*ans, sep='\n')


(n, m) = map(int, input().split())
nl = [list(map(int, input().split())) for i in range(n)]
ml = [list(map(int, input().split())) for i in range(m)]
for j in range(n):
	best = 100000000000
	for i in range(m):
		d = abs(ml[i][0] - nl[j][0]) + abs(ml[i][1] - nl[j][1])
		if best > d:
			best = d
			ans = i + 1
	print(ans)


(n, m) = map(int, input().split())
l_n = list((list(map(int, input().split())) for i in range(n)))
l_m = list((list(map(int, input().split())) for i in range(m)))
for i in range(n):
	q = 10 ** 9
	for t in range(m):
		(a, b) = l_n[i]
		(c, d) = l_m[t]
		v = abs(a - c) + abs(b - d)
		if v < q:
			q = v
			z = t
	print(z + 1)


(n, m) = list(map(int, input().split()))
pos = []
check = []
for i in range(n):
	(a, b) = list(map(int, input().split()))
	pos.append([a, b])
for i in range(m):
	(c, d) = list(map(int, input().split()))
	check.append([c, d])
for i in range(n):
	ans = 0
	k = 10 ** 9
	for j in range(m):
		t = abs(pos[i][0] - check[j][0]) + abs(pos[i][1] - check[j][1])
		if k > t:
			k = t
			ans = j + 1
	print(ans)


from sys import stdin
nii = lambda : map(int, stdin.readline().split())
lnii = lambda : list(map(int, stdin.readline().split()))
(n, m) = nii()
ab = [lnii() for i in range(n)]
cd = [lnii() for i in range(m)]
ans = []
for (a, b) in ab:
	min_dist = 10 ** 10
	for i in range(m):
		(c, d) = cd[i]
		if abs(a - c) + abs(b - d) < min_dist:
			t_ans = i
			min_dist = abs(a - c) + abs(b - d)
	ans.append(t_ans + 1)
for i in ans:
	print(i)


from sys import stdin, stdout

def manhattan_distance(p1, p2):
	return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])

def solve():
	(n, m) = list(map(int, input().split()))
	students = []
	check_points = []
	for _ in range(n):
		(a, b) = list(map(int, input().split()))
		students.append((a, b))
	for _ in range(m):
		(c, d) = list(map(int, input().split()))
		check_points.append((c, d))
	for s in students:
		cur_closest_dist = int(400000000.0)
		cur_closest_point = -1
		for i in range(m):
			c = check_points[i]
			if manhattan_distance(s, c) < cur_closest_dist:
				cur_closest_dist = manhattan_distance(s, c)
				cur_closest_point = i
		print(cur_closest_point + 1)

def main():
	solve()

def __starting_point():
	main()
__starting_point()


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split())) for i in range(m)]
for i in range(n):
	c = float('inf')
	e = 0
	g = 0
	for j in range(m):
		d = abs(a[i][0] - b[j][0]) + abs(a[i][1] - b[j][1])
		g += 1
		if d < c:
			(c, e) = (d, g)
	print(e)


(N, M) = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
cd = [list(map(int, input().split())) for _ in range(M)]
for i in range(N):
	d = []
	for j in range(M):
		d.append(abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]))
	print(d.index(min(d)) + 1)


(N, M) = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(N)]
y = [list(map(int, input().split())) for _ in range(M)]
for (a, b) in x:
	z = [abs(a - c) + abs(b - d) for (c, d) in y]
	print(z.index(min(z)) + 1)


(n, m) = map(int, input().split())
nab = [list(map(int, input().split())) for x in range(n)]
mab = [list(map(int, input().split())) + [x + 1] for x in range(m)]
print('\n'.join(map(str, [min(mab, key=lambda x: abs(x[0] - a) + abs(x[1] - b))[-1] for (a, b) in nab])))


(N, M) = map(int, input().split())
ns = [list(map(int, input().split())) for _ in range(N)]
ms = [list(map(int, input().split())) for _ in range(M)]
for n in ns:
	dmin = 2002002002
	num = -1
	for (i, m) in enumerate(ms):
		d = abs(n[0] - m[0]) + abs(n[1] - m[1])
		if d < dmin:
			dmin = d
			num = i
	print(num + 1)


(n, m) = map(int, input().split())
ST = [[int(x) for x in input().split()] for y in range(n)]
CH = [[int(x) for x in input().split()] for y in range(m)]
for (a, b) in ST:
	manhat = [abs(a - c) + abs(b - d) for (c, d) in CH]
	print(manhat.index(min(manhat)) + 1)


(N, M) = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(N)]
cd = [tuple(map(int, input().split())) for _ in range(M)]
for (a, b) in ab:
	tmp = []
	for (c, d) in cd:
		tmp.append(abs(a - c) + abs(b - d))
	print(tmp.index(min(tmp)) + 1)


(N, M) = list(map(int, input().split()))
s = []
for i in range(N):
	s.append(list(map(int, input().split())))
c = []
for j in range(M):
	c.append(list(map(int, input().split())))
for t1 in s:
	l = list(map(lambda x: abs(t1[0] - x[0]) + abs(t1[1] - x[1]), c))
	print(l.index(min(l)) + 1)


(N, M) = map(int, input().split())
AB = [tuple(map(int, input().split())) for i in range(N)]
CD = [tuple(map(int, input().split())) for i in range(M)]
for (a, b) in AB:
	x = z = 10 ** 9
	for (i, (c, d)) in enumerate(CD):
		dist = abs(a - c) + abs(b - d)
		if dist < x:
			x = dist
			z = i + 1
	print(z)


(n, m) = map(int, input().split(' '))
a = [list(map(int, input().split(' '))) for i in range(n)]
b = [list(map(int, input().split(' '))) for i in range(m)]
for (ax, ay) in a:
	c = []
	for (bx, by) in b:
		c.append(abs(bx - ax) + abs(by - ay))
	print(c.index(min(c)) + 1)


import sys
input = sys.stdin.readline
(N, M) = map(int, input().split())
s = []
for _ in range(N):
	(a, b) = map(int, input().split())
	s.append((a, b))
g = []
for _ in range(M):
	(c, d) = map(int, input().split())
	g.append((c, d))
ans = []
for i in range(N):
	(a, b) = s[i]
	i_ans = -1
	tmp = float('inf')
	for j in range(M):
		(c, d) = g[j]
		dist = abs(c - a) + abs(d - b)
		if dist < tmp:
			i_ans = j
			tmp = dist
	ans.append(i_ans)
for a in ans:
	print(a + 1)


(n, m) = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
cd = [list(map(int, input().split())) for j in range(m)]
for i in range(n):
	l = []
	for j in range(m):
		dist = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
		l.append(dist)
	goal = l.index(min(l)) + 1
	print(goal)


(n, m) = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
cd = [list(map(int, input().split())) for i in range(m)]
ans = [-1] * n
i = 0
for (a, b) in ab:
	t = 10 ** 12
	j = 0
	for (c, d) in cd:
		if abs(a - c) + abs(b - d) < t:
			t = abs(a - c) + abs(b - d)
			ans[i] = j + 1
		j += 1
	i += 1
print(*ans, sep='\n')


(n, m) = map(int, input().split())
a = [0] * n
b = [0] * n
c = [0] * m
d = [0] * m
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
for j in range(m):
	(c[j], d[j]) = map(int, input().split())
ans = []
for i in range(n):
	judge = 10 ** 9
	num = 0
	for j in range(m):
		if judge > abs(a[i] - c[j]) + abs(b[i] - d[j]):
			judge = abs(a[i] - c[j]) + abs(b[i] - d[j])
			num = j + 1
	ans.append(num)
for i in ans:
	print(i)


(n, m) = map(int, input().split())
ab = [list(map(int, input().split())) for x in [0] * n]
cd = [list(map(int, input().split())) for x in [0] * m]
for (a, b) in ab:
	l = [abs(a - c) + abs(b - d) for (c, d) in cd]
	print(l.index(min(l)) + 1)


(n, m) = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(n)]
C = [list(map(int, input().split())) for _ in range(m)]
for s in S:
	(x, ans) = (10 ** 9, 0)
	for (i, c) in enumerate(C):
		y = abs(s[0] - c[0]) + abs(s[1] - c[1])
		if y < x:
			(x, ans) = (y, i + 1)
	print(ans)


lst = input().split()
N = int(lst[0])
M = int(lst[1])
students = []
checkpoints = []
for i in range(N):
	students.append(input().split())
for i in range(M):
	checkpoints.append(input().split())

def distance(P, Q):
	return abs(int(P[0]) - int(Q[0])) + abs(int(P[1]) - int(Q[1]))
for s in students:
	l1 = [10 ** 10]
	l2 = [0]
	for i in range(M):
		if distance(s, checkpoints[i]) < l1[-1]:
			l1.append(distance(s, checkpoints[i]))
			l2.append(i + 1)
	print(l2[-1])


(N, M) = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(N)]
cd = [list(map(int, input().split())) for i in range(M)]
for (a, b) in ab:
	tmp = []
	for (c, d) in cd:
		tmp.append(abs(a - c) + abs(b - d))
	n = min(tmp)
	print(tmp.index(n) + 1)


(n, m) = map(int, input().split())
stu = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(m)]
for (x, y) in stu:
	k = []
	for (c, d) in p:
		k.append(abs(x - c) + abs(y - d))
	print(k.index(min(k)) + 1)


(N, M) = list(map(int, input().split()))
(s, c) = ([], [])
for i in range(N):
	s.append(list(map(int, input().split())))
for i in range(M):
	c.append(list(map(int, input().split())))
for si in s:
	l = [abs(si[0] - c[i][0]) + abs(si[1] - c[i][1]) for i in range(M)]
	print(l.index(min(l)) + 1)


(N, M) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(N)]
b = [list(map(int, input().split())) for i in range(M)]
for i in range(N):
	l = []
	for j in range(M):
		l.append(abs(a[i][0] - b[j][0]) + abs(a[i][1] - b[j][1]))
	print(l.index(min(l)) + 1)


(n, m) = map(int, input().split())
stu = []
che = []
kyori = []
ans = []
for _ in range(n):
	stu.append(list(map(int, input().split())))
for _ in range(m):
	che.append(list(map(int, input().split())))
for x in range(n):
	for y in range(m):
		kyori.append(abs(stu[x][0] - che[y][0]) + abs(stu[x][1] - che[y][1]))
	z = min(kyori)
	ans.append(kyori.index(z) + 1)
	kyori = []
for i in range(len(ans)):
	print(ans[i])


(n, m) = map(int, input().split())
std = [list(map(int, input().split())) for i in range(n)]
chk = [list(map(int, input().split())) for i in range(m)]
for s in std:
	ans = []
	for i in range(m):
		ans.append([abs(s[0] - chk[i][0]) + abs(s[1] - chk[i][1]), i + 1])
		ans.sort()
	print(ans[0][1])


(N, M) = map(int, input().split())
A = [list(map(int, input().split())) for n in range(N)]
C = [list(map(int, input().split())) for m in range(M)]
for n in range(N):
	ans = []
	for m in range(M):
		ans.append(abs(A[n][0] - C[m][0]) + abs(A[n][1] - C[m][1]))
	print(ans.index(min(ans)) + 1)


(n, m) = map(int, input().split())
ab = [[int(j) for j in input().split()] for i in range(n)]
cd = [[int(j) for j in input().split()] for i in range(m)]
for (a, b) in ab:
	l = [abs(a - c) + abs(b - d) for (c, d) in cd]
	print(l.index(min(l)) + 1)


def distance(coordinate1, coordinate2):
	x1 = coordinate1[0]
	y1 = coordinate1[1]
	x2 = coordinate2[0]
	y2 = coordinate2[1]
	return abs(x1 - x2) + abs(y1 - y2)

def main():
	(n, m) = map(int, input().split())
	ab_lst = [list(map(int, input().split())) for _ in range(n)]
	cd_lst = [list(map(int, input().split())) for _ in range(m)]
	point_lst = []
	for i in range(n):
		distance_lst = []
		for j in range(m):
			coordinate1 = ab_lst[i]
			coordinate2 = cd_lst[j]
			distance_lst.append(distance(coordinate1, coordinate2))
		minimum = min(distance_lst)
		for k in range(m):
			if distance_lst[k] == minimum:
				point_lst.append(k + 1)
				break
	for i in range(n):
		print(point_lst[i])

def __starting_point():
	main()
__starting_point()


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]
for x in a:
	(ans, dist) = (-1, 1000000000)
	for i in range(m):
		d = abs(x[0] - b[i][0]) + abs(x[1] - b[i][1])
		if d < dist:
			(ans, dist) = (i + 1, d)
	print(ans)


(n, m) = map(int, input().split())
now = [tuple(map(int, input().split())) for i in range(n)]
p = [tuple(map(int, input().split())) for i in range(m)]
for a in now:
	ans = 10 ** 10
	for i in range(m):
		if ans > abs(p[i][0] - a[0]) + abs(p[i][1] - a[1]):
			ind = i
			ans = abs(p[i][0] - a[0]) + abs(p[i][1] - a[1])
	print(ind + 1)


import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):

	def assertIO(self, input, output):
		(stdout, stdin) = (sys.stdout, sys.stdin)
		(sys.stdout, sys.stdin) = (StringIO(), StringIO(input))
		resolve()
		sys.stdout.seek(0)
		out = sys.stdout.read()[:-1]
		(sys.stdout, sys.stdin) = (stdout, stdin)
		self.assertEqual(out, output)

	def test_入力例_1(self):
		input = '2 2\n2 0\n0 0\n-1 0\n1 0'
		output = '2\n1'
		self.assertIO(input, output)

	def test_入力例_2(self):
		input = '3 4\n10 10\n-10 -10\n3 3\n1 2\n2 3\n3 5\n3 5'
		output = '3\n1\n2'
		self.assertIO(input, output)

	def test_入力例_3(self):
		input = '5 5\n-100000000 -100000000\n-100000000 100000000\n100000000 -100000000\n100000000 100000000\n0 0\n0 0\n100000000 100000000\n100000000 -100000000\n-100000000 100000000\n-100000000 -100000000'
		output = '5\n4\n3\n2\n1'
		self.assertIO(input, output)

def resolve():
	(N, M) = list(map(int, input().split()))
	S = [list(map(int, input().split())) for _ in range(N)]
	C = [list(map(int, input().split())) for _ in range(M)]
	ans = []
	for s in S:
		D = float('inf')
		t = 0
		for i in range(M):
			d = abs(s[0] - C[i][0]) + abs(s[1] - C[i][1])
			if d < D:
				D = d
				t = i
		ans.append(t + 1)
	for a in ans:
		print(a)

def __starting_point():
	resolve()
__starting_point()


(N, M) = map(int, input().split())
student = [tuple(map(int, input().split())) for x in range(N)]
point = [tuple(map(int, input().split())) for x in range(M)]
for (x1, y1) in student:
	data = [abs(x1 - x2) + abs(y1 - y2) for (x2, y2) in point]
	ans = data.index(min(data))
	print(ans + 1)


(N, M) = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for _ in range(N)]
C = [[int(_) for _ in input().split()] + [_ + 1] for _ in range(M)]
for (a, b) in AB:
	ans = []
	for c in C:
		ans += [[(abs(c[0] - a) + abs(c[1] - b)) * 100 + c[2], c[2]]]
	print(sorted(ans)[0][1])


(N, M) = map(int, input().split())
student = [list(map(int, input().split())) for i in range(N)]
check = [list(map(int, input().split())) for i in range(M)]
tmp = []
for i in range(len(student)):
	for j in range(len(check)):
		x = abs(student[i][0] - check[j][0])
		y = abs(student[i][1] - check[j][1])
		tmp.append(x + y)
	print(tmp.index(min(tmp)) + 1)
	tmp = []


(N, M) = map(int, input().split(' '))
S = [list(map(int, input().split(' '))) for i in range(N)]
C = [list(map(int, input().split(' '))) for i in range(M)]
for i in range(N):
	l = [abs(S[i][0] - C[j][0]) + abs(S[i][1] - C[j][1]) for j in range(M)]
	print(l.index(min(l)) + 1)


(N, M) = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
CD = [list(map(int, input().split())) for _ in range(M)]
for i in range(N):
	check = []
	for j in range(M):
		check.append(abs(AB[i][0] - CD[j][0]) + abs(AB[i][1] - CD[j][1]))
	print(check.index(min(check)) + 1)


(n, m) = list(map(int, input().split()))
l_n = [list(map(int, input().split())) for _ in range(n)]
l_m = [list(map(int, input().split())) for _ in range(m)]
for (i, j) in l_n:
	distance = 0
	cnt = 0
	ans = float('inf')
	for (k, l) in enumerate(l_m, 1):
		(a, b) = l
		distance = abs(i - a) + abs(j - b)
		if ans > distance:
			ans = min(ans, distance)
			cnt = k
	print(cnt)


(n, m) = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
cd = [list(map(int, input().split())) for i in range(m)]
for i in range(n):
	Min = 4 * 10 ** 8 + 1
	for j in range(m):
		d = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
		if Min > d:
			Min = d
			ans = j + 1
	print(ans)


(N, M) = map(int, input().split())
students = []
points = []
for _ in range(N):
	students.append(list(map(int, input().split())))
for _ in range(M):
	points.append(list(map(int, input().split())))
for i in range(N):
	MIN = 10 ** 10
	index = -1
	for j in range(M):
		if MIN > abs(students[i][0] - points[j][0]) + abs(students[i][1] - points[j][1]):
			MIN = abs(students[i][0] - points[j][0]) + abs(students[i][1] - points[j][1])
			index = j
	print(index + 1)


def LI():
	return list(map(int, input().split()))

def LIHW(h):
	return [list(map(int, input().split())) for _ in range(h)]
(N, M) = LI()
Nlist = LIHW(N)
Mlist = LIHW(M)
anslist = [0] * N
for i in range(N):
	(a, b) = Nlist[i]
	ans = 10 ** 9
	for j in range(M):
		(c, d) = Mlist[j]
		kyori = abs(c - a) + abs(d - b)
		if ans > kyori:
			ansind = j + 1
			ans = kyori
	anslist[i] = ansind
for i in range(N):
	print(anslist[i])


(n, m) = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(n)]
cd = [list(map(int, input().split())) for j in range(m)]
for i in range(n):
	dis = float('inf')
	ch = 0
	for j in range(m):
		if dis > abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]):
			dis = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
			ch = j
	print(ch + 1)


(N, M) = map(int, input().split())
z = [list(map(int, input().split())) for i in range(N)]
c = [list(map(int, input().split())) for i in range(M)]
for i in z:
	d = 10 ** 9
	ans = C = 0
	for j in c:
		C += 1
		k = abs(i[0] - j[0]) + abs(i[1] - j[1])
		if d > k:
			ans = C
			d = k
	print(ans)


(n, m) = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
	num = 0
	ans = float('inf')
	for j in range(m):
		man = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
		if man < ans:
			ans = man
			num = j
	print(num + 1)


def dist(x, y):
	return abs(x[0] - y[0]) + abs(x[1] - y[1])
(N, M) = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N)]
CD = [list(map(int, input().split())) for _ in range(M)]
for i in range(N):
	ans = -1
	min_dist = float('inf')
	for j in range(M):
		if (d := dist(AB[i], CD[j])) < min_dist:
			ans = j
			min_dist = d
	print(ans + 1)


(n, m) = map(int, input().split())
AB = [[int(i) for i in input().split()] for i in range(n)]
CD = [[int(i) for i in input().split()] for i in range(m)]
for ab in AB:
	dist = [abs(ab[0] - cd[0]) + abs(ab[1] - cd[1]) for cd in CD]
	print(dist.index(min(dist)) + 1)


(n, m) = map(int, input().split())
student = [tuple(map(int, input().split())) for i in range(n)]
check = [tuple(map(int, input().split())) for i in range(m)]
for (a, b) in student:
	d = [abs(a - c) + abs(b - d) for (c, d) in check]
	print(d.index(min(d)) + 1)


(n, m) = map(int, input().split())
ab = list((list(map(int, input().split())) for _ in range(n)))
cd = list((list(map(int, input().split())) for _ in range(m)))
for j in range(n):
	(a, b) = (ab[j][0], ab[j][1])
	(ans, res) = (0, 1001001001)
	for i in range(m):
		(c, d) = (cd[i][0], cd[i][1])
		if abs(a - c) + abs(b - d) < res:
			res = abs(a - c) + abs(b - d)
			ans = i + 1
	print(ans)


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
c = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
	l = [abs(c[j][0] - a[i][0]) + abs(c[j][1] - a[i][1]) for j in range(m)]
	print(l.index(min(l)) + 1)


(n, m) = list(map(int, input().split()))
a_lis = [list(map(int, input().split())) for i in range(n)]
c_lis = [list(map(int, input().split())) for i in range(m)]
for i in range(n):
	num = 0
	ans = 10 ** 10
	for j in reversed(list(range(m))):
		a = a_lis[i]
		c = c_lis[j]
		num = abs(a[0] - c[0]) + abs(a[1] - c[1])
		ans = min(ans, num)
		if num == ans:
			cnt = j + 1
	print(cnt)


(n, m) = map(int, input().split(' '))
ab = [list(map(int, input().split(' '))) for i in range(n)]
cd = [list(map(int, input().split(' '))) for i in range(m)]
for (nx, ny) in ab:
	distances = [abs(nx - mx) + abs(ny - my) for (mx, my) in cd]
	print(distances.index(min(distances)) + 1)


(N, M) = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(N)]
C = [list(map(int, input().split())) for _ in range(M)]
for (a, b) in S:
	dist = [abs(a - c) + abs(b - d) for (c, d) in C]
	print(dist.index(min(dist)) + 1)


(N, M) = map(int, input().split())
students = [list(map(int, input().split())) for _ in range(N)]
checkpts = [list(map(int, input().split())) for _ in range(M)]
for (a, b) in students:
	tmp = [abs(a - x) + abs(b - y) for (x, y) in checkpts]
	print(tmp.index(min(tmp)) + 1)


(n, m) = map(int, input().split())
a = []
b = []
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(m):
	b.append(list(map(int, input().split())))
for i in range(n):
	tmp = 10 ** 9
	for j in range(m):
		man = abs(a[i][0] - b[j][0]) + abs(a[i][1] - b[j][1])
		if man < tmp:
			tmp = man
			ans = j + 1
	print(ans)


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for x in range(n)]
b = [list(map(int, input().split())) for x in range(m)]
for x in range(n):
	c = []
	for y in range(m):
		c.append(abs(a[x][0] - b[y][0]) + abs(a[x][1] - b[y][1]))
	print(c.index(min(c)) + 1)


(N, M) = map(int, input().split())
n = [list(map(int, input().split())) for _ in range(N)]
m = [list(map(int, input().split())) for _ in range(M)]
result = []
for i in range(len(n)):
	result = []
	for j in range(len(m)):
		result.append(abs(n[i][0] - m[j][0]) + abs(n[i][1] - m[j][1]))
	print(result.index(min(result)) + 1)


m = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(m[0])]
c = [list(map(int, input().split())) for i in range(m[1])]
for i in range(m[0]):
	p = []
	for j in range(m[1]):
		p.append(abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1]))
	print(p.index(min(p)) + 1)


(N, M) = map(int, input().split())
s = [tuple(map(int, input().split())) for _ in range(N)]
c = [tuple(map(int, input().split())) for _ in range(M)]
for i in range(N):
	mn = [abs(s[i][0] - c[j][0]) + abs(s[i][1] - c[j][1]) for j in range(M)]
	print(mn.index(min(mn)) + 1)


(N, M) = list(map(int, input().split()))
stu = []
che = []
for i in range(N):
	ab = list(map(int, input().split()))
	stu.append(ab)
for i in range(M):
	cd = list(map(int, input().split()))
	che.append(cd)
ans = 0
dis = 0
x = 5 * 10 ** 8
for i in range(N):
	for j in range(M):
		dis = abs(stu[i][0] - che[j][0]) + abs(stu[i][1] - che[j][1])
		if dis < x:
			x = dis
			ans = j + 1
	print(ans)
	x = 5 * 10 ** 8


(n, m) = map(int, input().split())
students = [list(map(int, input().split())) for _ in range(n)]
checks = [list(map(int, input().split())) for _ in range(m)]
for s in students:
	dis = [abs(s[0] - c[0]) + abs(s[1] - c[1]) for c in checks]
	print(dis.index(min(dis)) + 1)


(n, m) = map(int, input().split())
stu = [list(map(int, input().split())) for i in range(n)]
chk = [list(map(int, input().split())) for i in range(m)]
for ab in stu:
	manh = [abs(ab[0] - cd[0]) + abs(ab[1] - cd[1]) for cd in chk]
	print(manh.index(min(manh)) + 1)


f = lambda x, y: abs(x[0] - y[0]) + abs(x[1] - y[1])
(N, M) = map(int, input().split())
l = [tuple(map(int, input().split())) for _ in range(N)]
m = [tuple(map(int, input().split())) for _ in range(M)]
for i in l:
	print(min([(f(i, j), k + 1) for (k, j) in enumerate(m)])[1])


(N, M) = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
C = [list(map(int, input().split())) for i in range(M)]
for i in A:
	ans = [abs(i[0] - j[0]) + abs(i[1] - j[1]) for j in C]
	ans_min = min(ans)
	print(ans.index(ans_min) + 1)


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
ab = []
cd = []
for _ in range(n):
	(a, b) = map(int, input().split())
	ab.append((a, b))
for _ in range(m):
	(c, d) = map(int, input().split())
	cd.append((c, d))
ans = []
for (a, b) in ab:
	t = 10 ** 18
	checkpoint = -1
	for (i, cdi) in enumerate(cd):
		(c, d) = cdi
		dist = abs(a - c) + abs(b - d)
		if dist < t:
			t = dist
			checkpoint = i + 1
	ans.append(checkpoint)
print(*ans, sep='\n')


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
	ans = []
	for j in range(m):
		ans.append(abs(a[i][0] - b[j][0]) + abs(a[i][1] - b[j][1]))
	print(ans.index(min(ans)) + 1)


(N, M) = list(map(int, input().split()))
S = [tuple(map(int, input().split())) for _ in range(N)]
P = [tuple(map(int, input().split())) for _ in range(M)]
for (sx, sy) in S:
	m = 10 ** 9
	for (i, (px, py)) in enumerate(P):
		d = abs(px - sx) + abs(py - sy)
		if d < m:
			im = i
			m = d
	print(im + 1)


(N, M) = map(int, input().split())
S = [list(map(int, input().split())) for n in range(N)]
P = [list(map(int, input().split())) for m in range(M)]
for (a, b) in S:
	D = []
	for (c, d) in P:
		D.append(abs(a - c) + abs(b - d))
	print(1 + P.index(P[D.index(min(D))]))


(n, m) = map(int, input().split())
num_list = []
for i in range(n):
	num_list.append(list(map(int, input().split())))
check_list = []
for i in range(m):
	check_list.append(list(map(int, input().split())))
for i in range(n):
	d = 10 ** 9
	h = 0
	for j in range(m):
		if d > abs(num_list[i][0] - check_list[j][0]) + abs(num_list[i][1] - check_list[j][1]):
			d = abs(num_list[i][0] - check_list[j][0]) + abs(num_list[i][1] - check_list[j][1])
			h = j + 1
	print(h)


(n, m) = list(map(int, input().split()))
(a, b, c, d) = ([], [], [], [])
for _ in range(n):
	(an, bn) = list(map(int, input().split()))
	a.append(an)
	b.append(bn)
for _ in range(m):
	(cn, dn) = list(map(int, input().split()))
	c.append(cn)
	d.append(dn)

def dist(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
for i in range(n):
	minimum = 10 ** 9
	min_id = 0
	for j in range(m):
		ds = dist(a[i], b[i], c[j], d[j])
		if ds < minimum:
			minimum = ds
			min_id = j
	print(min_id + 1)


(N, M) = map(int, input().split())
AB = []
for _ in range(N):
	(a, b) = map(int, input().split())
	AB.append((a, b))
CD = []
for _ in range(M):
	(c, d) = map(int, input().split())
	CD.append((c, d))
for (a, b) in AB:
	i = min(range(M), key=lambda i: abs(a - CD[i][0]) + abs(b - CD[i][1]))
	print(i + 1)


(N, M) = map(int, input().split())
s = [tuple(map(int, input().split())) for _ in range(N)]
c = [tuple(map(int, input().split())) for _ in range(M)]

def calc_dict(p1, p2):
	return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])
for i in range(N):
	dist = list(map(lambda x: calc_dict(s[i], x), c))
	print(dist.index(min(dist)) + 1)


(N, M) = map(int, input().split())
st = [[int(i) for i in input().split()] for j in range(N)]
cp = [[int(i) for i in input().split()] for j in range(M)]
for i in st:
	L = [abs(i[0] - j[0]) + abs(i[1] - j[1]) for j in cp]
	m = min(L)
	print(L.index(m) + 1)


(n, m) = map(int, input().split())
a = [[int(i) for i in input().split()] for j in range(n)]
c = [[int(i) for i in input().split()] for j in range(m)]
for (x1, y1) in a:
	d = 10 ** 9
	n = 1
	s = 0
	for (x2, y2) in c:
		if abs(x1 - x2) + abs(y1 - y2) < d:
			s = n
			d = abs(x1 - x2) + abs(y1 - y2)
		n += 1
	print(s)


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]
for (ax, ay) in a:
	mh = []
	for (i, [bx, by]) in enumerate(b):
		mh.append([abs(ax - bx) + abs(ay - by), i + 1])
	mh.sort()
	print(mh[0][1])


(N, M) = map(int, input().split())
(Nlist, Mlist) = ([], [])
res = []
for i in range(N):
	ab = list(map(int, input().split()))
	Nlist.append(ab)
for i in range(M):
	cd = list(map(int, input().split()))
	Mlist.append(cd)
for i in range(N):
	res = 0
	mini = float('inf')
	for j in range(M):
		calc = abs(Nlist[i][0] - Mlist[j][0]) + abs(Nlist[i][1] - Mlist[j][1])
		if calc < mini:
			mini = calc
			res = j + 1
	print(res)


(N, M) = map(int, input().split())
Std = [tuple(map(int, input().split())) for _ in range(N)]
Chp = [tuple(map(int, input().split())) for _ in range(M)]
INF = 10000000000.0
Arrv = []
Mdist = lambda x, y, u, v: abs(x - u) + abs(y - v)
for s in Std:
	close = INF
	for i in range(M):
		dist = Mdist(*s, *Chp[i])
		if dist < close:
			close = dist
			arrv = i + 1
	Arrv.append(arrv)
for ar in Arrv:
	print(ar)


(n, m) = list(map(int, input().split()))
ab = []
for i in range(n):
	ab.append(list(map(int, input().split())))
cd = []
for i in range(m):
	cd.append(list(map(int, input().split())))
for i in range(n):
	(a, b) = ab[i]
	dis = 10 ** 9
	point = 0
	for j in range(m):
		(c, d) = cd[j]
		if abs(a - c) + abs(b - d) < dis:
			point = j + 1
			dis = abs(a - c) + abs(b - d)
	print(point)


import sys
(n, m) = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split())) for i in range(m)]
chkPoint = [0] * n
for (i, axy) in enumerate(a):
	(ax, ay) = axy
	dist = sys.maxsize
	for (j, bxy) in enumerate(b):
		(bx, by) = bxy
		if dist > abs(ax - bx) + abs(ay - by):
			chkPoint[i] = j + 1
			dist = abs(ax - bx) + abs(ay - by)
	print(chkPoint[i])


(N, M) = list(map(int, input().split()))
X = []
for i in range(N):
	x = list(map(int, input().split()))
	X.append(x)
Y = []
for i in range(M):
	y = list(map(int, input().split()))
	Y.append(y)
for i in X:
	len = []
	for j in Y:
		len.append(abs(i[0] - j[0]) + abs(i[1] - j[1]))
	print(len.index(min(len)) + 1)


(N, M) = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
cd = [list(map(int, input().split())) for _ in range(M)]
for i in range(N):
	ans = -1
	dist = 10 ** 12
	for j in range(M):
		tmp = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
		if tmp < dist:
			ans = j
			dist = tmp
	print(ans + 1)


(N, M) = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(M)]
for i in range(N):
	d = []
	for j in range(M):
		d_x = abs(S[i][0] - P[j][0])
		d_y = abs(S[i][1] - P[j][1])
		d.append(d_x + d_y)
	print(d.index(min(d)) + 1)


(N, M) = map(int, input().split(' '))
ab = [0] * N
cd = [0] * M
for i in range(N):
	ab[i] = list(map(int, input().split(' ')))
for i in range(M):
	cd[i] = list(map(int, input().split(' '))) + [i + 1]
for (a, b) in ab:
	m = min(cd, key=lambda x: 10000 * (abs(a - x[0]) + abs(b - x[1])) + x[2])
	print(m[2])


(N, M) = map(int, input().split())
s = [list(map(int, input().split())) for _ in [0] * N]
c = [list(map(int, input().split())) for _ in [0] * M]
for (x, y) in s:
	d = {k + 1: abs(x - t[0]) + abs(y - t[1]) for (k, t) in enumerate(c)}
	print(min(d, key=d.get))


(n, m) = map(int, input().split())
n_list = [list(map(int, input().split())) for i in range(n)]
m_list = [list(map(int, input().split())) for i in range(m)]
for i in range(n):
	list = []
	for j in range(m):
		x = abs(n_list[i][0] - m_list[j][0])
		y = abs(n_list[i][1] - m_list[j][1])
		list.append(x + y)
	print(list.index(min(list)) + 1)


(n, m) = map(int, input().split())
students = [list(map(int, input().split())) for _ in range(n)]
points = [list(map(int, input().split())) for _ in range(m)]
ans = []
for i in range(n):
	min_diff = 20 ** 8 + 1
	near_point = 0
	for j in range(m):
		diff = abs(students[i][0] - points[j][0]) + abs(students[i][1] - points[j][1])
		if diff < min_diff:
			min_diff = diff
			near_point = j + 1
	ans.append(near_point)
print('\n'.join(map(str, ans)))


(n, m) = map(int, input().split())
li = [list(map(int, input().split())) for i in range(n)]
lj = [list(map(int, input().split())) for i in range(m)]
for i in range(n):
	li_distance = [abs(lj[j][0] - li[i][0]) + abs(lj[j][1] - li[i][1]) for j in range(m)]
	print(li_distance.index(min(li_distance)) + 1)


def func(x):
	return abs(x[0] - k[0]) + abs(x[1] - k[1])
(N, M) = map(int, input().split())
s = []
for i in range(N):
	(a, b) = map(int, input().split())
	s.append((a, b))
t = []
for i in range(M):
	(a, b) = map(int, input().split())
	t.append((a, b))
for k in s:
	print(1 + t.index(min(t, key=func)))


def f(gx, gy):
	ans = 10 ** 9
	no = 0
	for i in range(m):
		tmp = abs(gx - checkpoint[i][0]) + abs(gy - checkpoint[i][1])
		if tmp < ans:
			ans = tmp
			no = i
	return no + 1
(n, m) = list(map(int, input().split()))
gakusei = []
for i in range(n):
	(x, y) = list(map(int, input().split()))
	gakusei.append([x, y])
checkpoint = []
for j in range(m):
	(x, y) = list(map(int, input().split()))
	checkpoint.append([x, y])
for i in range(n):
	print(f(gakusei[i][0], gakusei[i][1]))


(N, M) = map(int, input().split())
ab = []
for _ in range(N):
	ab.append(list(map(int, input().split())))
cd = []
for _ in range(M):
	cd.append(list(map(int, input().split())))
for x in ab:
	a = x[0]
	b = x[1]
	cnt = []
	for y in cd:
		c = y[0]
		d = y[1]
		k = abs(a - c) + abs(b - d)
		cnt.append(k)
	print(cnt.index(min(cnt)) + 1)


(n, m) = list(map(int, input().split()))
student = []
for _ in range(n):
	(a, b) = list(map(int, input().split()))
	student.append([a, b])
checkpoint = []
for _ in range(m):
	(c, d) = list(map(int, input().split()))
	checkpoint.append([c, d])
for i in range(n):
	s = student[i]
	dist = float('inf')
	num = 0
	for j in range(m):
		c = checkpoint[j]
		tmp = abs(s[0] - c[0]) + abs(s[1] - c[1])
		if tmp < dist:
			dist = tmp
			num = j + 1
	print(num)


(N, M) = list(map(int, input().split()))
a = []
b = []
c = []
d = []
for i in range(N):
	(x, y) = list(map(int, input().split()))
	a.append(x)
	b.append(y)
for i in range(M):
	(x, y) = list(map(int, input().split()))
	c.append(x)
	d.append(y)
for i in range(N):
	m = abs(a[i] - c[0]) + abs(b[i] - d[0])
	p = 0
	for j in range(1, M):
		if m > abs(a[i] - c[j]) + abs(b[i] - d[j]):
			m = abs(a[i] - c[j]) + abs(b[i] - d[j])
			p = j
	print(p + 1)


from typing import List

def manhattan_distance(student: List[int], check_point: List[int]) -> int:
	return abs(check_point[0] - student[0]) + abs(check_point[1] - student[1])

def answer(n: int, m: int, students: List[List[int]], check_points: List[List[int]]) -> str:
	students_destination = []
	for student in students:
		mds = {}
		for (i, check_point) in enumerate(check_points, start=1):
			md = manhattan_distance(student, check_point)
			if md not in list(mds.keys()):
				mds[md] = str(i)
		students_destination.append(mds[min(mds.keys())])
	return '\n'.join(students_destination)

def main():
	(n, m) = list(map(int, input().split()))
	ab = [list(map(int, input().split())) for _ in range(n)]
	cd = [list(map(int, input().split())) for _ in range(m)]
	print(answer(n, m, ab, cd))

def __starting_point():
	main()
__starting_point()


(n, m) = map(int, input().split())
ab = []
cd = []
for i in range(n):
	ab.append(list(map(int, input().split())))
for j in range(m):
	cd.append(list(map(int, input().split())))
for k in range(n):
	s = [abs(ab[k][0] - cd[l][0]) + abs(ab[k][1] - cd[l][1]) for l in range(m)]
	print(s.index(min(s)) + 1)


(n, m) = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

def distance(x, y, i, j):
	return abs(x - i) + abs(y - j)
for (a, b) in ab:
	dists = [distance(a, b, c, d) for (c, d) in cd]
	print(dists.index(min(dists)) + 1)


(n, m) = map(int, input().split())
student = [list(map(int, input().split())) for i in range(n)]
point = [list(map(int, input().split())) for i in range(m)]
for (a, b) in student:
	length = 10 ** 10
	pn = 0
	for j in range(m):
		(c, d) = point[j]
		if abs(a - c) + abs(b - d) < length:
			length = abs(a - c) + abs(b - d)
			pn = 1 + j
	print(pn)


(N, M) = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(N)]
c = [list(map(int, input().split())) for i in range(M)]
for i in range(N):
	d = []
	for j in range(M):
		d.append(abs(s[i][0] - c[j][0]) + abs(s[i][1] - c[j][1]))
	print(d.index(min(d)) + 1)


(N, M) = map(int, input().split())
Ss = [tuple(map(int, input().split())) for i in range(N)]
CPs = [tuple(map(int, input().split())) for i in range(M)]
for (a, b) in Ss:
	dist = [abs(a - c) + abs(b - d) for (c, d) in CPs]
	print(dist.index(min(dist)) + 1)


(N, M) = map(int, input().split())
P = []
for i in range(N):
	(x, y) = map(int, input().split())
	P.append([x, y])
C = []
for i in range(M):
	(a, b) = map(int, input().split())
	C.append([a, b])
for p in P:
	mind = 10 ** 18
	for j in range(M):
		d = abs(p[0] - C[j][0]) + abs(p[1] - C[j][1])
		if d < mind:
			ans = j + 1
			mind = d
	print(ans)


(n, m) = map(int, input().split())
st = []
co = []
for i in range(n):
	(a, b) = map(int, input().split())
	st.append([a, b])
for i in range(m):
	(c, d) = map(int, input().split())
	co.append([c, d])
for (a, b) in st:
	tmp = 10 ** 9
	output = 0
	for i in range(m):
		if tmp > (new := (abs(a - co[i][0]) + abs(b - co[i][1]))):
			output = i + 1
			tmp = new
	print(output)


(n, m) = map(int, input().split())
s = [tuple(map(int, input().split())) for _ in range(n)]
c = [tuple(map(int, input().split())) for _ in range(m)]
for (a, b) in s:
	d = float('inf')
	for i in range(m):
		(x, y) = c[i]
		if abs(a - x) + abs(b - y) < d:
			d = abs(a - x) + abs(b - y)
			ans = i + 1
	print(ans)


(n, m) = list(map(int, input().split()))
ab = [tuple(map(int, input().split())) for _ in range(n)]
cd = [tuple(map(int, input().split())) for _ in range(m)]
for i in range(n):
	x = 1 << 30
	y = -1
	(a, b) = ab[i]
	for j in range(m):
		(c, d) = cd[j]
		d = abs(a - c) + abs(b - d)
		if x > d:
			x = d
			y = j
	print(y + 1)


(N, M) = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
CD = [tuple(map(int, input().split())) for _ in range(M)]
f = lambda ab: min(((abs(ab[0] - CD[i][0]) + abs(ab[1] - CD[i][1]), i + 1) for i in range(M)))[1]
print(*[f(ab) for ab in AB], sep='\n')


(n, m) = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(n)]
C = [list(map(int, input().split())) for _ in range(m)]
for (a, b) in A:
	l = [abs(a - c) + abs(b - d) for (c, d) in C]
	print(l.index(min(l)) + 1)


(n, m) = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(n)]
c = [list(map(int, input().split())) for _ in range(m)]
where = []
for i in range(n):
	distance = 10 ** 9
	for j in range(m):
		if distance > abs(s[i][0] - c[j][0]) + abs(s[i][1] - c[j][1]):
			distance = abs(s[i][0] - c[j][0]) + abs(s[i][1] - c[j][1])
			w = j
	where.append(w + 1)
[print(i) for i in where]


(n, m) = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(n)]
o = [list(map(int, input().split())) for _ in range(m)]
for (a, b) in s:
	k = []
	for (c, d) in o:
		k.append(abs(a - c) + abs(b - d))
	print(k.index(min(k)) + 1)


(n, m) = map(int, input().split())
l1 = []
l2 = []
for _ in range(n):
	(a, b) = map(int, input().split())
	l1.append((a, b))
for _ in range(m):
	(c, d) = map(int, input().split())
	l2.append((c, d))
for (a, b) in l1:
	mi = 1000000000.0
	i = 0
	for (j, (c, d)) in enumerate(l2):
		dist = abs(a - c) + abs(b - d)
		if dist < mi:
			mi = dist
			i = j
	print(i + 1)


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split())) for i in range(m)]
for i in range(n):
	x = [0] * m
	for j in range(m):
		x[j] = abs(a[i][0] - b[j][0]) + abs(a[i][1] - b[j][1])
	print(x.index(min(x)) + 1)


(N, M) = map(int, input().split())
stu = []
for v in range(N):
	(ai, bi) = map(int, input().split())
	stu.append((v, ai, bi))
cp = []
for w in range(M):
	(ci, di) = map(int, input().split())
	cp.append((w, ci, di))
cp = cp[::-1]
ans = [0] * N
for (i, x, y) in stu:
	mindist = 10 ** 16
	cp_num = 0
	for (j, k, l) in cp:
		dist = abs(x - k) + abs(y - l)
		if mindist >= dist:
			mindist = dist
			cp_num = j + 1
	ans[i] = cp_num
for n in ans:
	print(n)


(n, m) = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(n)]
c = [list(map(int, input().split())) for _ in range(m)]
for i in p:
	d = [abs(i[0] - c[j][0]) + abs(i[1] - c[j][1]) for j in range(len(c))]
	print(d.index(min(d)) + 1)


(N, M) = map(int, input().split())
students = tuple((tuple(map(int, input().split())) for _ in range(N)))
checks = tuple((tuple(map(int, input().split())) for _ in range(M)))
print(*(c for (_, c) in (min(((abs(x0 - x1) + abs(y0 - y1), i + 1) for (i, (x0, y0)) in enumerate(checks))) for (x1, y1) in students)), sep='\n')


(N, M) = map(int, input().split())
Seito = [tuple(map(int, input().split())) for i in range(N)]
Check = [tuple(map(int, input().split())) for i in range(M)]
for (a, b) in Seito:
	dist = [abs(a - c) + abs(b - d) for (c, d) in Check]
	print(dist.index(min(dist)) + 1)


(n, m) = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

def how_long(aabb, ccdd):
	return abs(aabb[0] - ccdd[0]) + abs(aabb[1] - ccdd[1])
for stu in ab:
	r = [how_long(stu, cd[i]) for i in range(m)]
	print(r.index(min(r)) + 1)


(N, M) = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]
check = [list(map(int, input().split())) for i in range(M)]
for (x, y) in X:
	dist = [abs(x - c[0]) + abs(y - c[1]) for c in check]
	MIN = min(dist)
	print(dist.index(MIN) + 1)


(n, m) = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
c = [0] * m
d = [0] * m
for j in range(m):
	(c[j], d[j]) = map(int, input().split())
for i in range(n):
	e = []
	for j in range(m):
		e.append(abs(a[i] - c[j]) + abs(b[i] - d[j]))
	f = e.index(min(e))
	print(f + 1)


(N, M) = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(N)]
c = [list(map(int, input().split())) for _ in range(M)]
for i in range(N):
	d = 10 ** 9
	n = 0
	for j in range(M):
		x = abs(s[i][0] - c[j][0]) + abs(s[i][1] - c[j][1])
		if x < d:
			d = x
			n = j + 1
	print(n)


(n, m) = map(int, input().split())
a = [0] * n
b = [0] * n
c = [0] * m
d = [0] * m
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
for i in range(m):
	(c[i], d[i]) = map(int, input().split())
for i in range(n):
	for j in range(m):
		if j == 0:
			ind = 0
			dis = abs(a[i] - c[j]) + abs(b[i] - d[j])
		elif abs(a[i] - c[j]) + abs(b[i] - d[j]) < dis:
			ind = j
			dis = abs(a[i] - c[j]) + abs(b[i] - d[j])
	print(ind + 1)


(n, m) = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
	mn = 1000000000
	ans = 0
	for j in range(m):
		d = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
		if d < mn:
			mn = d
			ans = j + 1
	print(ans)


(n, m) = map(int, input().split())
ab = [list(map(int, input().split())) for _ in [0] * n]
cd = [list(map(int, input().split())) for _ in [0] * m]
for (a, b) in ab:
	t = 1001001001
	ti = 0
	for (i, (c, d)) in enumerate(cd):
		e = abs(a - c) + abs(b - d)
		if t > e:
			t = e
			ti = i + 1
	print(ti)


(n, m) = map(int, input().split())
a = [[int(i) for i in input().split()] for l in range(n)]
b = [[int(i) for i in input().split()] for l in range(m)]
for A in a:
	c = 1
	r = 0
	m = 10000000000
	for B in b:
		k = abs(A[0] - B[0]) + abs(A[1] - B[1])
		if m > k:
			m = k
			r = c
		c += 1
	print(r)


(n, m) = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
cd = [list(map(int, input().split())) for i in range(m)]
for i in ab:
	ans = []
	for j in cd:
		kyori = abs(i[0] - j[0]) + abs(i[1] - j[1])
		ans.append(kyori)
	print(ans.index(min(ans)) + 1)


(N, M) = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
cd = [list(map(int, input().split())) for _ in range(M)]
for i in range(N):
	dist = float('inf')
	ans = 0
	(a, b) = (ab[i][0], ab[i][1])
	for j in range(M)[::-1]:
		(c, d) = (cd[j][0], cd[j][1])
		if abs(a - c) + abs(b - d) <= dist:
			dist = abs(a - c) + abs(b - d)
			ans = j + 1
	print(ans)


(N, M) = map(int, input().split())
a = []
c = []
for i in range(N):
	(x, y) = map(int, input().split())
	a.append([x, y])
for i in range(M):
	(x, y) = map(int, input().split())
	c.append([x, y])
for i in a:
	tmp = 10 ** 9
	for l in range(M):
		j = c[l]
		x = abs(i[0] - j[0]) + abs(i[1] - j[1])
		if tmp > x:
			tmp = x
			ans = l + 1
	print(ans)


(n, m) = list(map(int, input().split()))
students = []
for _ in range(n):
	students.append(list(map(int, input().split())))
checks = []
for _ in range(m):
	checks.append(list(map(int, input().split())))
for student in students:
	index = 1
	min = 10 ** 8 * 4
	for (i, check) in enumerate(checks, 1):
		tmp = abs(student[0] - check[0]) + abs(student[1] - check[1])
		if min > tmp:
			min = tmp
			index = i
	print(index)


(N, M) = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
CD = [list(map(int, input().split())) for _ in range(M)]
for ab in AB:
	man = [abs(ab[0] - CD[i][0]) + abs(ab[1] - CD[i][1]) for i in range(len(CD))]
	print(man.index(min(man)) + 1)


(N, M) = map(int, input().split())
a = [0] * N
b = [0] * N
c = [0] * M
d = [0] * M
for i in range(N):
	(a[i], b[i]) = map(int, input().split())
for i in range(M):
	(c[i], d[i]) = map(int, input().split())
for i in range(N):
	min = 0
	for j in range(M):
		if abs(a[i] - c[min]) + abs(b[i] - d[min]) > abs(a[i] - c[j]) + abs(b[i] - d[j]):
			min = j
	print(min + 1)


(n, m) = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for i in range(m)]
for (a, b) in ab:
	ma = 10 ** 10
	tp = 0
	for i in range(m):
		if ma > abs(a - cd[i][0]) + abs(b - cd[i][1]):
			ma = abs(a - cd[i][0]) + abs(b - cd[i][1])
			tp = i + 1
	print(tp)


import math
import collections
from itertools import product
ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(map(int, input().split()))
(n, m) = mi()
ab = [li() for _ in range(n)]
cd = [li() for _ in range(m)]
for i in range(n):
	length = 10 ** 10
	ans = 0
	for j in range(m):
		if abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]) < length:
			length = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
			ans = j
	print(ans + 1)


a = list(map(int, input().split()))
b = [list(map(int, input().split())) for i in range(a[0])]
c = [list(map(int, input().split())) for i in range(a[1])]
for i in range(a[0]):
	d = []
	for j in range(a[1]):
		d.append(abs(b[i][0] - c[j][0]) + abs(b[i][1] - c[j][1]))
	else:
		print(d.index(min(d)) + 1)


(n, m) = list(map(int, input().split()))
X = [tuple(map(int, input().split())) for _ in range(n)]
Y = [tuple(map(int, input().split())) for _ in range(m)]
for x in X:
	d1 = sum(x)
	d2 = x[0] - x[1]
	z = 10 ** 9
	for (i, y) in enumerate(Y, 1):
		D1 = sum(y)
		D2 = y[0] - y[1]
		Z = max(abs(D1 - d1), abs(D2 - d2))
		if z > Z:
			z = Z
			ans = i
	print(ans)


(n, m) = map(int, input().split())
A = []
B = []
C = []
D = []
E = []
ans = 0
for i in range(n):
	(a, b) = map(int, input().split())
	A.append(a)
	B.append(b)
for i in range(m):
	(c, d) = map(int, input().split())
	C.append(c)
	D.append(d)
for i in range(n):
	for j in range(m):
		ans = abs(A[i] - C[j]) + abs(B[i] - D[j])
		E.append(ans)
		ans = 0
	print(E.index(min(E)) + 1)
	E.clear()


import itertools
url = 'https://atcoder.jp//contests/abc057/tasks/abc057_a'

def main():
	(n, m) = list(map(int, input().split()))
	ab = [list(map(int, input().split())) for _ in range(n)]
	cd = [list(map(int, input().split())) for _ in range(m)]
	for i in range(len(ab)):
		dist = []
		for k in range(len(cd)):
			tmp = abs(ab[i][0] - cd[k][0]) + abs(ab[i][1] - cd[k][1])
			dist.append(tmp)
		print(dist.index(min(dist)) + 1)

def __starting_point():
	main()
__starting_point()


import sys
import math
import itertools
import collections
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD2 = 998244353
INF = float('inf')
input = lambda : sys.stdin.readline().strip()
NI = lambda : int(input())
NMI = lambda : map(int, input().split())
NLI = lambda : list(NMI())
SI = lambda : input()

def main():
	(N, M) = NMI()
	AB = [NLI() for _ in range(N)]
	CD = [NLI() for _ in range(M)]
	for n in range(N):
		A = AB[n][0]
		B = AB[n][1]
		distance = []
		for m in range(M):
			C = CD[m][0]
			D = CD[m][1]
			distance.append(abs(A - C) + abs(B - D))
		print(distance.index(min(distance)) + 1)

def __starting_point():
	main()
__starting_point()


(N, M) = list(map(int, input().split()))
ab = list((list(map(int, input().split())) for _ in range(N)))
cd = list((list(map(int, input().split())) for _ in range(M)))
for i in range(N):
	k = 0
	d = abs(ab[i][0] - cd[0][0]) + abs(ab[i][1] - cd[0][1])
	for j in range(1, M):
		if abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]) < d:
			k = j
			d = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
	print(k + 1)


(n, m) = map(int, input().split())
a = [0] * n
b = [0] * n
c = [0] * m
d = [0] * m
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
for i in range(m):
	(c[i], d[i]) = map(int, input().split())
for i in range(n):
	dist = abs(a[i] - c[0]) + abs(b[i] - d[0])
	point = 1
	for j in range(1, m):
		if dist > abs(a[i] - c[j]) + abs(b[i] - d[j]):
			dist = abs(a[i] - c[j]) + abs(b[i] - d[j])
			point = j + 1
	print(point)


(n, m) = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(n)]
cd = [list(map(int, input().split())) for i in range(m)]
for val in ab:
	tmp = []
	for point in cd:
		tmp.append(abs(val[0] - point[0]) + abs(val[1] - point[1]))
	print(tmp.index(min(tmp)) + 1)


import numpy as np
(n, m) = map(int, input().split())
ab = []
for _ in range(n):
	(a, b) = map(int, input().split())
	ab.append((a, b))
result = np.zeros([m, n], dtype=np.int64)
cd = []
for i in range(m):
	(c, d) = map(int, input().split())
	for (j, (a, b)) in enumerate(ab):
		result[i, j] = abs(a - c) + abs(b - d)
print(*result.argmin(axis=0) + 1, sep='\n')


((n, m), *a) = [list(map(int, s.split())) for s in open(0).readlines(0)]
for (i, j) in a[:n]:
	l = [abs(x - i) + abs(y - j) for (x, y) in a[n:]]
	print(1 + l.index(min(l)))


def mht(a, b):
	return abs(a[0] - b[0]) + abs(a[1] - b[1])
(n, m) = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(n)]
c = [list(map(int, input().split())) for _ in range(m)]
for i in p:
	a = [10 ** 9, 0]
	for j in range(m):
		if mht(i, c[j]) < a[0]:
			a = [mht(i, c[j]), j + 1]
	print(a[1])


(n, m) = map(int, input().split())
student_list = [list(map(int, input().split())) for _ in range(n)]
check_list = [list(map(int, input().split())) for _ in range(m)]
for s in student_list:
	tmp = []
	for c in check_list:
		tmp.append(abs(s[0] - c[0]) + abs(s[1] - c[1]))
	print(tmp.index(min(tmp)) + 1)


(n, m) = map(int, input().split())
st = []
pt = []
ch = []
for i in range(n):
	st.append(list(map(int, input().split())))
for i in range(m):
	pt.append(list(map(int, input().split())))
for j in st:
	for k in pt:
		d = abs(j[0] - k[0]) + abs(j[1] - k[1])
		ch.append(d)
	print(ch.index(min(ch)) + 1)
	ch = []


(n, m) = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
c = [0] * m
d = [0] * m
for j in range(m):
	(c[j], d[j]) = map(int, input().split())
e = [0] * n
g = [0] * m
for k in range(n):
	for l in range(m):
		g[l] = abs(a[k] - c[l]) + abs(b[k] - d[l])
	e[k] = int(g.index(min(g)) + 1)
	print(e[k])


(n, m) = list(map(int, input().split()))
stu = []
checkpoints = []
for _ in range(n):
	ab = list(map(int, input().split()))
	stu.append(list(ab))
for _ in range(m):
	cd = list(map(int, input().split()))
	checkpoints.append(list(cd))
for s in stu:
	checkpoint_id = 1010101
	manhatttaaann_dis = 2 * 10 ** 18 + 101010101
	for (i, cp) in enumerate(checkpoints):
		dist = abs(s[0] - cp[0]) + abs(s[1] - cp[1])
		if dist < manhatttaaann_dis:
			manhatttaaann_dis = dist
			checkpoint_id = i
	print(checkpoint_id + 1)


(n, m) = map(int, input().split())
s_pos = []
c_pos = []
for i in range(n):
	(a, b) = map(int, input().split())
	s_pos.append([a, b])
for i in range(m):
	(c, d) = map(int, input().split())
	c_pos.append([c, d])
for i in range(n):
	min_dist = 10 ** 16
	c_index = 0
	for j in range(m):
		dist = abs(s_pos[i][0] - c_pos[j][0]) + abs(s_pos[i][1] - c_pos[j][1])
		if dist < min_dist:
			min_dist = dist
			c_index = j + 1
	print(c_index)


(n, m) = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]
B = [list(map(int, input().split())) for i in range(m)]
for a in A:
	m = float('Inf')
	p = 0
	for (i, b) in enumerate(B):
		if m > abs(a[0] - b[0]) + abs(a[1] - b[1]):
			m = abs(a[0] - b[0]) + abs(a[1] - b[1])
			p = i + 1
	print(p)


(n, m) = map(int, input().split())
p = [list(map(int, input().split())) for i in range(n)]
q = [list(map(int, input().split())) for i in range(m)]
for x in range(n):
	c = []
	for y in range(m):
		c.append(abs(p[x][0] - q[y][0]) + abs(p[x][1] - q[y][1]))
	print(c.index(min(c)) + 1)


(n, m) = map(int, input().split())
ab = []
for i in range(n):
	ab.append(list(map(int, input().split())))
cd = []
for i in range(m):
	cd.append(list(map(int, input().split())))
ans = [0] * m
for i in range(n):
	(a, b) = (ab[i][0], ab[i][1])
	dist = [0] * m
	for j in range(m):
		dist[j] = abs(a - cd[j][0]) + abs(b - cd[j][1])
	dm = min(dist)
	for j in range(m):
		if dist[j] == dm:
			print(j + 1)
			break


import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10 ** 6)

def zz():
	return list(map(int, sys.stdin.readline().split()))

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

def S():
	return sys.stdin.readline()[:-1]

def C(line):
	return [sys.stdin.readline() for _ in range(line)]
(n, m) = zz()
(A, B) = ([], [])
for i in range(n):
	(a, b) = zz()
	A.append(a)
	B.append(b)
(C, D) = ([], [])
for i in range(m):
	(c, d) = zz()
	C.append(c)
	D.append(d)
dist = [[0] * m for i in range(n)]
for i in range(n):
	for j in range(m):
		dist[i][j] = abs(A[i] - C[j]) + abs(B[i] - D[j])
for i in range(n):
	print(np.argmin(dist[i]) + 1)


(n, m) = map(int, input().split())
stu = [list(map(int, input().split())) for i in range(n)]
po = [list(map(int, input().split())) for i in range(m)]
for i in stu:
	tmp = 10 ** 12
	for j in po:
		ab = abs(i[0] - j[0]) + abs(i[1] - j[1])
		if ab < tmp:
			tmp = ab
			ans = po.index(j)
	print(ans + 1)


(n, m) = [int(x) for x in input().split()]
a = [[int(x) for x in input().split()] for y in range(n)]
b = [[int(x) for x in input().split()] for y in range(m)]
for ai in a:
	n = [abs(ai[0] - bi[0]) + abs(ai[1] - bi[1]) for bi in b]
	print(n.index(min(n)) + 1)


(N, M) = map(int, input().split())
S = [tuple(map(int, input().split())) for _ in range(N)]
C = [tuple(map(int, input().split())) for _ in range(M)]
for i in S:
	ans = 0
	k = 10 ** 10
	for j in range(M):
		n = abs(i[0] - C[j][0]) + abs(i[1] - C[j][1])
		if k > n:
			k = n
			ans = j + 1
	else:
		print(ans)


(N, M) = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]
CD = [list(map(int, input().split())) for i in range(M)]
for (a, b) in AB:
	x = 10 ** 20
	for (i, (c, d)) in enumerate(CD):
		l = int(abs(a - c) + abs(b - d))
		if x > l:
			x = l
			num = i + 1
	print(num)


(n, m) = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
	k = float('inf')
	for j in range(m):
		l = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
		if l < k:
			k = l
			out = j + 1
	print(out)


(n, m) = map(int, input().split())
student = [None] * n
for i in range(n):
	student[i] = tuple(map(int, input().split()))
point = [None] * m
for i in range(m):
	point[i] = tuple(map(int, input().split()))
for i in range(n):
	dist = pow(10, 9)
	ans = 0
	(x, y) = student[i]
	for j in range(m):
		sub = abs(point[j][0] - x) + abs(point[j][1] - y)
		if dist > sub:
			dist = sub
			ans = j + 1
	print(ans)


(n, m) = map(int, input().split())
(L1, L2, L3) = ([], [], [])
for s in range(n):
	L1.append(list(map(int, input().split())))
for s in range(m):
	L2.append(list(map(int, input().split())))
for x in L1:
	L3 = []
	for y in L2:
		L3.append(abs(x[0] - y[0]) + abs(x[1] - y[1]))
	print(L3.index(min(L3)) + 1)


from math import gcd
from itertools import combinations, permutations, accumulate, product
from collections import deque, defaultdict, Counter
import decimal
import re
import math
import bisect
import heapq
import sys
sys.setrecursionlimit(10000000)
mod = 10 ** 9 + 7
INF = float('inf')
from sys import stdin
readline = stdin.readline

def readInts():
	return list(map(int, readline().split()))

def readTuples():
	return tuple(map(int, readline().split()))

def I():
	return int(readline())
(n, m) = readInts()
N = [readInts() for _ in range(n)]
M = [readInts() for _ in range(m)]
for (a, b) in N:
	pos = INF
	ans = None
	for (i, (x, y)) in enumerate(M):
		if abs(a - x) + abs(b - y) < pos:
			pos = abs(a - x) + abs(b - y)
			ans = i + 1
	print(ans)


(n, m) = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(n)]
B = [list(map(int, input().split())) for _ in range(m)]
for a in A:
	D = []
	for i in range(m):
		D.append([abs(a[0] - B[i][0]) + abs(a[1] - B[i][1]), i + 1])
	D = sorted(D, key=lambda x: (x[0], x[1]))
	print(D[0][1])


(n, m) = list(map(int, input().split()))
s_x_plus_y = []
s_x_minus_y = []
p_x_plus_y = []
p_x_minus_y = []
for student in range(n):
	(x, y) = list(map(int, input().split()))
	s_x_plus_y.append(x + y)
	s_x_minus_y.append(x - y)
for i in range(m):
	(x, y) = list(map(int, input().split()))
	p_x_plus_y.append(x + y)
	p_x_minus_y.append(x - y)
for i in range(n):
	p_dist = []
	for j in range(m):
		p1 = abs(s_x_plus_y[i] - p_x_plus_y[j])
		p2 = abs(s_x_minus_y[i] - p_x_minus_y[j])
		d = max(p1, p2)
		p_dist.append(d)
	print(p_dist.index(min(p_dist)) + 1)


(n, m) = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
	l = [0] * m
	for j in range(m):
		l[j] = abs(s[i][0] - p[j][0]) + abs(s[i][1] - p[j][1])
	print(l.index(min(l)) + 1)


(N, M) = map(int, input().split())
St = [list(map(int, input().split())) for _ in range(N)]
Pt = [list(map(int, input().split())) for _ in range(M)]
for (a, b) in St:
	dis = [abs(a - c) + abs(b - d) for (c, d) in Pt]
	print(dis.index(min(dis)) + 1)


(n, m) = map(int, input().split())
nlst = [[int(i) for i in input().split()] for _ in range(n)]
mlst = [[int(i) for i in input().split()] for _ in range(m)]
for i in nlst:
	tmp = [abs(i[0] - j[0]) + abs(i[1] - j[1]) for j in mlst]
	print(tmp.index(min(tmp)) + 1)


(n, m) = map(int, input().split())
st = []
cp = []
for i in range(n):
	st.append(list(map(int, input().split())))
for i in range(m):
	cp.append(list(map(int, input().split())))
for i in range(n):
	distance = 0
	shortest_cp = 0
	for j in range(m):
		if j == 0:
			distance = 1
			shortest_cp = abs(st[i][0] - cp[j][0]) + abs(st[i][1] - cp[j][1])
		elif abs(st[i][0] - cp[j][0]) + abs(st[i][1] - cp[j][1]) < shortest_cp:
			distance = j + 1
			shortest_cp = abs(st[i][0] - cp[j][0]) + abs(st[i][1] - cp[j][1])
	print(distance)


import sys, math
from itertools import combinations as c, product as p
from collections import deque
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def si():
	return input()

def ii():
	return int(input())

def fi():
	return float(input())

def lstr():
	return input().split()

def lint():
	return list(map(int, input().split()))

def lintdec():
	return list(map(lambda x: int(x) - 1, input().split()))

def lnstr(n):
	return [input() for _ in range(n)]

def lnint(n):
	return [int(input()) for _ in range(n)]

def lint_list(n):
	return [lint() for _ in range(n)]
(N, M) = lint()
students = lint_list(N)
check = lint_list(M)
for (sx, sy) in students:
	ans = -1
	dist = INF
	for i in range(M):
		(cx, cy) = check[i]
		tmp = abs(cx - sx) + abs(cy - sy)
		if tmp < dist:
			dist = tmp
			ans = i + 1
	print(ans)


(N, M) = map(int, input().split())
(a, b) = ([0] * N, [0] * N)
for i in range(N):
	(a[i], b[i]) = map(int, input().split())
(c, d) = ([0] * M, [0] * M)
for i in range(M):
	(c[i], d[i]) = map(int, input().split())
for i in range(N):
	ans = min(range(M), key=lambda j: abs(a[i] - c[j]) + abs(b[i] - d[j]))
	print(ans + 1)


(n, m) = map(int, input().split())
students = [list(map(int, input().split())) for i in range(n)]
targets = [list(map(int, input().split())) for i in range(m)]
x = 0
snumber = [(0, x)] * n

def md(s, t):
	d = abs(s[0] - t[0]) + abs(s[1] - t[1])
	return d
for i in range(n):
	x = 4 * 10 ** 8
	for j in range(m):
		if x > md(students[i], targets[j]):
			x = md(students[i], targets[j])
			snumber[i] = (j + 1, md(students[i], targets[j]))
for i in range(n):
	print(snumber[i][0])


(N, M) = map(int, input().split())
A = []
C = []
for i in range(N):
	A.append([int(i) for i in input().split()])
for j in range(M):
	C.append([int(i) for i in input().split()])
for i in range(N):
	l = []
	for k in range(M):
		l.append(abs(A[i][0] - C[k][0]) + abs(A[i][1] - C[k][1]))
	print(l.index(min(l)) + 1)


(N, M) = map(int, input().split())
stu = [list(map(int, input().split())) for _ in range(N)]
che = [list(map(int, input().split())) for _ in range(M)]
for i in range(N):
	dis = []
	for k in range(M):
		dis.append(abs(stu[i][0] - che[k][0]) + abs(stu[i][1] - che[k][1]))
	shortest = min(dis)
	print(dis.index(shortest) + 1)


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
c = [list(map(int, input().split())) for _ in range(m)]
INF = 10 ** 9 + 7
for i in a:
	ans = INF
	for j in range(m):
		tmp = abs(i[0] - c[j][0]) + abs(i[1] - c[j][1])
		if tmp < ans:
			ans = tmp
			num = j + 1
	print(num)


(n, m) = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
	ans = -1
	num = 10 ** 10
	for j in range(m):
		cnt = abs(a[i][0] - b[j][0]) + abs(a[i][1] - b[j][1])
		if cnt < num:
			ans = j + 1
			num = cnt
	print(ans)


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
	c = 10 ** 10
	e = 0
	for j in range(m):
		d = abs(a[i][0] - b[j][0]) + abs(a[i][1] - b[j][1])
		if d < c:
			c = d
			e = j
	print(e + 1)


(N, M) = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(N)]
C = [list(map(int, input().split())) for _ in range(M)]
for (a, b) in S:
	m = 10 ** 9
	cnt = 0
	for (c, d) in C:
		l = abs(c - a) + abs(d - b)
		cnt += 1
		if m > l:
			m = min(m, l)
			ans = cnt
	print(ans)


(n, m) = [int(x) for x in input().split()]
a = []
for i in range(n):
	a.append([int(x) for x in input().split()])
c = []
for i in range(m):
	c.append([int(x) for x in input().split()])
for i in range(n):
	d = 10 ** 9
	cc = 0
	for j in range(m):
		di = abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1])
		if di < d:
			d = di
			cc = j
	print(cc + 1)


((n, _), *d) = [list(map(int, s.split())) for s in open(0)]
for (i, j) in d[:n]:
	l = [abs(x - i) + abs(y - j) for (x, y) in d[n:]]
	print(l.index(min(l)) + 1)


(N, M) = list(map(int, input().split()))
A = []
B = []
C = []
D = []
for i in range(N):
	(x, y) = list(map(int, input().split()))
	A.append(x)
	B.append(y)
for i in range(M):
	(x, y) = list(map(int, input().split()))
	C.append(x)
	D.append(y)
for i in range(N):
	ans = []
	for j in range(M):
		tmp = abs(A[i] - C[j]) + abs(B[i] - D[j])
		ans.append(tmp)
	T = len(ans)
	for k in range(T):
		if ans[k] == min(ans):
			print(k + 1)
			break


(n, m) = map(int, input().split())
al = []
bl = []
for i in range(n):
	(a, b) = map(int, input().split())
	al.append([a, b])
for j in range(m):
	(c, d) = map(int, input().split())
	bl.append([c, d])

def check(a, b):
	x = a[0] - b[0]
	y = a[1] - b[1]
	if x < 0:
		x = -x
	if y < 0:
		y = -y
	return x + y
for a in al:
	min = 1000000000
	cnt = 1
	for b in bl:
		tmp = check(a, b)
		if tmp < min:
			ans = cnt
			min = tmp
		cnt += 1
	print(ans)


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split())) for i in range(m)]
for i in a:
	cnt = 2 * 10 ** 16
	ans = 0
	for j in range(len(b)):
		if abs(i[0] - b[j][0]) + abs(i[1] - b[j][1]) < cnt:
			cnt = abs(i[0] - b[j][0]) + abs(i[1] - b[j][1])
			ans = j + 1
	print(ans)


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
c = [list(map(int, input().split())) for i in range(m)]
for i in a:
	ans = [abs(i[0] - j[0]) + abs(i[1] - j[1]) for j in c]
	ans_min = min(ans)
	print(ans.index(ans_min) + 1)


(n, m) = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]
for (a, b) in ab:
	l = [abs(a - c) + abs(b - d) for (c, d) in cd]
	print(l.index(min(l)) + 1)


(n, m) = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
	s = 0
	t = float('inf')
	for j in range(m):
		p = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
		if p < t:
			s = j + 1
			t = p
	print(s)


(n, m) = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(m)]
for (a, b) in s:
	k = float('inf')
	f = 0
	for (i, (c, d)) in enumerate(p, start=1):
		t = abs(a - c) + abs(b - d)
		if k > t:
			k = t
			f = i
	print(f)


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
c = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
	bag = []
	for k in range(m):
		bag.append(abs(a[i][0] - c[k][0]) + abs(a[i][1] - c[k][1]))
	ind = bag.index(min(bag))
	print(ind + 1)


(n, m) = map(int, input().split())
sd = []
cp = []
for i in range(n):
	sd.append([int(j) for j in input().split()])
for i in range(m):
	cp.append([int(j) for j in input().split()])
dist = [[0 for i in range(m)] for j in range(n)]
for i in range(n):
	for j in range(m):
		dist[i][j] = abs(sd[i][0] - cp[j][0]) + abs(sd[i][1] - cp[j][1])
for i in range(n):
	print(dist[i].index(min(dist[i])) + 1)


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split())) for i in range(m)]
for i in a:
	t = 10 ** 18
	ans = 0
	c = 1
	for j in b:
		k = abs(i[0] - j[0]) + abs(i[1] - j[1])
		if t > k:
			ans = c
			t = k
		c += 1
	print(ans)


(N, M) = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(N)]
cd = [tuple(map(int, input().split())) for _ in range(M)]
for (a, b) in ab:
	check_point_dist = 10 ** 8 * 4 + 1
	check_point = 0
	count = 0
	for (c, d) in cd:
		count += 1
		if check_point_dist > abs(a - c) + abs(b - d):
			check_point = count
			check_point_dist = abs(a - c) + abs(b - d)
	else:
		print(check_point)


(n, m) = map(int, input().split())
p = [list(map(int, input().split())) for i in range(n)]
c = [list(map(int, input().split())) for i in range(m)]
for i in p:
	cnt = 1
	d = 10 ** 9
	for j in c:
		if abs(i[0] - j[0]) + abs(i[1] - j[1]) < d:
			d = abs(i[0] - j[0]) + abs(i[1] - j[1])
			ans = cnt
		cnt += 1
	print(ans)


(n, m) = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]
r = []
for i in ab:
	(x1, y1) = (i[0], i[1])
	temp = []
	for j in cd:
		(x2, y2) = (j[0], j[1])
		temp.append(abs(x1 - x2) + abs(y1 - y2))
	r.append(temp.index(min(temp)) + 1)
print(*r, sep='\n')


(n, m) = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(n)]
c = [list(map(int, input().split())) for _ in range(m)]

def dist(p1, p2):
	return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])
for i in range(n):
	x = min(c, key=lambda x: dist(p[i], x))
	num = c.index(x) + 1
	print(num)


(N, M) = map(int, input().split())
A = [map(int, input().split()) for _ in range(N)]
C = [list(map(int, input().split())) for _ in range(M)]
for (a, b) in A:
	print(min([(i, abs(c - a) + abs(d - b)) for (i, (c, d)) in enumerate(C, 1)], key=lambda x: x[1])[0])


def d(x, y):
	return abs(x[0] - y[0]) + abs(x[1] - y[1])
(n, m) = map(int, input().split())
x = [tuple(map(int, input().split())) for i in range(n)]
y = [tuple(map(int, input().split())) for i in range(m)]
for i in range(n):
	p = 0
	for j in range(1, m):
		if d(x[i], y[j]) < d(x[i], y[p]):
			p = j
	print(p + 1)


f = lambda k: [list(map(int, input().split())) for _ in range(k)]
(n, m) = map(int, input().split())
lln = f(n)
llm = f(m)
for (a, b) in lln:
	(mi, p) = (10 ** 9, m)
	for (i, [c, d]) in enumerate(llm):
		di = abs(c - a) + abs(d - b)
		if di < mi:
			(mi, p) = (di, i + 1)
	print(p)


(N, M) = map(int, input().split())
stu = [0] * N
for i in range(N):
	stu[i] = list(map(int, input().split()))
cp = [0] * M
for i in range(M):
	cp[i] = list(map(int, input().split()))
stumo = [0] * N
for i in range(N):
	min_move = 10000000000000000000000000
	for j in range(M):
		min_his = min_move
		mhd = abs(stu[i][0] - cp[j][0]) + abs(stu[i][1] - cp[j][1])
		min_move = min(min_move, mhd)
		if min_move != min_his:
			stumo[i] = j + 1
for i in range(N):
	print(stumo[i])


(N, M) = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
CD = [list(map(int, input().split())) for _ in range(M)]
result = []
for (a, b) in AB:
	tmp = []
	for (c, d) in CD:
		tmp.append(abs(a - c) + abs(b - d))
	result.append(tmp.index(min(tmp)) + 1)
for r in result:
	print(r)