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):
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 a,b in AB:
  md = 10 ** 9
  nearest = -1
  for i in range(M):
    c,d = CD[i]
    d = abs(a-c) + abs(d-b)
    if d < md:
      nearest = i+1
      md = d
  ANS.append(nearest)
  
print('\n'.join(map(str,ANS)))

Solution (Python):
N,M = map(int,input().split())
A = [0]*N
B = [0]*N
C = [0]*M
D = [0]*M
result = [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):
	Cnt = 0
	Dist = float('inf')
	x = A[i]
	y = B[i]
	for j in range(M):
		if abs(x-C[j])+abs(y-D[j]) < Dist:
			
			Dist = abs(x-C[j])+abs(y-D[j])
			Cnt = j+1
	result[i]=Cnt
 
for i in range(N):
	print(result[i])

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




for i in range(N):
    a, b = ab[i]
    tmp = float('inf')
    p = -1
    for j in range(M):
        c, d = cd[j]
        dist = abs(a-c)+abs(b-d)
        if tmp > dist:
            tmp = dist
            p = j+1
    print(p)

Solution (Python):
n, m = map(int, input().split())
ab = []
for i in range(n):
    ab.append(list(map(int, input().split())))
cd = []
for j in range(m):
    cd.append(list(map(int, input().split())))
for i in range(n):
    a, b = ab[i]
    min_d = 10**10
    for j in range(m):
        c, d = cd[j]
        if min_d > abs(a - c) + abs(b - d):
            min_d = abs(a - c) + abs(b - d)
            check = j+1
    print(check)

Solution (Python):
N,M = map(int,input().split())
A = [0]*N
B = [0]*N
C = [0]*M
D = [0]*M
result = [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):
	Cnt = 0
	Dist = float('inf')
	x = A[i]
	y = B[i]
	for j in range(M):
		if abs(x-C[j])+abs(y-D[j]) < Dist:
			
			Dist = abs(x-C[j])+abs(y-D[j])
			Cnt = j+1
	result[i]=Cnt

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7


n,m=MI()
stu=[]
che=[]
for i in range(n):
    stu.append(LI())
for j in range(m):
    che.append(LI())
for i in range(n):
    mini=inf
    num=0
    for j in range(m):
        l=abs(che[j][0]-stu[i][0])+abs(che[j][1]-stu[i][1])
        
        if l<mini:
            mini=l
            num=j+1
    print(num)

Solution (Python):
import sys

input = sys.stdin.readline

def main():
    n,m = map(int, input().split())
    a = [0]*n
    b = [0]*n
    c = [0]*m
    d = [0]*m
    ans = [1]*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):
        temp = abs(a[i]-c[0]) + abs(b[i]-d[0])
        for j in range(1,m):
            cur = abs(a[i]-c[j]) + abs(b[i]-d[j])
            if temp > cur:
                temp = cur
                ans[i] = j+1
        print(ans[i])

if __name__ == '__main__':
    main()

Solution (Python):
import sys

input = sys.stdin.readline

def main():
    n,m = map(int, input().split())
    s = []
    p = []
    min = [10**12]*n
    ans = [0]*n
    for _ in range(n):
        s.append(list(map(int, input().split())))
    for _ in range(m):
        p.append(list(map(int, input().split())))
    for i in range(n):
        a, b = s[i]
        for j in range(m):
            c,d  = p[j]
            md = abs(a-c) + abs(b-d)
            if md < min[i]:
                min[i] = md
                ans[i] = j+1
    for i in ans:
        print(i)

if __name__ == '__main__':
    main()

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


def read():
    N, M = map(int, input().strip().split())
    AB = list()
    for i in range(N):
        a, b = map(int, input().strip().split())
        AB.append((a, b))
    CD = list()
    for i in range(M):
        c, d = map(int, input().strip().split())
        CD.append((c, d))
    return N, M, AB, CD


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


def solve(N, M, AB, CD):
    checkpoints = list()
    for a, b in AB:
        min_checkpoint = 0
        min_d = 10**9
        for j, (c, d) in enumerate(CD):
            d = distance(a, b, c, d)
            if d < min_d:
                min_d = d
                min_checkpoint = j + 1
        checkpoints.append(min_checkpoint)
    for c in checkpoints:
        print(c)


