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
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]




n,m=mii()

arr =[]
for i in range(n):
    a,b=mii()
    arr.append([a,b])
mat = []
for i in range(m):
    c,d=mii()
    mat.append([c,d])
ans=[]
for i,j in arr:
    num = 10**100
    c1,c2=0,0
    cnt=0
    p=0
    for c,d in mat:
        cnt+=1
        if abs(i-c)+abs(j-d) <num:
            c1,c2=c,d
            num = abs(i-c)+abs(j-d)
            p=cnt
            
    ans.append(p)

print(*ans)

Solution (Python):




n, m = map(int,input().split())

stds = list()
chkp = list()

for i in range(n):
    ab = list(map(int,input().split()))
    stds.append(ab)

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


for i in range(n):
    mindist = 10**9
    ans = -1
    for j in range(m):
        dist = abs(chkp[j][0] - stds[i][0]) + abs(chkp[j][1] - stds[i][1])
        if dist < mindist:
            mindist = dist
            ans = j + 1

    
    print(ans)

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

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)

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

def dist(a,b,c,d):
    return abs(a-c)+abs(b-d)

for a,b in ab:
    idx = 0
    for i in range(m):
        if dist(a,b,cd[i][0],cd[i][1]) < dist(a,b,cd[idx][0],cd[idx][1]):
            idx = i
    print(idx+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):
    distance = abs(a[i] - c[0]) + abs(b[i] - d[0])
    check = 0
    for j in range(1,m):
        temp = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if distance > temp:
            distance = temp 
            check = j
    print(check + 1)

Solution (Python):
def distance(a,b,c,d):
  return abs(a-c)+abs(b-d)

N,M=map(int, input().split())
Alist = []
Blist = []
for i in range(N):
  a,b=map(int, input().split())
  Alist.append(a)
  Blist.append(b)
Clist = []
Dlist = []
for i in range(M):
  c,d=map(int, input().split())
  Clist.append(c)
  Dlist.append(d)

for i in range(N):
  min_d = 10**10
  a = Alist[i]
  b = Blist[i]
  for k in range(M):
    c = Clist[k]
    d = Dlist[k]
    if min_d > distance(a,b,c,d):
      min_d = distance(a,b,c,d)
      kiroku = k

  print(kiroku+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)]
for i in range(n):
    dmin = abs(stu[i][0] - che[0][0]) + abs(stu[i][1] - che[0][1])
    ans = 1
    for j in range(1, m):
        d = abs(stu[i][0] - che[j][0]) + abs(stu[i][1] - che[j][1])
        if d < dmin:
            ans = j + 1
            dmin = d
    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)]

ans = []
for i in range(n):
    nearest = 10**9
    idx = None
    for j in range(m):
        a, b = ab[i]
        c, d = cd[j]
        if abs(a-c)+abs(b-d) < nearest:
            nearest = abs(a-c)+abs(b-d)
            idx = j+1
    ans.append(idx)
for i in range(len(ans)):
    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)]
min = 5e+8
c = 0

for i in range(n):
    for j in range(m):
        d = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if d<min:
            min=d
            c = j+1
    min = 5e+8
    print(c)

Solution (Python):
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):
    ans = 0
    min = 10 ** 20
    for j in range(m):
        dis = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if min > dis:
            min = dis
            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())

import numpy as np
for i in range(n):
    min_distance = np.inf
    checkpoint = 0
    for j in range(m):
        distance = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if distance == min_distance:
            checkpoint = min(checkpoint, j)
        elif distance < min_distance:
            checkpoint = j
            min_distance = distance
    print(checkpoint + 1)

Solution (Python):
n, m = map(int,input().split())
ab_l = []
for _ in range(n):
    ab_l.append(list(map(int,input().split())))
cd_l = []
for _ in range(m):
    cd_l.append(list(map(int,input().split())))
ans_l = [0]*n

