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








def resolve():
    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:
        valmin=10**5
        cnt=0
        l=[]
        for j in B:
            l.append(abs(i[0]-j[0])+abs(i[1]-j[1]))
        print(l.index(min(l))+1)





resolve()

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 i in range(M):
    c[i],d[i]=map(int,input().split())
def route(n):
    array=[]
    for i in range(M):
        k=abs(a[n]-c[i])+abs(b[n]-d[i])
        array.append(k)
    e=array.index(min(array))
    return e
for i in range(N):
    print(route(i)+1)

Solution (Python):
n,m=map(int,input().split())
a=[0]*n
b=[0]*n
c=[0]*m
d=[0]*m
ans=[0]*n

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):
    dis=[-1]*3
    for j in range(m):
        dis[1]=abs(a[i]-c[j])+abs(b[i]-d[j])
        if (dis[0]<0):
            ans[i]=j+1
            dis[2]=dis[1]
        else:
            if (dis[2]>dis[1]):
                ans[i]=j+1
                dis[2]=dis[1]
        dis[0]=dis[1]
for i in range(n):
    print(ans[i])

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

Solution (Python):











mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    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())
    cd = [0] * m
    for i in range(m):
        cd[i] = list(map(int,input().split()))
    for i in range(n):
        ans = m+1
        l = INF
        for j in range(m):
            if abs(a[i]-cd[j][0])+abs(b[i]-cd[j][1])<l:
                ans = j+1
                l = abs(a[i]-cd[j][0])+abs(b[i]-cd[j][1])
            elif abs(a[i]-cd[j][0])+abs(b[i]-cd[j][1])==l:
                ans = min(ans,j+1)
        print(ans)
    return

if __name__=='__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline

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

def main():
    mod=10**9+7
    N,M=MI()
    a=[0]*N
    b=[0]*N
    c=[0]*M
    d=[0]*M
    
    for i in range(N):
        aa,bb=MI()
        a[i]=aa
        b[i]=bb
        
    for i in range(M):
        cc,dd=MI()
        c[i]=cc
        d[i]=dd
        
    def calc(x1,y1,x2,y2):
        return abs(x2-x1)+abs(y2-y1)
    
    def s_calc(x,y):
        temp=10**10
        pos=-1
        for i in range(M):
            l=calc(x,y,c[i],d[i])
            if temp>l:
                temp=l
                pos=i+1
                
        return pos
    
    for i in range(N):
        print(s_calc(a[i],b[i]))
            

main()

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

Solution (Python):

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 i in range(n):
    a,b=ab[i]
    ans=10**9
    ans_index=-1
    for j in range(m):
        c,d=cd[j]
        if ans>abs(c-a)+abs(d-b):
            ans=abs(c-a)+abs(d-b)
            ans_index=j+1
    print(ans_index)

Solution (Python):
n, m = map(int, input().split())
stu = []
check = []
for i in range(n):
    stu.append(list(map(int, input().split())))
for i in range(m):
    check.append(list(map(int, input().split())))
for i in stu:
    min_dis = 4 * 10 ** 8 + 1
    for j, k in enumerate(check):
        dis = abs(i[0] - k[0]) + abs(i[1] - k[1])
        if dis < min_dis:
            ans = j + 1
            min_dis = dis
    print(ans)

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 ab in AB:
  ind = 1
  ans = 1
  dist = float('inf')
  for cd in CD:
    temp_dist = abs(ab[0]-cd[0])+abs(ab[1]-cd[1])
    if temp_dist<dist:
      ans = ind
      dist = temp_dist
    ind += 1
  print(ans)

Solution (Python):
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 i in range(N):
  ans = 10**10
  ansIndex = -1
  for j in range(M):
    tmp = abs(X[i][0]-Y[j][0])+abs(X[i][1]-Y[j][1])
    if tmp < ans:
      ans = tmp
      ansIndex = j
  print(ansIndex+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)]

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

for x in ab:
    idx=0
    for i in range(M):
        if dist(x,cd[i]) < dist(x,cd[idx]):
            idx=i
    print(idx+1)

