Problem:
 Score : 200 points    Problem Statement 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 1 2 2
2 0
0 0
-1 0
1 0      Sample Output 1 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 .       Sample Input 2 3 4
10 10
-10 -10
3 3
1 2
2 3
3 5
3 5      Sample Output 2 3
1
2  There can be multiple checkpoints at the same coordinates.       Sample Input 3 5 5
-100000000 -100000000
-100000000 100000000
100000000 -100000000
100000000 100000000
0 0
0 0
100000000 100000000
100000000 -100000000
-100000000 100000000
-100000000 -100000000      Sample Output 3 5
4
3
2
1

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())

    init = []
    for _ in range(N):
        a, b = map(int, input().split())
        init.append((a, b))

    check = []
    for _ in range(M):
        c, d = map(int, input().split())
        check.append((c, d))

    for i in init:
        pos = 0
        dist = 10**9
        x0, y0 = i[0], i[1]
        for j in range(M):
            x1, y1 = check[j][0], check[j][1]
            if abs(x0 - x1) + abs(y0 - y1) < dist:
                pos = j + 1
                dist = abs(x0 - x1) + abs(y0 - y1)

        print(pos)


if __name__ == '__main__':
    main()

Solution (Python):
N,M=map(int,input().split())
a_list=[]
b_list=[]
for i in range(N):
    a,b=map(int,input().split())
    a_list.append(a)
    b_list.append(b)
    
c_list=[]
d_list=[]
for i in range(M):
    c,d=map(int,input().split())
    c_list.append(c)
    d_list.append(d)

for i in range(N):
    sum=1000000000
    for j in range(M):
        key=abs(a_list[i]-c_list[j])+abs(b_list[i]-d_list[j])
        if sum>key:
            ans=j+1
            sum=key
    print(ans)

Solution (Python):
N,M=map(int,input().split())
st=[list(map(int,input().split())) for i in range(N)]
ch=[list(map(int,input().split())) for i in range(M)]
for s in st:
    Min=1000000000
    Mindex=-1
    for i in range(M):
        if abs(ch[i][0]-s[0])+abs(ch[i][1]-s[1])<Min:
            Min=abs(ch[i][0]-s[0])+abs(ch[i][1]-s[1])
            Mindex=i+1
    print(Mindex)

Solution (Python):
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])

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

Solution (Python):
N, M = map(int, input().split())
a = [0 for i in range(N)]
b = [0 for i in range(N)]
for i in range(N):
	a[i], b[i] = map(int, input().split())
c = [0 for i in range(M)]
d = [0 for i in range(M)]
for i in range(M):
	c[i], d[i] = map(int, input().split())

ans = [1 for i in range(N)]
for i in range(N):
	for j in range(M):
		if abs(a[i]-c[j])+abs(b[i]-d[j]) < abs(a[i]-c[ans[i]-1])+abs(b[i]-d[ans[i]-1]):
			ans[i] = j+1

for i in range(N):
	print(ans[i])

Solution (Python):
import sys

ni = lambda: int(sys.stdin.readline().rstrip())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
INF = 10 ** 9
n, m = nm()
ab = [nl() for i in range(n)]
cd = [nl() for i in range(m)]
ans = []
for i in range(n):
    temp = INF
    a = ab[i][0]
    b = ab[i][1]
    for j in range(m-1, -1, -1):
        c = cd[j][0]
        d = cd[j][1]
        if abs(a - c) + abs(b - d) <= temp:
            temp = abs(a - c) + abs(b - d)
            idx = j + 1
    ans.append(str(idx))
print('\n'.join(ans))

Solution (Python):
n, m = map(int, input().split())
a = []
b = []
for _ in range(n):
    a1, b1 = map(int, input().split())
    a.append([a1, b1])
for _ in range(m):
    c, d = map(int, input().split())
    b.append([c, d])
for a_ in a:
    e = []
    for b_ in b:
        ans = abs(a_[0] - b_[0]) + abs(a_[1] - b_[1])
        e.append(ans)
    print(e.index(min(e))+1)

Solution (Python):
n, m = map(int, raw_input().split())
a = []
c = []
for i in range(n):
	a.append(map(int, raw_input().split()))
for j in range(m):
	c.append(map(int, raw_input().split()))

for i in range(n):
	dist0 = 999999999
	j0 = 999
	for j in range(m):
		dist = abs(a[i][0]-c[j][0]) + abs(a[i][1]-c[j][1])
		if dist < dist0:
			dist0 = dist
			j0 = j
	print j0 + 1