for i in range(n):
    distance_min = float('inf')
    for j in range(m):
        distance = abs(ab_l[i][0]-cd_l[j][0]) + abs(ab_l[i][1]-cd_l[j][1])
        if distance < distance_min:
            distance_min = distance
            ans_l[i] = j+1

for val in ans_l:
    print(val)

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 A:
  D=[abs(i[0]-j[0])+abs(i[1]-j[1]) for j in C]
  print(D.index(min(D))+1)

Solution (Python):
import sys

from itertools import accumulate

def readlines(n):
    for _ in range(n):
        x, y = map(int, input().split())
        yield x, y

def main():
    n, m = map(int, input().split())
    
    stu = list(readlines(n))
    check = list(readlines(m))
    
    def distances(a, b):
        for i, cd in enumerate(check, 1):
            c, d = cd
            yield abs(a - c) + abs(b - d), i

    for a, b in stu:
        yield str(min(distances(a, b))[1])



print("\n".join(main()))

Solution (Python):
def resolve():
	n, m = map(int, input().split())
	a, b = [-1]*n, [-1]*n
	c, d = [-1]*m, [-1]*m
	ans = []
	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):
		low_i = -1
		low_v = float('inf')
		for j in range(m):
			v = abs(a[i] - c[j]) + abs(b[i] - d[j])
			if v < low_v:
				low_v = v
				low_i = j
		ans.append(low_i+1)
	for i in ans:
		print(i)
resolve()

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):
    tmp = []
    for j in range(M):
        tmp.append(abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]))
    print(tmp.index(min(tmp))+1)

Solution (Python):
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):
    ans = 10000000000000
    for j in range(m):
        x = abs(a[i][0]-b[j][0]) + abs(a[i][1]-b[j][1])
        if x < ans:
            ans = x
            y = j
    print(y+1)

Solution (Python):









import numpy as np






N,M = map(int,input().split())
times = N
AB = []
for _ in range(times):
    AB.append(list(map(int,input().split()))) 
times = M
CD = []
for _ in range(times):
    CD.append(list(map(int,input().split()))) 

AB = np.array(AB)
CD = np.array(CD)
for ab in AB:
    arr = np.sum(abs(ab-CD),axis=1)
    
    print(np.argmin(arr)+1)

Solution (Python):
def myAnswer(N:int,M:int,A:list,B:list,C:list,D:list) ->int:
   for a,b in zip(A,B):
      ans = 10**10
      no = 0
      for n in range(M):
         c = C[n]
         d = D[n]
         distance = abs(a - c) + abs(b - d)
         if(ans > distance):
            ans = distance
            no = n+1
      print(no)


def modelAnswer():
   return
def main():
   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)
   myAnswer(N,M,A[:],B[:],C[:],D[:])

if __name__ == '__main__':
   main()

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,m = iim()

pe = []
ch = []
for i in range(n):
    pe.append(iil())

for j in range(m):
    ch.append(iil())

for k in pe:
    dist = 1000000000
    point = 0
    for ind,l in enumerate(ch):
        if abs(k[0]-l[0])+abs(k[1]-l[1]) < dist:
            dist = abs(k[0]-l[0])+abs(k[1]-l[1])
            point = ind+1
    print(point)

Solution (Python):
def resolve():
    '''
    code here
    '''
    N, M = [int(item) for item in input().split()]
    students = [[int(item) for item in input().split()] for _ in range(N)]
    cps = [[int(item) for item in input().split()] for _ in range(M)]

    for i in range(N):
        min_dist = 10**9
        min_dist_index = 0
        for j in range(M):
            x_dist = abs(students[i][0] - cps[j][0])
            y_dist = abs(students[i][1] - cps[j][1])
            man_dist = x_dist + y_dist

            if min_dist > man_dist:
                min_dist = man_dist
                min_dist_index = j

        print(min_dist_index+1)

if __name__ == "__main__":
    resolve()