Solution (Python):
import sys
from io import StringIO
import unittest

doTest=0

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    n,m=list(map(int, readline().strip().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, readline().strip().split()))
    for i in range(m):
        c[i],d[i]=list(map(int, readline().strip().split()))

    for i in range(n):
        minDiff=999999999
        minpnt=9999999
        for j in range(m):
            diff=abs(a[i]-c[j])+abs(b[i]-d[j])
            if diff < minDiff:
                minDiff = diff
                minpnt=j
        print(minpnt+1)
    return

if doTest==0:
    resolve()
    sys.exit()

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 i in range(M):
    c[i],d[i] = map(int,input().split())

for i in range(N):
    mindif = 10**9
    ans = -1
    for j in range(M):
        dif = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if (mindif > dif):
            mindif = dif
            ans = j
    print(ans+1)

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

for i in range(N):
    MIN = 10**9
    for j in range(M):
        if abs(a[i]-c[j])+abs(b[i]-d[j]) < MIN:
            MIN = abs(a[i]-c[j])+abs(b[i]-d[j])
            cnt = j+1
    print(cnt)

Solution (Python):
from numpy import array
student=[]
point=[]
N,M=map(int,input().split())
for z in range(N):
    a,b=map(int,input().split())
    A=array([a,b])
    student.append(A)
for y in range(M):
    c,d=map(int,input().split())
    C=array([c,d])
    point.append(C)
for e in student:
    list=[]
    for f in point:
        g=e-f
        i=0
        for h in g:
            i+=abs(h)
        list.append(i)
    j=min(list)
    count=0
    for k in list:
        if  k==j:
            print(count+1)
            break
        else:
            count+=1

Solution (Python):


N, M = map(int, input().split())

stu_list = []
for i in range(N):
    stu = list(map(int, input().split()))
    stu_list.append(stu)

chkpoint_list = []
for i in range(M):
    chkpoint = list(map(int, input().split()))
    chkpoint_list.append(chkpoint)

INF = 1000000000
for stu in stu_list:
    min_distance = INF
    for m in range(M):
        distance = abs(chkpoint_list[m][0] - stu[0]) + abs(chkpoint_list[m][1] - stu[1])

        if distance < min_distance:
            min_distance = distance
            ans = m + 1

    print(ans)

Solution (Python):
n, m = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(n)]
t = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
    a, b = 10 ** 9, 0
    for j in range(m):
        c = abs(s[i][0] - t[j][0]) + abs(s[i][1] - t[j][1])
        if c < a:
            a = c
            b = j
    print(b + 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):
    nearest = 100000000000
    ans = 0
    for j in range(m):
        dis = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if dis < nearest:
            ans = j+1
            nearest = dis
    print(ans)

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

hito = [list(map(int, input().split())) for i in range(n)]
point = [list(map(int, input().split())) for j in range(m)]

for k in range(n):
    min_ten = abs(point[0][0]-hito[k][0])+abs(point[0][1]-hito[k][1])
    min_num = 1
    for p in range(1, m):
        kyori = abs(point[p][0]-hito[k][0])+abs(point[p][1]-hito[k][1])
        if kyori < min_ten:
            min_ten = kyori
            min_num = p+1
    print(min_num)

Solution (Python):
n, m = map(int, input().split())
hito = [list(map(int, input().split())) for i in range(n)]
point = [list(map(int, input().split())) for j in range(m)]
kekka = []
for k in range(n):
    min_ten = abs(point[0][0]-hito[k][0])+abs(point[0][1]-hito[k][1])
    min_num = 1
    for p in range(1, m):
        kyori = abs(point[p][0]-hito[k][0])+abs(point[p][1]-hito[k][1])
        if kyori < min_ten:
            min_ten = kyori
            min_num = p+1
    kekka.append(min_num)
for r in kekka:
    print(r)

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

Solution (Python):
n, m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
p = [list(map(int, input().split())) for i in range(m)]
for i in range(n):
    min_l = 1000000000
    index = 0
    for j in range(m):
        d = abs(l[i][0] - p[j][0]) + abs(l[i][1] - p[j][1])
        if min_l > d:
            min_l = d
            index = j
    print(index + 1)