Solution (Python):
n,m = map(int,input().split())
stud = []
for i in range(n):
    a,b = map(int,input().split())
    stud.append([a,b])
dist = [ 1e9 for i in range(n) ]
at = [ 0 for i in range(n) ]
for j in range(m):
    a,b = map(int,input().split())
    for i in range(n):
        d = abs(a - stud[i][0]) + abs(b - stud[i][1])
        if d < dist[i]:
            dist[i] = d
            at[i] = j+1

for i in at:
    print(i)

Solution (Python):
(n,m),*a=[list(map(int,s.split()))for s in open(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)))

Solution (Python):
N, M = map(int, input().split())
students = [tuple(map(int,input().split())) for i in range(N)]
cps = [tuple(map(int,input().split())) for i in range(M)]

def manlen(a,b) :
  return abs(a[0]-b[0])+abs(a[1]-b[1])

for std in students:
  lengths = [manlen(std,cp) for cp in cps]
  bestcp = 1 + lengths.index(min(lengths))
  print(bestcp)

Solution (Python):
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)

Solution (Python):
N, M = map(int, input().split())
ab = []
cd = []
for i in range(N):
    a, b = map(int, input().split())
    ab.append([a, b])

for i in range(M):
    c, d = map(int, input().split())
    cd.append([c, d])

for i in range(N):
    m_min = 100000000000
    i_min = -1
    for j in range(M):
        m = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if m < m_min:
            m_min = m 
            i_min = j
    print(i_min+1)

Solution (Python):
N, M = map(int, input().split())
S = []
C = []

for i in range(N):
    a, b = map(int, input().split())
    S.append((a, b))

for i in range(M):
    c, d = map(int, input().split())
    C.append((c, d))

for si in S:
    ans = -1
    min_ = 10 ** 10
    for i, ci in enumerate(C):
        ds = abs(ci[0] - si[0]) + abs(ci[1] - si[1])
        if ds < min_:
            min_ = ds
            ans = i
    print(ans + 1)

Solution (Python):
N, M = map(int, input().split())
STUDENTS = [tuple(map(int, input().split())) for _ in range(N)]
CHECKPOINTS = [tuple(map(int, input().split())) for _ in range(M)]
for student in STUDENTS:
	L = 10 ** 10
	for i, checkpoint in enumerate(CHECKPOINTS):
		l = abs(checkpoint[0] - student[0]) + abs(checkpoint[1] - student[1])
		if l < L:
			nc = i + 1
			L = l
	print(nc)

Solution (Python):
n,m=map(int,input().split())
hoge_x=[]
hoge_y=[]
huga_x=[]
huga_y=[]
for i in range(n):
  a,b=map(int,input().split())
  hoge_x.append(a)
  hoge_y.append(b)
  
for j in range(m):
  a,b=map(int,input().split())
  huga_x.append(a)
  huga_y.append(b)

for i in range(n):
  ans_kyori=-1
  ans_index=-1
  for j in range(m):
    kyori=abs(hoge_x[i]-huga_x[j])+abs(hoge_y[i]-huga_y[j])
    if(kyori<ans_kyori or ans_kyori==-1):
      ans_kyori=kyori
      ans_index=j+1
  print(ans_index)

Solution (Python):


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())
check = []

for i in range(n):
    min_len = 10000000000
    min_id = 10000000000
    for j in range(m):
        length = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if length < min_len:
            min_len = length
            min_id = j + 1
    check.append(min_id)

for i in range(len(check)):
    print(check[i])

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
def checkpoints(N: int, M: int, students: list, points: list)->list:
    ans = []
    for x, y in students:
        min_d, min_i = float('inf'), 0
        for i, (c, d) in enumerate(points):
            if abs(x-c) + abs(y-d) < min_d:
                min_d = abs(x-c) + abs(y-d)
                min_i = i
        ans.append(min_i)

    return ans


if __name__ == "__main__":
    N = 0
    M = 0
    N, M = map(int, input().split())
    students = [tuple(map(int, input().split())) for _ in range(N)]
    points = [tuple(map(int, input().split())) for _ in range(M)]
    ans = checkpoints(N, M, students, points)

    print('\n'.join(str(i+1) for i in ans))

Solution (Python):

from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007


"""
a,b = LI()
print((a+b)%24)
"""