Solution (Python):
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):
    ans = -1
    MIN = float('inf')
    for j in range(M):
        a, b = students[i]
        c, d = points[j]
        if MIN > abs(a-c) + abs(b-d):
            MIN = abs(a-c) + abs(b-d)
            ans = j + 1
    print(ans)

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:
    l = []
    for j in cd:
        l.append(abs((j[0]-i[0])) + abs((j[1]-i[1])))
    print(l.index(min(l)) + 1)

Solution (Python):
import numpy as np
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)]

dist = np.zeros((n, m))
for i in range(n):
  for j in range(m):
    dist[i, j] = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])

for dis in dist:
  print(dis.argmin()+1)

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

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

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

def MD(P1,P2):
  return (abs(P1[0]-P2[0])+abs(P1[1]-P2[1]))

for i in range(N):
  Min_D = int(10e10)
  for j in range(M):
    D = MD(S[i],C[j])
    if Min_D > D:
      Min_D = D
      P = j+1
  print(P)

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

for i in range(N):
    now_x, now_y = s_locs[i]
    closest_cp_idx = None
    min_dist = float("inf")
    for j in range(M):
        dist = abs(c_locs[j][0]-now_x) + abs(c_locs[j][1]-now_y)
        if dist < min_dist:
            min_dist = dist
            closest_cp_idx = j+1
    print(closest_cp_idx)

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):
    seq_min = 1e9
    ans = -1
    for j in range(m):
        seq = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if seq_min > seq:
            seq_min = seq
            ans = j
    print(ans + 1)

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

a = []
b = []
c = []
d = []
for i in range(n):
    ax, by = map(int, input().split())
    a.append(ax)
    b.append(by)
for i in range(m):
    cx, dy = map(int, input().split())
    c.append(cx)
    d.append(dy)

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

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

Solution (Python):
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 a,b in ab:
    kyori=1000000007
    ans=0
    for i,v in enumerate(cd):
        now=abs(a-v[0])+abs(b-v[1])
        if kyori>now:
            kyori=now
            ans=i
    print(ans+1)

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:
    l = []
    for j in cd:
        l.append(abs((j[0] - i[0])) + abs((j[1] - i[1])))
    print(l.index(min(l)) + 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 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)

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


def f(a, b, c, d):
    return abs(a - c) + abs(b - d)


for a, b in AB:
    v, idx = 10**10, 0
    for i, (c, d) in enumerate(CD, start=1):
        
        d = f(a, b, c, d)
        if v > d:
            idx = i
            v = d
    print(idx)

Solution (Python):
def Distance(t_a,t_b):
    return abs(t_a[0]-t_b[0]) + abs(t_a[1]-t_b[1])

n,m = map(int,input().split(' '));
students = []
for p in range(n):
    students.append(tuple(map(int,input().split(' '))))
check = []
for q in range(m):
    check.append(tuple(map(int,input().split(' '))))
ans = ''
for s in students:
    dmin = Distance(s, check[0])
    dindex = 0
    i = 1
    while i < m:
        d0 = Distance(s, check[i])
        if d0 < dmin:
            dmin = d0
            dindex = i
        i += 1
    ans += str(dindex+1) + '\n'
print(ans)

Solution (Python):
n, m = map(int, input().split())
list_AB = [ list(map(int,input().split(" "))) for i in range(n)]
list_CD = [ list(map(int,input().split(" "))) for i in range(m)]
ans = [[0, pow(10, 12)] for _ in range(n)]

for i, l in enumerate(list_AB):
    a = l[0]
    b = l[1]
    for j, k in enumerate(list_CD):
        c = k[0]
        d = k[1]
        if abs(a-c) + abs(b-d) < ans[i][1]:
            ans[i][1] = abs(a-c) + abs(b-d)
            ans[i][0] = j + 1

for i in range(n):
    print(ans[i][0])