if __name__ == '__main__':
    inputs = read()
    solve(*inputs)

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

Solution (Python):
n,m=map(int,input().split())
gakusei=[]
for i in range(n):
  gakusei.append(list(map(int,input().split())))
check=[]
for j in range(m):
  check.append(list(map(int,input().split())))
for k in range(0,n):
  minkyori=10**100
  keep=-1
  for l in range(0,m):
    kyori=abs(gakusei[k][0]-check[l][0])+abs(gakusei[k][1]-check[l][1])
    if kyori<minkyori:
      minkyori=kyori
      keep=l
  print(keep+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))

for a, b in ab:
    mi_len = 10**9
    for ind, (c, d) in enumerate(cd):
        l = abs(a-c)+abs(b-d)
        if l<mi_len:
            mi_len = l
            mi_ind = ind+1
    print(mi_ind)

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 a, b in students:
    dist = 4 * 10 ** 8
    ans = 0
    for j in range(m):
        c, d = checkpoints[j]
        tmp = abs(a - c) + abs(b - d)
        if dist > tmp:
            dist = tmp
            ans = j + 1
    print(ans)

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

Solution (Python):
def main():
    n, m = map(int, input().split())
    student = [[int(x) for x in input().split()] for _ in range(n)]
    point = [[int(x) for x in input().split()] for _ in range(m)]
    answer = [0 for _ in range(n)]
    for i, begin in enumerate(student):
        a, b = begin
        dist = float("inf")
        for j, goal in enumerate(point):
            c, d = goal
            if abs(a - c) + abs(b - d) < dist:
                dist = abs(a - c) + abs(b - d)
                answer[i] = j + 1
    print("\n".join(map(str, answer)))


if __name__ == '__main__':
    main()

Solution (Python):
def resolve():
  n, m = map(int, input().split())
  ab = []
  for i in range(n):
    ab.append(list(map(int, input().split())))
  cd = []
  for i in range(m):
    cd.append(list(map(int, input().split())))

  for a in ab:
    ans = 0
    dist = 10000000000
    for i in range(m):
      tmp = abs(a[0] - cd[i][0]) + abs(a[1] - cd[i][1])
      if tmp < dist:
        ans = i+1
        dist = tmp
    print(ans)
  return

if __name__ == "__main__":
  resolve()

Solution (Python):
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, M = (int(i) for i in input().split())
    AB = [[int(i) for i in input().split()] for j in range(N)]
    CD = [[int(i) for i in input().split()] for j in range(M)]
    for a, b in AB:
        ansD = 10**9
        ans = 0
        for j, cd in enumerate(CD):
            curD = abs(a - cd[0]) + abs(b - cd[1])
            if curD < ansD:
                ansD = curD
                ans = j+1
        print(ans)


if __name__ == '__main__':
    main()

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

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

for s in S:
    a,b=s
    now=0
    dis=10**9

    for t in C:
        c,d,n=t
        D=abs(c-a)+abs(d-b)
        
        if D<dis:
            dis=D
            now=n
    print(now)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,m=map(int, input().split())
    lp=[list(map(int, input().split())) for i in range(n)]
    lb=[list(map(int, input().split())) for i in range(m)]

    for x in range(n):
        kyorimin=4*10**8
        ans=m
        for y in range(m):
            kyori = abs(lp[x][0] - lb[y][0]) + abs(lp[x][1] - lb[y][1])
            if kyori<kyorimin:
                kyorimin=kyori
                ans=y+1
        print(ans)
resolve()

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 x, y in students:
    distance = float('inf')

    for i in range(M):
        gx, gy = checkpoints[i][0], checkpoints[i][1]
        tmp_dis = abs(x - gx) + abs(y - gy)
        if tmp_dis < distance:
            distance = tmp_dis
            ans = i + 1
    print(ans)

Solution (Python):
n,m = map(int,input().split())
a,c = [],[]
for _ in range(n):
    a.append(list(map(int,input().split())))