n,m = LI()
p = LIR(n)
q = LIR(m)
for x,y in p:
    s = 1
    ans = float("inf")
    for i in range(m):
        if abs(x-q[i][0])+abs(y-q[i][1]) < ans:
            ans = abs(x-q[i][0])+abs(y-q[i][1])
            c = i+1
    print(c)

"""
n = I()
ans = int(math.log10(n)+1)
for i in range(2,int(n**0.5)+1):
    if n%i == 0:
        ans = min(ans, max(int(math.log10(i)+1),int(math.log10(n//i)+1)))
print(ans)
"""


"""
n,a,b = LI()
v = LI()
v.sort()
v = v[::-1]
ans = v[:a]
d = {}
d[ans[-1]] = 0
if ans[0] != ans[-1]:
    for i in ans:
        if i == ans[-1]:
            d[i] += 1
    k = d[i]
    d[i] = 0
    for i in v:
        if i == ans[-1]:
            d[i] += 1
    c = 1
    for j in range(min(k,d[ans[-1]]-k)):
        c *= d[ans[-1]]-j
        c //= j+1
else:
    for i in v:
        if i == ans[-1]:
            d[i] += 1
    c = 0
    for k in range(a,min(d[ans[-1]],b)+1):
        p = 1
        for j in range(min(k,d[ans[-1]]-k)):
            p *= d[ans[-1]]-j
            p //= j+1
        c += p
print(sum(ans)/a)
print(c)
"""

Solution (Python):

import numpy as np
N, M = map(int, input().split())

a, b = [0] * N, [0] * N
c, d = [0] * M, [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):
    tmp = []
    for j in range(M):
        tmp.append(abs(a[i] - c[j]) + abs(b[i] - d[j]))
    print(np.argmin(tmp) + 1)

Solution (Python):
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)]
import sys
for st in S:
  n=-1
  z= sys.maxsize
  j=0
  for ch in C:
    mi = abs(st[0] - ch[0]) + abs(st[1] - ch[1])
    j+=1
    
    if z > mi:
      z = mi
      n = j
  print(n)

Solution (Python):
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
    min=100000000000
    for j in range(m):
        dis=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if(min>dis):
            min=dis
            ans=j+1
    print(ans)

Solution (Python):
N, M = map(int, input().split())
students = [list(map(int, input().split())) for _ in range(N)]
checkpoints = [list(map(int, input().split())) for _ in range(M)]
for s in students:
    ans = 10**9
    for i, c in enumerate(checkpoints):
        dis = abs(c[0] - s[0]) + abs(c[1] - s[1])
        if ans > dis:
            ans = dis
            ansi = i
    print(ansi + 1)

Solution (Python):
n,m = map(int,input().split())
listA = [list(map(int, input().split())) for i in range(n)]
listB = [list(map(int, input().split())) for j in range(m)]
listC=[]

for k in range(n):
  b=0
  c=0
  for l in range(m):
    a=abs(listA[k][0]-listB[l][0])+abs(listA[k][1]-listB[l][1])
    if a<b or l==0:
      b=a
      c=l
  print(c+1)

Solution (Python):
N, M = map(int, input().split())
a, b, c, d = [],[],[],[]

for i in range(N):
  ai, bi = map(int, input().split())
  a.append(ai)
  b.append(bi)

for j in range(M):
  cj, dj = map(int, input().split())
  c.append(cj)
  d.append(dj)
  

  
for i in range(N):
  dist, min_dist = 0, 10**9
  ans = 1
  for j in range(M):
    dist = abs(c[j] - a[i]) + abs(d[j] - b[i])
    if dist < min_dist:
      ans = j+1
      min_dist = dist



  print(ans)

Solution (Python):
N, M = map(int, input().split())

S = []
C = []
for i in range(N):
    a, b = map(int, input().split())
    S.append((a,b))
for i in range(M):
    c, d = map(int, input().split())
    C.append((c,d))



for s in S:
    ans = []
    for i,c in enumerate(C):
        d = abs(s[0] - c[0]) + abs(s[1] - c[1])
        ans.append((d,i))
    ans = sorted(ans)
    min_d = ans[0][0]
    ans_last = []
    for j in ans:
        if j[0] == min_d:
            ans_last.append(j[1]+1)
    print(sorted(ans_last)[0])