Solution (Python):
n, m = map(int, input().split())
students = []
checkpoints = []
for _ in range(n):
    students.append(tuple(map(int, input().split())))
for _ in range(m):
    checkpoints.append(tuple(map(int, input().split())))

ans = []
for a, b in students:
    curr_d = 10 ** 10
    curr_i = 0
    for i, (c, d) in enumerate(checkpoints, start=1):
        dist = abs(a - c) + abs(b - d)
        if dist < curr_d:
            curr_d = dist
            curr_i = i
    ans.append(curr_i)

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

Solution (Python):
n, m = map(int, input().split())
stu = []
for i in range(n):
    stu.append(list(map(int, input().split())))
chk = []
for i in range(m):
    chk.append(list(map(int, input().split())))
    
for i in range(n):
    near = 10**10
    for j in range(m):
        mht = abs(stu[i][0]-chk[j][0])+abs(stu[i][1]-chk[j][1])
        if near > mht:
            near = mht
            idx = j
    print(idx+1)

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

P = []
C = []

for i in range(N):
    P += [[int(x) for x in input().split()]]
    
for i in range(M):
    C += [[int(x) for x in input().split()]]

for i in range(N):
    d_min = abs(P[i][0] - C[0][0]) + abs(P[i][1] - C[0][1])
    c_min = 1
    for j in range(M):
        d = abs(P[i][0] - C[j][0]) + abs(P[i][1] - C[j][1])
        if d < d_min:
            d_min = d
            c_min = j+1
    print(c_min)

Solution (Python):
N, M = map(int,input().split())
s = [list(map(int,input().split())) for k in range(N)]
p = [list(map(int,input().split())) for k in range(M)]
ans = []
for e in s:
    temp = float("inf")
    u = 0
    for k in range(M):
        if temp > abs(e[0]-p[k][0]) + abs(e[1]-p[k][1]):
            temp = abs(e[0]-p[k][0]) + abs(e[1]-p[k][1])
            u = k+1
    ans.append(u)
print(*ans,sep="\n")

Solution (Python):
import numpy as np
n,m=map(int,input().split())
x=np.ones((n,2))
y=np.ones((m,2))

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

for i in range(m):
    y[i]=list(map(int,input().split()))
    
def m_d(a,b):
    return(abs(a[0]-b[0])+abs(a[1]-b[1]))

for i in range(n):
    d=[]
    for j in range(m):
        d.append(m_d(x[i],y[j]))
                 
    print(d.index(min(d))+1)

Solution (Python):
import sys  
import numpy as np

input = sys.stdin.readline
N, M= map(int, input().split())
AB = []
for i in range(N):
    a, b = list(map(int, input().split()))
    AB.append([a, b])

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


for i in range(N):
    leng = []
    for j in range(M):
        temp = abs(AB[i][0]-CD[j][0]) + abs(AB[i][1]-CD[j][1])
        leng.append(temp)
    for k in range(len(leng)):
        if leng[k] == min(leng):
            print(k+1)
            break

Solution (Python):
n,m=map(int,input().split())
a=[list(map(int,input().split())) for a in range(n)]
c=[list(map(int,input().split())) for b in range(m)]
dist=0
minnum=0
for indi,i in enumerate(a):
    min=10**10
    minnum=0
    for indj,j in enumerate(c):
        dist=0 
        dist+=abs(i[0]-j[0])
        dist+=abs(i[1]-j[1])
        
        if min>dist:
            min=dist
            minnum=indj
    print(minnum+1)

Solution (Python):
n,m=map(int,input().split())
a=[list(map(int,input().split())) for a in range(n)]
c=[list(map(int,input().split())) for b in range(m)]
dist=0
minnum=0
for indi,i in enumerate(a):
    min=abs(i[0]-c[0][0])+abs(i[1]-c[0][1])
    minnum=0
    for indj,j in enumerate(c):
        dist=0 
        dist+=abs(i[0]-j[0])
        dist+=abs(i[1]-j[1])
        
        if min>dist:
            min=dist
            minnum=indj
    print(minnum+1)

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