for _ in range(m):
    c.append(list(map(int,input().split())))
li = []
for i in range(n):
    min_distance = 1000000000000
    min_j = 0
    for j in range(m):
        if abs(a[i][0]-c[j][0]) + abs(a[i][1]-c[j][1]) < min_distance:
            min_distance = abs(a[i][0]-c[j][0]) + abs(a[i][1]-c[j][1])
            min_j = j+1
    li.append(min_j)
for i in range(n):
    print(li[i])

Solution (Python):
n,m = map(int, input().split())
stud = [list(map(int, input().split())) for _ in range(n)]
goal = [list(map(int, input().split())) for _ in range(m)]
for x,y in stud:
    ansd = float("inf")
    for i in range(m):
        x2,y2 = goal[i][0],goal[i][1]
        d = abs(x-x2) + abs(y-y2)
        if d < ansd:
            ans = i+1
            ansd = 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)]

p = [float("INF")] * n
check = [""]*n
for i in range(n):
    for j in range(m):
        if abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]) < p[i]:
            p[i] = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
            check[i] = j+1
for s in check: print(s)

Solution (Python):
def dist(x,y):
    return abs(x[0]-y[0])+abs(x[1]-y[1])
N,M = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
B = [list(map(int,input().split())) for _ in range(M)]
for i in range(N):
    ind = 0
    dmin = 10**9
    for j in range(M-1,-1,-1):
        if dist(A[i],B[j])<=dmin:
            ind = j+1
            dmin = dist(A[i],B[j])
    print(ind)

Solution (Python):
import sys
def main():
    input = sys.stdin.readline
    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)]
    ans=[0]*N
    for i in range(N):
        a,b=S[i]
        tmp=10**10
        for j in range(M):
            c,d=C[j]
            if tmp > abs(a-c)+abs(b-d):
                tmp = abs(a-c)+abs(b-d)
                ans[i]=j+1
    for i in range(N):
        print(ans[i])

if __name__ == '__main__':
    main()

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, (ai, bi) in enumerate(ab):
    ans = 0
    dist_min = 1000000007
    for j, (cj, dj) in enumerate(cd):
        dist_tmp = abs(ai - cj) + abs(bi - dj)
        if dist_min > dist_tmp:
            ans = j + 1
            dist_min = dist_tmp
    
    print(ans)

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 j in range(M)]

ans = [0]*N

for i, x in enumerate(ab):
    a, b = x
    D = 10**9
    for j, y in enumerate(cd):
        c, d = y
        dis = abs(a-c) + abs(b-d)
        if dis < D:
            D = dis
            ans[i] = j + 1

print(*ans, sep='\n')

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:
    x = z = 10**9
    for i,(c,d) in enumerate(CD):
        dist = abs(a-c) + abs(b-d)
        if dist < x:
            x = dist
            z = i+1
    print(z)

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(i[0] - j[0]) + abs(i[1] - j[1]))
    print(l.index(min(l)) + 1)

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

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

ans = []

for i in range(n):
    a, b = ab[i]
    res = [0, float('inf')]
    for j in range(m):
        c, d = cd[j]
        dis = abs(a - c) + abs(b - d)
        if dis < res[1]:
            res = [j + 1, dis]
    ans.append(res[0])

for k in ans:
    print(k)

Solution (Python):
import numpy as np
N, M = map(int, input().split())
a, b = np.array([input().split() for _ in range(N)], dtype=int).T
c, d = np.array([input().split() for _ in range(M)], dtype=int).T

dx = np.subtract.outer(a, c)
dy = np.subtract.outer(b, d)
dist = np.abs(dx) + np.abs(dy)
ans = np.argmin(dist, axis=1)+1
print(*ans, sep="\n")

Solution (Python):
n,m=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(n):
  A,B=map(int,input().split())
  a.append(A)
  b.append(B)
for i in range(m):
  C,D=map(int,input().split())
  c.append(C)
  d.append(D)