Solution (Python):
N,M=map(int,input().split())
ab=[[int(i) for i in input().split()] for i in range(N)]
check=[[int(i) for  i in input().split()] for i in range(M)]
for hito in ab:
    curmin=10**9
    goto=0
    for j,point in enumerate(check):
        if abs(point[1]-hito[1])+abs(point[0]-hito[0])<curmin:
            curmin=abs(point[1]-hito[1])+abs(point[0]-hito[0])
            goto=j+1
    print(goto)

Solution (Python):
N, M = list(map(int, input().split()))
St = [input().split() for _ in range(N)]
Ch = [input().split() for _ in range(M)]

for i in range(N):
    memo = []
    for j in range(M):
        diff = abs(int(St[i][0]) - int(Ch[j][0])) + abs(int(St[i][1]) - int(Ch[j][1]))
        memo.append(diff)
    print(memo.index(min(memo)) + 1)

Solution (Python):
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])

Solution (Python):

N,M= map(int,input().split())
AB=[[str(j) for j in input().split()] for i in range(N)]
CD=[[str(j) for j in input().split()] for i in range(M)]

for i in range(0, N):
    min_=10**9
    
    ind = 0
    for j in range(0, M):
        if abs(int(AB[i][0])-int(CD[j][0]))+ abs(int(AB[i][1])-int(CD[j][1])) < min_:
            min_=abs(int(AB[i][0])-int(CD[j][0]))+ abs(int(AB[i][1])-int(CD[j][1]))
            ind_ = j
        
    print(ind_+1)

Solution (Python):
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)

Solution (Python):
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)

Solution (Python):
n,m = (int(i) for i in 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 x1 in ab:
    min_dist = 10**10
    min_idx = 0
    for idx,x2 in enumerate(cd):
        dist = abs(x1[0]-x2[0]) + abs(x1[1]-x2[1])
        if dist < min_dist:
            min_dist = dist
            min_idx = idx
    
    print(min_idx+1)

Solution (Python):
N,M = map(int,input().split())
ab = [[int(i) for i in input().split()] for _ in range(N)]
cd = [[int(i) for i in input().split()] for _ in range(M)]
 
for a,b in ab:
    num = 0
    d = 10**10
    for i in range(M):
        if abs(a-cd[i][0])+abs(b-cd[i][1])<d:
            num = i+1
            d = abs(a-cd[i][0])+abs(b-cd[i][1])
    print(num)

Solution (Python):
n,m=map(int,input().split())
o,p,q,r=[],[],[],[]
def kyori(a,b,c,d):return abs(a-c)+abs(b-d)
for i in range(n):
  a,b=map(int,input().split())
  o.append(a)
  p.append(b)
for i in range(m):
  a,b=map(int,input().split())
  q.append(a)
  r.append(b)
for i in range(n):
  mind=kyori(o[i],p[i],q[0],r[0])
  minn=1
  for j in range(m-1):
    a=kyori(o[i],p[i],q[j+1],r[j+1])
    if a<mind:
      mind=a
      minn=j+2
  print(minn)

Solution (Python):
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 i in range(n):
    res = 10**9+7
    ans = 0
    for j in range(m):
        temp = abs(x[i][0]-y[j][0])+abs(x[i][1]-y[j][1])
        if temp<res:
            res = temp
            ans = j+1
    print(ans)

Solution (Python):
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))

lst = [ [0] * M for _ in range(N)] 
for i in range(N):
    for j in range(M):
        lst[i][j] = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])

for i in range(N):
    print(lst[i].index(min(lst[i])) + 1)

Solution (Python):
n,m = map(int,input().split())

stu = [list(map(int,input().split())) for i in range(n)]

check = [list(map(int,input().split())) for i in range(m)]

mini = [3*10**8]*n
index = [0]*n

for i in range(n):
    for j in range(m):
        dist = abs(stu[i][0]-check[j][0]) + abs(stu[i][1]-check[j][1])
        if dist < mini[i]:
            mini[i] = dist
            index[i] = j+1
    
    
            
for i in index:
    print(i)

Solution (Python):
N,M=map(int,input().split())
stu=[]
che=[]
for i in range(N):
    stu.append(list(map(int,input().split())))
for j in range(M):
    che.append(list(map(int,input().split())))
for i in range(N):
    l=abs(stu[i][0]-che[0][0])+abs(stu[i][1]-che[0][1])
    n=0
    for j in range(1,M):
        ll=abs(stu[i][0]-che[j][0])+abs(stu[i][1]-che[j][1])
        if l>ll:
            l=ll
            n=j
    print(n+1)