Solution (Python):

import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, M: int, a: "List[int]", b: "List[int]", c: "List[int]", d: "List[int]"):
    for ai, bi in zip(a, b):
        ans = mindist = None
        for j in range(M):
            dist = abs(ai - c[j]) + abs(bi - d[j])
            if mindist is None or dist < mindist:
                ans = j + 1
                mindist = dist
        print(ans)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    a = [int()] * (N)  
    b = [int()] * (N)  
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    c = [int()] * (M)  
    d = [int()] * (M)  
    for i in range(M):
        c[i] = int(next(tokens))
        d[i] = int(next(tokens))
    solve(N, M, a, b, c, d)


if __name__ == '__main__':
    main()

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

def kyori(X,Y):
    return abs(X[0]-Y[0])+abs(X[1]-Y[1])

def near_p(hito):
    temp = []
    for _ in range(m):
        temp.append(kyori(hito,M[_]))
    return temp.index(min(temp))+1

for i in range(n):
    print(near_p(N[i]))

Solution (Python):
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):
  x,y = a[i]
  
  count = 0
  l = abs(x-c[0][0]) + abs(y-c[0][1])
  for j in range(m):
    
    p,q = c[j]
    
    if l > abs(x-p) + abs(y-q):
      l = abs(x-p)+abs(y-q)
      count = j
      
  print(count+1)

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

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

dist = [0] * m

for a, b in ab:
    dist = [0] * m
    for j in range(m):
        dist[j] = abs(a-cd[j][0]) + abs(b-cd[j][1])
    ans = dist.index(min(dist)) + 1
    print(ans)

Solution (Python):
n,m = map(int, input().split())
stu,check = [],[]
for i in range(n):
    stu.append(list(map(int, input().split())))
for i in range(m):
    check.append(list(map(int, input().split())))
for i in range(n):
    dist = float("inf")
    ind = 0
    for j in range(m):
        x = abs(stu[i][0]-check[j][0])+ abs(stu[i][1]-check[j][1])
        if x < dist:
            ind = j
            dist = x
    print(ind+1)

Solution (Python):
n,m = map(int,input().split())
nx = []
ny = []
mx = []
my = []

for i in range(n):
    a,b = map(int,input().split())
    nx.append(a)
    ny.append(b)
    
for i in range(m):
    c,d = map(int,input().split())
    mx.append(c)
    my.append(d)
    
for i in range(n):
    man = []
    for j in range(m):
        k = abs(nx[i]-mx[j])+abs(ny[i]-my[j])
        man.append(k)
    print(man.index(min(man))+1)

Solution (Python):


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):
    x,y = a[i]
    
    count = 0
    l = abs(x-c[0][0]) + abs(y-c[0][1])
    for j in range(m):
        
        p,q = c[j]
        
        if l > abs(x-p)+abs(y-q):
            l = abs(x-p)+abs(y-q)
            count = j
    print(count+1)

Solution (Python):
def dist(a, b):
    return abs(a[0]-b[0]) + abs(a[1]-b[1])
n, m = map(int, input().split())
studs = [list(map(int, input().split())) for _ in range(n)]
checks = [list(map(int, input().split())) for _ in range(m)]
for s in studs:
    min_d = 4 * 10 ** 8 + 1
    min_idx = 0

    for idx, c in enumerate(checks):
        d = dist(s, c)
        if d < min_d:
            min_d = d
            min_idx = idx + 1

        elif d==min_d:
            min_idx = min(min_idx, idx+1)
    print(min_idx)

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

for i in range(N) :
    ansC = M+1
    anslen = 10**10
    for j in range(M) :
        Manh = abs(Sab[i][0] - Cab[j][0]) + abs(Sab[i][1] - Cab[j][1])
        if Manh < anslen :
            ansC = j+1
            anslen = Manh
    print(ansC)

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):
  l,ans=pow(10,9),0
  for j in range(m):
    x=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
    if l>x:                           
      ans=j+1
    l=min(l,x)
  print(ans)

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