for i in range(n):
  minimum=1000000000
  ans=0
  for j in range(m):
    if abs(a[i]-c[j])+abs(b[i]-d[j])<minimum:
      minimum=abs(a[i]-c[j])+abs(b[i]-d[j])
      ans=j+1
  print(ans)

Solution (Python):
N, M = map(int,input().split())
st = [[] for _ in range(N)]
cp = [[] for _ in range(M)]
for i in range(N):
    a, b = map(int,input().split())
    st[i] = [a, b]
for j in range(M):
    c, d = map(int,input().split())
    cp[j] = [c, d]
for i in range(N):
    ne = 10**12
    p = 0
    for j in range(M):
        dis = abs(st[i][0]-cp[j][0])+abs(st[i][1]-cp[j][1])
        if dis < ne:
            p = j
            ne = dis
    print(p+1)

Solution (Python):
n, m = map(int, input().split())
students = [list(map(int,input().split())) + [float('inf'), -1] for _ in range(n)]
for i in range(m):
    x, y = map(int,input().split())
    for stu in students:
        dist = abs(stu[0]-x) + abs(stu[1]-y) 
        if dist < stu[2]: stu[2], stu[3] = dist, i+1
for stu in students: print(stu[3])

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

def distance(list1,list2):
    return abs(list1[0]-list2[0]) + abs(list1[1]-list2[1])

for i in range(n):
    student = s_list[i]
    distance_list = []
    for j,c in enumerate(c_list):
        dist = distance(student,c)
        distance_list.append(dist)
    print(distance_list.index(min(distance_list))+1)

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

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

ans = [] 
for i in range(n):
    mn = 10**9
    idx = 0
    for j in range(m):
        p = abs(stu[i][0] - chp[j][0]) + abs(stu[i][1] - chp[j][1])
        if p < mn:
            mn = p
            idx = j + 1
    print(idx)

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

ab = []
cd = []

A = 0
B = 1
C = 0
D = 1

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 _ab in ab:
    dis = []
    for _cd in cd:
        dis.append(abs(_ab[A] - _cd[C]) + abs(_ab[B] - _cd[D]))
    print(dis.index(min(dis)) + 1)

Solution (Python):
n,m=map(int,input().split())
student=[]
for i in range(n):
    s=list(map(int,input().split()))
    student.append(s)
point=[]
for j in range(m):
    p=list(map(int,input().split()))
    point.append(p)

manh=[]
for k in range(n):
    for l in range(m):
        x=abs(student[k][0]-point[l][0])
        y=abs(student[k][1]-point[l][1])
        manh.append([x+y])
    
    print(manh.index(min(manh))+1)
    manh=[]

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

def main():
    N, M = map(int, readline().rstrip().split())
    AB = [list(map(int, readline().rstrip().split())) for _ in range(N)]
    CD = [list(map(int, readline().rstrip().split())) for _ in range(M)]
    for a, b in AB:
        dist = 10**10
        ans = -1
        for i, (c, d) in enumerate(CD):
            if abs(a-c) + abs(b-d) < dist:
                dist = abs(a-c) + abs(b-d)
                ans = i + 1
        print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N, M = map(int, input().split())
    AB = []
    CD = []
    for _ in range(N):
        a, b = map(int, input().split())
        AB.append((a,b))

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

    for i in range(N):
        a = AB[i][0]
        b = AB[i][1]
        d_min = INF
        index = 0
        for j, cd in enumerate(CD):
            c = cd[0]
            d = cd[1]
            d = abs(a-c) + abs(b-d)
            if d<d_min:
                d_min = d
                index = j+1
        print(index)



if __name__ == '__main__':
    main()

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

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

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

  
for i in S:
  ans = 0
  D = 10**16
  for idx,j in enumerate(T):
    if D > abs(i[0]-j[0])+abs(i[1]-j[1]):
      D = abs(i[0]-j[0])+abs(i[1]-j[1])
      ans = idx + 1
  print(ans)

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())
for i in range(N):
    minnum = float('inf')
    for j in range(M):
        if minnum > abs(a[i]-c[j]) + abs(b[i]-d[j]):
            minnum = abs(a[i]-c[j]) + abs(b[i]-d[j])
            ans = 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)]