Solution (Python):
N,M = map(int,input().split())
sutdent = []
point = []
INF = float("inf")
anss = []
for i in range(N):
    a,b = map(int,input().split())
    sutdent.append((a,b))
for i in range(M):
    c,d = map(int,input().split())
    point.append((c,d))
for a,b in sutdent:
    ans = INF
    index = 0
    for num,(c,d) in enumerate(point):
        count = abs(a-c)+abs(b-d)
        if count<ans:
            ans=count
            index = num+1
    anss.append(index)
for a in anss:
    print(a)

Solution (Python):
n,m=map(int,input().split())
l1=[]
l2=[]
for i in range(n):
  l1.append(list(map(int,input().split())))
for i in range(m):
  l2.append(list(map(int,input().split())))
for i in range(n):
  l=abs(l1[i][0]-l2[0][0])+abs(l1[i][1]-l2[0][1])
  n=0
  for j in range(1,m):
    if l>abs(l1[i][0]-l2[j][0])+abs(l1[i][1]-l2[j][1]):
      l=abs(l1[i][0]-l2[j][0])+abs(l1[i][1]-l2[j][1])
      n=j
    else:
      pass
  print(n+1)

Solution (Python):
import numpy as np


N, M = list(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 s in students:
    measure = []
    for c in checkpoints:
        tmp = abs(c[0]-s[0]) + abs(c[1]-s[1])
        measure.append(tmp)
    print(np.argmin(measure) + 1)

Solution (Python):
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 i in range(n):
  res=1
  d=abs(a_b[i][0]-c_d[0][0])+abs(a_b[i][1]-c_d[0][1])
  for j in range(1,m):
    t=abs(a_b[i][0]-c_d[j][0])+abs(a_b[i][1]-c_d[j][1])
    if t<d:
      d=t
      res=j+1
  print(res)

Solution (Python):
def main():
    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:
        dist = float("inf")
        ans = 0
        for i in range(M):
            c, d = C[i]
            x = abs(a-c) + abs(b-d)
            if x < dist:
                ans = i+1
                dist = x
        print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
N,M = map(int,input().split())
stu = []
cha = []
for _ in range(N):
    a,b = map(int,input().split())
    stu.append([a,b])
for _ in range(M):
    a,b = map(int,input().split())
    cha.append([a,b])
for s in stu:
    ch = 0
    min_d = 1000000000
    for i,c in enumerate(cha):
        d = abs(s[0] - c[0]) + abs(s[1] - c[1])
        if d < min_d:
            ch = i
            min_d = d
    print(ch+1)

Solution (Python):
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)

Solution (Python):
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
from operator import itemgetter

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())

rem = pow(10,9)+7


x,y= (int(i) for i in input().split())       









sa = []
for  i in range(x):
    sa.append([int(i) for i in input().split()])
sb = []
for  i in range(y):
    sb.append([int(i) for i in input().split()])
for i in range(x):
    s = []
    for k in range(y):
        s.append(abs(sa[i][0]-sb[k][0]) + abs(sa[i][1] - sb[k][1]))
    print(s.index(min(s))+1)

Solution (Python):
(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)))

Solution (Python):

(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)))

Solution (Python):
(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)))

Solution (Python):
(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)))

Solution (Python):
from numpy import*;(n,m),*a=[list(map(int,s.split()))for s in open(0).readlines(0)]
for i,j in a[:n]:print(1+argmin([abs(x-i)+abs(y-j)for x,y in a[n:]]))

Solution (Python):
N,M=map(int,input().split())
students=[tuple(map(int,input().split())) for i in range(N)]
point=[tuple(map(int,input().split())) for i in range(M)]
inf=float('inf')
for n in students:
    ans=0
    Min=inf
    for j in range(M):
        if abs(n[0]-point[j][0])+abs(n[1]-point[j][1])<Min:
            ans=j+1
            Min=abs(n[0]-point[j][0])+abs(n[1]-point[j][1])
    print(ans)

Solution (Python):
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)]

s = []
t = []

for i in range(n):
    for j in range(m):
        s.append(abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1]))
    t.append(s.index(min(s)) + 1)
    s = []

for i in range(len(t)):
    print(t[i])

Solution (Python):
n,m = map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]
ans = [0] * n
det = [400000001]*n
for i in range(m):
    c, d = map(int, input().split())
    for p in range(n):
        dif = abs(c-x[p][0])+abs(d-x[p][1])
        if det[p] > dif:
            ans[p] = i
            det[p] = dif