Solution (Python):
n, m = map(int, input().split())
st = [list(map(int, input().split()))for _ in range(n)]
cp = [list(map(int, input().split()))for _ in range(m)]

for a, b in st:
    temp_d = float('inf')
    temp_m = 0
    for i, cd in enumerate(cp):
        c, d = cd
        d = (abs(c - a) + abs(d - b))
        if d < temp_d:
            temp_m = i + 1
            temp_d = d
    print(temp_m)

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

for i in range(M):
    lcd.append(list(map(int,input().split())))
for i in range(N):
    dmin=10**9
    ans=1
    for j in range(M):

        if abs(lab[i][0]-lcd[j][0])+abs(lab[i][1]-lcd[j][1])<dmin:
            
            dmin=abs(lab[i][0]-lcd[j][0])+abs(lab[i][1]-lcd[j][1])
            ans=j+1
    
    
    print(ans)

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

index = 0

for i in range(n):
    ans = 2 * 10 ** 16 + 1
    for j in range(m):
        cnt = abs(a[i]-c[j]) + abs(b[i]-d[j])
        if cnt < ans:
            ans = cnt
            index = j+1
    print(index)

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

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)

Solution (Python):
def d(a, b):
    return abs(a[0] - b[0]) + abs(a[1] - b[1])


n, m = map(int, input().split())
students = {}
check = {}
for i in range(1, n+1):
    x = list(map(int, input().split()))
    students[i] = x

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

for i in range(1, n+1):
    st = students[i]
    b = 10**10
    ans = 0
    for j in range(1, m+1):
        if b > d(st, check[j]):
            b = d(st, check[j])
            ans = j
    print(ans)

Solution (Python):
n,m=map(int,input().split())
nl=[list(map(int,input().split())) for _ in range(n)]
ml=[list(map(int,input().split())) for _ in range(m)]

for i in range(n):
    min_d = 10 ** 9
    near = -1
    for j in range (m):
        if abs(nl[i][0]-ml[j][0])+abs(nl[i][1]-ml[j][1])<min_d:
            near=j+1
            min_d=abs(nl[i][0]-ml[j][0])+abs(nl[i][1]-ml[j][1])
    print(near)

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

Solution (Python):
def main():
    student_num, point_num = map(int, input().split())
    student_location = [tuple(map(int, input().split())) for _ in range(student_num)]
    point_location = [tuple(map(int, input().split())) for _ in range(point_num)]
    answer = [0] * student_num
    for i in range(student_num):
        min_distance = float("inf")
        for j in range(point_num):
            distance = abs(student_location[i][0] - point_location[j][0]) + abs(student_location[i][1] - point_location[j][1])
            if min_distance > distance:
                answer[i] = j + 1
                min_distance = distance
    for ans in answer:
        print(ans)


if __name__ == '__main__':
    main()

Solution (Python):

INF = 10**9
def dist(tuple_a, tuple_b):
    return abs(tuple_a[0] - tuple_b[0]) + abs(tuple_a[1] - tuple_b[1])

def main():
    n, m = map(int, input().split())
    p = []
    for _ in range(n):
        a, b = map(int, input().split())
        p.append((a, b))
    chp = []
    for _ in range(m):
        c, d = map(int, input().split())
        chp.append((c, d))
    ans = []
    for i in range(n):
        tmp = INF
        v = 0
        point = p[i]
        for j in range(m):
            di = dist(point, chp[j])
            if  di < tmp: 
                tmp = di
                v = j
        ans.append(v)
    for i in range(n):
        print(ans[i]+1)
main()

Solution (Python):
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:
    best = float('inf')
    result = -1
    for i in range(M):
        c, d = cd[i]
        t = abs(a - c) + abs(b - d)
        if t < best:
            result = i + 1
            best = t
    print(result)

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

stu_x = {}
stu_y = {}
chk_x = {}
chk_y = {}
for i in range(N):
    stu_x[i], stu_y[i] = map(int, input().split())