for a, b in s:
    ans_num = 0
    ans_dist = 1000000007
    for i in range(len(check_points)):
        x, y = check_points[i]
        dist = abs(a - x) + abs(b - y)
        if dist < ans_dist:
            ans_num = i + 1
            ans_dist = dist
    print(ans_num)

Solution (Python):
icase=0
if icase==0:
    n,m=map(int,input().split())
    a=[]
    for i in range(n):
        xi,yi=map(int,input().split())
        a.append([xi,yi])
    c=[]
    for i in range(m):
        xi,yi=map(int,input().split())
        c.append([xi,yi])
    for i in range(n):
        idsmin=10**9
        ip=51
        for ii in range(m-1,-1,-1):
            ids=abs(a[i][0]-c[ii][0])+abs(a[i][1]-c[ii][1])

            if ids<=idsmin:
                idsmin=ids
                ip=ii+1
        print(ip)

Solution (Python):
n , m = map(int,input().split())
p = []
q = []
for i in range(n):
    x = list(map(int,input().split()))
    p.append(x)
for j in range(m):
    y = list(map(int,input().split()))
    q.append(y)
for a,b in p:
    cou = 0
    ans = 0
    kar = 10**9
    for c,d in q:
        cou += 1
        if (abs(a-c)+abs(b-d)) < kar:
            ans = cou
            kar = (abs(a-c)+abs(b-d))
    print(ans)

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

Solution (Python):
n,m=map(int,input().split())
A=[[0,0]for i in range(n)]
B=[[0,0] for i in range(m)]
E=[1]*n
for i in range(n):
    A[i][0],A[i][1]=map(int,input().split())
for i in range(m):
    B[i][0],B[i][1]=map(int,input().split())
for i in range(n):
    c=abs(A[i][0]-B[0][0])+abs(A[i][1]-B[0][1])
    for j in range(1,m):
        if abs(A[i][0]-B[j][0])+abs(A[i][1]-B[j][1])<c:
            c=abs(A[i][0]-B[j][0])+abs(A[i][1]-B[j][1])
            E[i]=j+1
for i in range(n):
    print(E[i])

Solution (Python):
def main():
    from itertools import starmap

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

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

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

    def dist(t1, t2):
        return sum(starmap(lambda a, b: abs(a - b), zip(t1, t2)))

    ans = []
    for s_ in s:
        d = 4 * 10 ** 8 + 1
        idx = -1
        for i, p_ in enumerate(p):
            t = dist(s_, p_)
            if t < d:
                d = t
                idx = i
        ans.append(idx + 1)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main()

Solution (Python):
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:
    ret = -1
    dis = 10**20
    for i, x in enumerate(cd):
        c, d = x
        if dis > abs(c-a) + abs(d-b):
            dis = abs(c-a) + abs(d-b)
            ret = i
    print(ret+1)

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

Solution (Python):
def resolve():
    n,m=map(int,input().split())
    ab=[]
    check=[]
    for i in range(n):
        tmp=list(map(int,input().split()))
        ab.append(tmp)
    for i in range(m):
        tmp=list(map(int,input().split()))
        check.append(tmp)
    for i in range(n):
        num=1
        ans=1000000000
        for j in range(m):
            len=abs(ab[i][0]-check[j][0])+abs(ab[i][1]-check[j][1])
            if ans>len:
                tmp=num
                ans=len
            num+=1
        print(tmp)
resolve()

Solution (Python):
import numpy as np
N,M = list(map(int,input().split()))
XY = []
D = []
for n in range(N):
  XY.append(tuple(map(int,input().split())))

for m in range(M):
  D.append(tuple(map(int,input().split())))

XY = np.array(XY)
D = np.array(D)
for i in np.argmin(np.sum(np.abs(XY[:,None,:] - D[None,:,:]),axis=2),axis=1):
  print(i+1)