for i in ans:
    print(i+1)

Solution (Python):
N, M = [ int(x) for x in input().split() ]
ab_s = [ [ int(x) for x in input().split() ] for _ in range(N) ]
cds = [ [ int(x) for x in input().split() ] for _ in range(M) ]

ans = []
for i in range(N):
    a, b = ab_s[i]
    r = -1
    d_min = -1
    for j in range(M):
        c, d = cds[j]
        distance = abs(a - c) + abs(b - d)
        if d_min < 0 or d_min > distance:
            r = j
            d_min = distance
    ans.append(r + 1)

print("\n".join(map(str, ans)))

Solution (Python):
n, m = map(int, input().split())
ab = [tuple(int(x) for x in input().split()) for _ in range(n)]
cd = [tuple(int(x) for x in input().split()) for _ in range(m)]

for a, b in ab:
    ans = 1
    d = abs(a - cd[0][0]) + abs(b - cd[0][1])
    for i in range(1, m):
        temp_d = abs(a - cd[i][0]) + abs(b - cd[i][1])
        if temp_d < d:
            d = temp_d
            ans = i + 1
    print(ans)

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

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

Solution (Python):
n,m=map(int,input().split())
student=[]
check=[]
for i in range(n):
    a,b=map(int,input().split())
    student.append([a,b])
for i in range(m):
    a,b=map(int,input().split())
    check.append([a,b])
for i in student:
    minimam=10**10
    point=0
    for j in range(m):
        if abs(i[0]-check[j][0])+abs(i[1]-check[j][1]) < minimam:
            minimam=abs(i[0]-check[j][0])+abs(i[1]-check[j][1])
            point = j+1
    print(point)

Solution (Python):
n,m = map(int,input().split())
a,b = [[] for i in range(n)],[[] for i in range(n)]
c,d = [[] for i in range(m)],[[] for i in range(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())

check = [[] for i in range(m)]
for i in range(n):
    for j in range(m):
        check[j] = abs(a[i]-c[j])+abs(b[i]-d[j])
    print(check.index(min(check))+1)

Solution (Python):
N, M = map(int, input().split())
student = [list(map(int, input().split())) for _ in range(N)]
chpoint = [list(map(int, input().split())) for _ in range(M)]
ans = []
for i in range(N):
    mdisstance_tmp = float('inf')
    ans_tmp = 0
    for j in range(M):
        mdistance = abs(student[i][0]-chpoint[j][0])+abs(student[i][1]-chpoint[j][1])
        if mdisstance_tmp > mdistance:
            mdisstance_tmp = mdistance
            ans_tmp = j+1
    ans.append(ans_tmp)

for i in ans:
    print(i)

Solution (Python):
n, m = list(map(int, input().split()))
Students = [tuple(map(int, input().split())) for i in range(n)]
CheckPoints = [tuple([i] + list(map(int, input().split()))) for i in range(m)]

for student in Students:
    ManhattanDistanceList = []
    for point in CheckPoints:
        sx, sy = student
        px, py = point[1], point[2]
        ManhattanDistanceList.append(
            tuple([point[0], abs(sx - px) + abs(sy - py)]))
    ManhattanDistanceList.sort(key=lambda x: x[1])
    print(ManhattanDistanceList[0][0]+1)

Solution (Python):
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)

Solution (Python):
n,m=[int(i) for i in input().split()]
ab=[]
cd=[]
for i in range(n):
    a,b=[int(j) for j in input().split()]
    ab.append((a,b))

for i in range(m):
    c,d=[int(j) for j in input().split()]
    cd.append((c,d))

for i in range(n):
    mini=10000000000000000
    for j in range(m):
        dis=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if mini>dis:
            mini=dis
            point=j+1
    print(point)

Solution (Python):
N, M = map(int, input().split())
ab = []
cd = []
for i in range(N):
    ab.append(list(map(int,input().split())))

for i in range(M):
    cd.append(list(map(int,input().split())))

for sx,sy in ab:
    dist_min = float('inf')
    num_min = -1
    for i in range(M):
        tmp = abs(sx-cd[i][0]) + abs(sy-cd[i][1])
        if dist_min > tmp:
            num_min = i + 1
            dist_min = tmp
    print(num_min)

Solution (Python):
""" AtCoder """

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):
    min_len = 1000000000
    for j in range(M):
        tmp = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if min_len > tmp:
            ans = j+1
            min_len = tmp
    print(ans)