for i in range(M):
    chk_x[i], chk_y[i] = map(int, input().split())

for i in range(N):
    X = stu_x[i]
    Y = stu_y[i]
    dis = []
    for j in range(M):
        row = abs(X - chk_x[j])
        col = abs(Y - chk_y[j])

        dis.append(row + col)
    index = dis.index(min(dis)) + 1
    print(index)

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

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)]
for a, b in S:
    dist = [abs(a-c) + abs(b-d) for c, d in C]
    print(dist.index(min(dist))+1)

Solution (Python):
n, m = map(int, input().split())
a = []
b = []
c = []
d = []
for _ in range(n):
  _a, _b = map(int, input().split())
  a.append(_a)
  b.append(_b)

for _ in range(m):
  _c, _d = map(int, input().split())
  c.append(_c)
  d.append(_d)

for i in range(n):
  point = 1
  ans = abs(a[i]-c[0])+abs(b[i]-d[0])
  for j in range(m):
    man = abs(a[i] - c[j]) + abs(b[i] - d[j])
    if ans > man:
      point = j + 1
      ans = man
  print(point)

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

    ST = []
    for _ in range(N):
        ST.append(tuple(map(int, input().split())))

    CP = []
    for _ in range(M):
        CP.append(tuple(map(int, input().split())))

    
    
    

    return N, M, ST, CP


def solve(N, M, ST, CP):
    def get_dist(xy1, xy2):
        x1, y1 = xy1
        x2, y2 = xy2

        return abs(x1 - x2) + abs(y1 - y2)

    res = []
    for st in ST:
        min_cp, min_dist = 0, float("inf")
        for i, cp in enumerate(CP):
            dist = get_dist(st, cp)
            if dist < min_dist:
                min_dist = dist
                min_cp = i
        res.append(min_cp + 1)

    return res


if __name__ == '__main__':
    ans = solve(*args())
    for a in ans:
        print(a)

Solution (Python):
N, M = map(int, input().split())
stdt = []
chpt = []
for _ in range(N):
    a, b = map(int, input().split())
    stdt.append((a, b))
for _ in range(M):
    a, b = map(int, input().split())
    chpt.append((a, b))

for s in stdt:
    a, b, = s[0], s[1]
    m = 100000000000000
    i = 0
    for j in range(M):
        d = abs(a - chpt[j][0]) + abs(b - chpt[j][1])
        if m > d:
            m = d
            i = j + 1
    print(i)

Solution (Python):
n, m = [int(i) for i in 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):
    l = [abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]) for j in range(m)]
    print(l.index(min(l)) + 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)]

for i in range(n):
  a, b = ab[i]
  
  dis = 10 ** 20
  res = 0
  for i, check in enumerate(cd):
    tmp_dis = abs(a - check[0]) + abs(b - check[1])
    if dis == tmp_dis:
      continue
    if tmp_dis < dis:
      dis = tmp_dis
      res = i + 1
  
  print(res)

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:
    n = float('inf')
    ans = 0
    for i, tmp in enumerate(cd):
        c, d = tmp
        m = abs(a-c)+abs(b-d)
        if n > m:
            n = m
            ans = i+1
    print(ans)

Solution (Python):
N,M  = [int(zz) for zz in input().split()]
student = [[int(zz) for zz in input().split()] for _ in range(N)]
checkpoint = [[int(zz) for zz in input().split()] for _ in range(M)]

ans = []
for i in range(N):
    tmp = [0]*M
    for j in range(M):
        tmp[j] = abs(student[i][0]-checkpoint[j][0])+abs(student[i][1]-checkpoint[j][1])
    ans.append(tmp.index(min(tmp)))

[print(i+1) for i in ans]

Solution (Python):
n,m = map(int,input().split())
s = []
p = []
for i in range(n):
  x,y = map(int,input().split())
  s += [(x,y)]
for i in range(m):
  x,y = map(int,input().split())
  p += [(x,y)]

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


for i in range(n):
  ans = 1
  min_d = dist(s[i], p[0])
  for j in range(1, m):
    d = dist(s[i], p[j])
    if d < min_d:
      ans = j+1
      min_d = d
  print(ans)

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