Solution (Python):
import numpy as np
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)]
ans = 0
starts =np.array(a)
goals = np.array(b)

for start in range(n):
    dist = 10000000000
    ans = 0
    for goal in range(m):
        if dist > abs(goals[goal][0]-starts[start][0]) + abs(goals[goal][1]-starts[start][1]):
            dist = abs(goals[goal][0]-starts[start][0]) + abs(goals[goal][1]-starts[start][1])
            ans = goal+1
    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 i in range(n):
    tmp = float("inf")
    ans = 0
    y = float("inf")
    for j in range(m):
        x = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if x < tmp or x == tmp and i < y:
            tmp = x
            ans = j + 1
            y = i
    print(ans)

Solution (Python):
n,m = map(int,input().split())
student = []
check = []
for i in range(n):
    ab = [int(i) for i in input().split()]
    student.append(ab)
for j in range(m):
    cd = [int(i) for i in input().split()]
    check.append(cd)
mn = 10**13
for ax,by in student:
    for i in range(m):
        dist = abs(ax-check[i][0]) + abs(by-check[i][1])
        if mn > dist:
            ans = i+1
            mn = dist
    print(ans)
    mn = 10**13

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

l_ans = [] 
for i in range(N):
  a,b = ln[i][0],ln[i][1]
  dis = float("inf")
  ch = 0
  for j in range(M):
    c,d = lm[j][0],lm[j][1]
    if dis > abs(a-c)+abs(b-d):
      dis = abs(a-c)+abs(b-d)
      ch = j+1
  l_ans.append(ch)

for i in l_ans:
  print(i)

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

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

INF = 10 ** 8 * 4
for s in ss:
    dist = INF
    c_point = 0
    a, b = s
    for i, v in enumerate(p):
        c, d = v
        manhattan = abs(a - c) + abs(b - d)
        if manhattan < dist:
            c_point = i + 1
            dist = manhattan
    print(c_point)

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

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

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

for i in range(0,N):
    a,b=student[i]
    ans=10**20
    anscheck=0
    for j in range(0,M):
        c,d=checkpoint[j]
        if ans>abs(a-c)+abs(b-d):
            anscheck=j
            ans=abs(a-c)+abs(b-d)

    print(anscheck+1)

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)]
def d(x,y):
    return abs(x[0]-y[0])+abs(x[1]-y[1])
for i in a:
    ans=10101001010
    ch=0
    for j in range(m):
        if d(i,c[j])<ans:
            ch=j
            ans=d(i,c[j])
    print(ch+1)

Solution (Python):
n,m=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(n):
  tmp_a,tmp_b=map(int,input().split())
  a.append(tmp_a)
  b.append(tmp_b)
for i in range(m):
  tmp_c,tmp_d=map(int,input().split())
  c.append(tmp_c)
  d.append(tmp_d)

import numpy as np
c=np.array(c)
d=np.array(d)

for i in range(n):
    tmp_x=a[i]
    tmp_y=b[i]
    dis_arr=(abs(c - tmp_x)+abs(d - tmp_y)).tolist()
    print(dis_arr.index(min(dis_arr))+1)

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

for x in range(N):
    min_y = 0
    min_value = 10**12
    for y in range(M):
        distance = abs(n_student[x][0] - m_point[y][0]) + \
            abs(n_student[x][1] - m_point[y][1])
        if distance < min_value:
            min_value = distance
            min_y = y + 1
    print(min_y)

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

chk = []
for i in range(M):
    a, b = map(int, input().split())
    chk.append((a, b))

ans = [0] * N

for i in range(N):
    jdg = float("INF")
    for k in range(M):
        a, b = sdt[i]
        c, d = chk[k]
        if jdg > abs(a-c)+abs(b-d):
            ans[i] = k+1
            jdg = abs(a-c)+abs(b-d)

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