for i in range(N):
    ans = 0
    dis = 10**9
    for j in range(M):
        if dis > abs(a[i][0]-c[j][0]) + abs(a[i][1]-c[j][1]):
            ans = j+1
            dis = abs(a[i][0]-c[j][0]) + abs(a[i][1]-c[j][1])
    print(ans)

Solution (Python):
import numpy as np
N, M = map(int, input().split())
s = np.array([[int(v) for v in input().split()] for _ in range(N)])
c = np.array([[int(v) for v in input().split()] for _ in range(M)])

for i in range(N):
    print(np.argmin(np.sum(np.abs(s[i] - c), axis=1)) + 1)

Solution (Python):
def resolve():
    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 ab in AB:
        dist = float("inf")
        point = None
        for i, cd in enumerate(CD):
            if dist > abs(ab[0]-cd[0])+abs(ab[1]-cd[1]):
                dist = abs(ab[0]-cd[0])+abs(ab[1]-cd[1])
                point = i+1
        print(point)


if '__main__' == __name__:
    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 student in ab:
    minimum = 1e+9
    for i, check in enumerate(cd):
        distance = abs(student[0] - check[0]) + abs(student[1] - check[1])
        if minimum > distance:
            ans = i+1
            minimum = distance
    print(ans)

Solution (Python):
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def lcm(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm, numbers, 1)


def gcd_list(numbers):
    return reduce(gcd, numbers)


def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True



def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P


def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret



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




for i in range(n):
    x1, y1 = a[i], b[i]
    d1 = INF
    ans = 0
    for j in range(m):
        x2 = c[j]
        y2 = d[j]
        d2 = abs(x1 - x2) + abs(y1 - y2)
        
            
        if d1 > d2:
            ans = j + 1
            d1 = d2
    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):
    ans = 0
    ans_dis = float("inf")
    for j in range(M):
        distance = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if distance < ans_dis:
            ans = j + 1
            ans_dis = distance
    print(ans)

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

ANS = [[] for _ in range(n)]
for i, (a,b) in enumerate(AB,1):
    ans = 10**9
    for j, (c,d) in enumerate(CD,1):
        dst = abs(a-c) + abs(b-d)
        if dst < ans:
            ans = dst
            ANS[i-1] = j
for a in ANS:
    print(a)

Solution (Python):
import sys

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 = [0 for _ in range(n)]

for i in range(n):
    dis = sys.maxsize
    for j in range(m):
        abs_dis = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if dis > abs_dis:
            ans[i] = j + 1
            dis = abs_dis

for n in range(len(ans)):
    if n == len(ans) - 1:
        print(ans[n], end="")
    else:
        print(ans[n])

Solution (Python):

n,m = map(int,input().split())
students = [list(map(int,input().split())) for _ in range(n)]
points = [list(map(int,input().split())) for _ in range(m)]
def manhattan(s,points):
    lst = []
    for i in points:
        lst.append(abs(s[0] - i[0]) + abs(s[1] - i[1]))
    return lst.index(min(lst))+1

for i in students:
    print(manhattan(i,points))

Solution (Python):
def func(x1,y1,x2,y2):
    return abs(x1-x2)+abs(y1-y2)
n,m = map(int,input().split())
g = [list(map(int,input().split())) for _ in range(n)]
c = [list(map(int,input().split())) for _ in range(m)]
index = 0
for k in g:
    num = 10**9
    for i,d in enumerate(c):
        tmp = func(k[0],k[1],d[0],d[1])
        if tmp < num:
            num = tmp
            index = i
    print(index+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 x1,y1 in ab:
    tmp = float('inf')
    ans = None
    for num,xy2 in enumerate(cd):
        x2 = xy2[0]
        y2 = xy2[1]
        dist = abs(x1-x2)+abs(y1-y2)
        if dist < tmp:
            tmp = dist
            ans = num + 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)]
ans=[]

for i in range(N):
  dmin=2*10**8
  cnum=0
  for j in range(M):
    d=abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1])
    if d<dmin:
      dmin=d
      cnum=j
  ans.append(cnum+1)
print(*ans)