ans = []

for i in a:
  count = 10**10
  check = 0
  for j in range(m):
    if count > abs(i[0]-b[j][0])+abs(i[1]-b[j][1]):
      check = j+1
      count = abs(i[0]-b[j][0])+abs(i[1]-b[j][1])
    
  ans.append(check)
for i in ans:
  print(i)

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

min_dist = 10 ** 10
min_num = M
for i in range(N) :
    for j in range(M) :
        dist = abs(stu_li[i][0] - chk_li[j][0]) + abs(stu_li[i][1] - chk_li[j][1])
        if dist < min_dist : 
            min_dist = dist
            min_num = j
    print(min_num + 1)
    min_dist = 10 ** 10
    min_num = M

Solution (Python):
n,m=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(n):
    a_i,b_i=map(int,input().split())
    a.append(a_i)
    b.append(b_i)
for i in range(m):
    c_i,d_i=map(int,input().split())
    c.append(c_i)
    d.append(d_i)
for i in range(n):
    a_i=a[i]
    b_i=b[i]
    dis=-1
    for j in range(m):
        buf=abs(a_i-c[j])+abs(b_i-d[j])
        if dis<0 or buf<dis:
            dis=buf
            ans=j+1
    print(ans)

Solution (Python):
[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())))
ans=[]
for i in range(n):
    kyorimin=10**9
    for j in range(m):
        kyori=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if kyorimin>kyori:
            goal=j+1
            kyorimin=kyori
    ans.append(goal)
for i in range(len(ans)):
    print(ans[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 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)

Solution (Python):
N, M = map(int, input().split())
people = [list(map(int, input().split())) for i in range(N)]
point = [list(map(int, input().split())) for i in range(M)]
ans = [-1] * N
def calc_dist(a, b):
    return abs(a[0] - b[0]) + abs(a[1] - b[1])


for i in range(len(people)):
    tmp = 1000000000
    for j in range(len(point)):
        dist = calc_dist(people[i], point[j])
        if dist < tmp:
            ans[i] = j
            tmp = dist

for i in ans:
    print(i+1)

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

for i in range(n):
    x = 10**9
    for j in range(m):
        man = abs(stu[i][0] - che[j][0]) + abs(stu[i][1] - che[j][1])
        if man < x:
            c_num = j + 1
            x = man
    ans.append(c_num)
for k in ans:
    print(k)

Solution (Python):
N,M=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
x=[]
y=[]
for i in range(N):
  a_i,b_i=map(int,input().split())
  a.append(a_i)
  b.append(b_i)
for i in range(M):
  c_i,d_i=map(int,input().split())
  c.append(c_i)
  d.append(d_i)
for i in range(N):
  x=[]
  for j in range(M):
    l=abs(a[i]-c[j])+abs(b[i]-d[j])
    x.append(l)
    u=min(x)
    w=x.index(u)+1
  y.append(w)
for k in range(N):
  print(y[k])

Solution (Python):
n,m=map(int,input().split())
lis1 = [list(map(int,input().split())) for _ in range(n)]
lis2 = [list(map(int,input().split())) for _ in range(m)]

def manhattan(lis1,lis2):
    d=0
    for i in range(len(lis1)):
        d+=abs(lis1[i]-lis2[i])
    return d
  
for i in range(n):
    d=3*10**8
    idx=1
    for j in range(m):
        d_new = manhattan(lis1[i],lis2[j])
        if d_new < d:
            d = d_new
            idx = j+1
    print(idx)

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

students = []
for _ in range(n):
    s, t = map(int, input().split())
    students.append((s, t))

xy = []
for _ in range(m):
    x, y = map(int, input().split())
    xy.append((x, y))


for s, t in students:
    MIN = float('infinity')
    checkpoint = 0
    for i in range(len(xy)):
        x, y = xy[i]
        distance = abs(s - x) + abs(t - y)
        if distance < MIN:
            MIN = distance
            checkpoint = i
    print(checkpoint + 1)