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

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007



def m_dist(p,q):
	return abs(p[0]-q[0])+abs(p[1]-q[1])

def gg(pos, ssl):
	mmm=m_dist(pos,ssl[0])
	m_id=0
	for i, q in enumerate(ssl[1:], 1):
		td=m_dist(pos, q)
		if td < mmm:
			mmm = td
			m_id = i
	return m_id
		
def main():
	
	n, m = tin()
	
	pl=[lin() for _ in range(n)]
	ssl = [lin() for _ in range(m)]
	for p in pl:
		r = gg(p, ssl)
		
		print(r+1)
	
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):
def resolve():
    N, M = [int(i) for i in input().split()]
    aabb = [list(map(int, input().split())) for _ in range(N)]
    ccdd = [list(map(int, input().split())) for _ in range(M)]
    for i in range(N):
        a, b = aabb[i]
        minPoint = -1
        minV = 10**9
        for j in range(M):
            c, d = ccdd[j]
            v = abs(a - c) + abs(b - d)
            if v < minV:
                minPoint = j + 1
            minV = min(minV, v)
        print(minPoint)


resolve()

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

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

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

for a, b in S:
    ans = None
    min_dist = 1 << 32
    for i, (c, d) in enumerate(C):
        dist = abs(c - a) + abs(d - b)
        if dist < min_dist:
            min_dist = dist
            ans = i
    print(ans + 1)

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

list_a = []
list_b = []
count = 0

for i in range(N):
    a = [int(i) for i in input().split()]
    list_a.append(a)
    
for i in range(M):
    b = [int(i) for i in input().split()]
    list_b.append(b)
    
for i in range(N):
    ans_x = 10**18
    for j in range(M):
        x = abs(list_a[i][0]-list_b[j][0])
        y = abs(list_a[i][1]-list_b[j][1])
        xxx = x + y
        if xxx < ans_x:
            ans_x = xxx
            count = j+1
    print(count)

Solution (Python):
n,m = map(int,input().split())
ab = [0]*n
cd = [0]*m
for i in range(n):
    ab[i] = list(map(int,input().split()))
for i in range(m):
    cd[i] = list(map(int,input().split())) + [i]
for a,b in ab:
    dis = [0]*m
    for c,d,i in cd:
        dis[i] = [abs(a-c) + abs(b-d)] + [i+1]
    dis.sort(key= lambda val : val[0])
    print(dis[0][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 meter(a, b, c, d):
    return abs(a-c) + abs(b-d)

ans = []

for a, b in ab:
    best_ind = None
    best_dist = float('inf')
    for j, (c, d) in enumerate(cd):
        tmp_dist = meter(a, b, c, d)

        if tmp_dist < best_dist:

            best_dist = tmp_dist
            best_ind = j+1
    print(best_ind)

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):
def getN():
    return int(input())


def getNM():
    return map(int, input().split())


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


from collections import defaultdict, deque, Counter
from sys import exit
import math
import copy
from bisect import bisect_left, bisect_right
from heapq import *
import sys


INF = 10 ** 17
MOD = 1000000007

from fractions import *


def inverse(f):
    
    return 1 / f


def combmod(n, k, mod=MOD):
    ret = 1
    for i in range(n - k + 1, n + 1):
        ret *= i
        ret %= mod

    for i in range(1, k + 1):
        ret *= pow(i, mod - 2, mod)
        ret %= mod

    return ret

MOD = 10 ** 9 + 7

def dist(a, b):
    return abs(a[0] - b[0]) + abs(a[1] - b[1])
def solve():
    n, m = getList()
    st = []
    for i in range(n):
        st.append(getList())

    ch = []
    for i in range(m):
        ch.append(getList())

    for s in st:
        tmp = 10 ** 9
        ans = -1
        for idx, c in enumerate(ch):
            if dist(s, c) < tmp:
                ans = idx + 1
                tmp = dist(s,c)

        print(ans)


def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    solve()

Solution (Python):


LI = lambda: list(map(int, input().split()))


N, M = LI()
AB = [LI() for _ in range(N)]
CD = [LI() for _ in range(M)]

INF = 10 ** 15


def distance(i, j):
    d = abs(AB[i][0] - CD[j][0]) + abs(AB[i][1] - CD[j][1])
    return d


def solve(i):
    
    w = (INF, INF)
    for j in range(M):
        t = (distance(i, j), j + 1)
        w = min(w, t)
    return w[1]


def main():
    for i in range(N):
        ans = solve(i)
        print(ans)
    
    
if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np

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

for i in range(N):
    person = np.asarray(ab[i])
    shortest = 10**18
    for j in range(M):
        point = np.asarray(cd[j])
        diflist = person - point
        dif = abs(diflist[0])+abs(diflist[1])
        if dif < shortest:
            shortest = dif
            count = j+1
    print(count)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    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:
        min_dist = f_inf
        res = 0
        for i in range(m):
            c, d = CD[i]
            dist = abs(a - c) + abs(b - d)
            if min_dist > dist:
                min_dist = dist
                res = i + 1
        print(res)


if __name__ == '__main__':
    resolve()

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    S = [[int(a) for a in input().split()] for _ in range(N)]
    C = [[int(c) for c in input().split()] for _ in range(M)]
    Ans = [1] * N
    for i in range(N):
        a, b = S[i]
        dist = abs(a - C[0][0]) + abs(b - C[0][1])
        for j in range(1, M):
            tdist = abs(a - C[j][0]) + abs(b - C[j][1])
            if tdist < dist:
                dist = tdist
                Ans[i] = j + 1
    print(*Ans, sep="\n")
    return 0

if __name__ == "__main__":
    solve()

Solution (Python):






from collections import defaultdict











import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,m = readInts()
a = [0] * n;b = [0]*n;c = [0] * m;d = [0]*m;
for i in range(n):
    a_,b_ = readInts()
    a[i] = a_;b[i]=b_;
for i in range(m):
    c_,d_ = readInts()
    c[i] = c_;d[i] = d_;
for A,B in zip(a,b):
    MIN = float('inf')
    i = 1
    for C,D in zip(c,d):
        man = abs(C-A) + abs(D-B)
        if man < MIN:
            idx = i
            MIN = man
        i += 1
    print(idx)

Solution (Python):
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor



dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n, m = map(int, input().split())
ab = [0]*n
cd = [0]*m
for i in range(n):
    ab[i] = readints()
for i in range(m):
    cd[i] = readints()


x = []
for i in range(n):
    tmp_li = []
    ans = 10**100
    tmp = 0
    for j in range(m):
        tmp = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        
        
        tmp_li.append(tmp)
    
    x.append(tmp_li.index(min(tmp_li)))

for i in range(len(x)):
    y = x[i]+1
    print(y)

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

Solution (Python):
N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
XY = [tuple(map(int, input().split())) for _ in range(M)]

ans = [0] * N
for i, (a, b) in enumerate(AB):
    d = abs(XY[0][0] - a) + abs(XY[0][1] - b)
    for j, (x, y) in enumerate(XY):
        e = abs(a - x) + abs(b - y)
        if d > e:
            ans[i] = j
            d = e

print(*[a + 1 for a in ans], sep='\n')

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

Solution (Python):
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m=mi()
a =  [list(map(int, input().split())) for i in range(n)]
c =  [list(map(int, input().split())) for i in range(m)]

INF = 100000000000
dis = INF
ans = 0
for i in range(n):
    for j in range(m):
        if abs(a[i][0]-c[j][0]) + abs(a[i][1]-c[j][1]) < dis:
            dis = abs(a[i][0]-c[j][0]) + abs(a[i][1]-c[j][1])
            ans = j+1

    print(ans)
    dis = INF
    ans = 0

Solution (Python):
n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
  x,y=map(int,input().split())
  a.append([x,y])
for i in range(m):
  x,y=map(int,input().split())
  b.append([x,y])
for i in a:
  ans=10**18
  t=0
  for j in range(m):
    if abs(i[0]-b[j][0])+abs(i[1]-b[j][1])<ans:
      t=j+1
      ans=abs(i[0]-b[j][0])+abs(i[1]-b[j][1])
  print(t)

Solution (Python):
n, m = map(int, input().split())
ab = []
for i in range(n):
    ai, bi = map(int, input().split())
    ab.append([ai, bi])
cd = []
for i in range(m):
    ci, di = map(int, input().split())
    cd.append([ci, di])

ans = []
for i in range(n):
    ai, bi = ab[i]
    mini = 10**10
    for j in range(m):
        cj, dj = cd[j]
        dist = abs(ai-cj) + abs(bi-dj)
        if dist < mini:
            mini = dist
            ret = j+1
    ans.append(ret)

for ret in ans:
    print(ret)

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

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

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

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:
    m = min(abs(a-c)+abs(b-d) for c, d in cd)
    
    for i in range(M):
        if abs(a-cd[i][0])+abs(b-cd[i][1])==m:
            print(i+1)
            break

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)]
d = {}
for i in range(n):
    for j in range(m):
        d[j] = abs(s[i][0]-c[j][0])+abs(s[i][1]-c[j][1])
    t = sorted(d.items(), key=lambda x:x[1])
    print(t[0][0]+1)
    d = {}

Solution (Python):
n,m=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
x=[]
y=[]
l=[]
p=[]

for i in range(n):
    ai,bi=map(int,input().split())
    a.append(ai)
    b.append(bi)
    
for j in range(m):
    ci,di=map(int,input().split())
    c.append(ci)
    d.append(di)
    
for i in range(n):
    for j in range(m):
        x.append(abs(a[i]-c[j]))
        y.append(abs(b[i]-d[j]))
        l.append(x[j+i*m]+y[j+i*m])
    
    p.append(l.index(min(l))+1)   
    l=[]
    
    
    
for i in range(n):
    print(p[i])

Solution (Python):
n, m = map(int, input().split())
s = [list(map(int, input().split())) for i in range(n)]
c = [list(map(int, input().split())) for j in range(m)]
for k in range(n):
    x = abs(s[k][0] - c[0][0]) + abs(s[k][1] - c[0][1])
    ans = 1
    for l in range(1, m):
        y = abs(s[k][0] - c[l][0]) + abs(s[k][1] - c[l][1])
        if y < x:
            x = y
            ans = l + 1
        elif y == x:
            x = y
    print(ans)

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

c =[[int(i) for i in input().split()] for j in range(M)]

n = 100000000000
n1 = 0
n2 = 0

for i in range(N):
    for j in range(M):
        n1 = abs(c[j][0] - a[i][0]) + abs(c[j][1] - a[i][1])
        if n1 < n:
            n = n1
            n2 = j
    n = 100000000000
    print(n2 + 1)

Solution (Python):
n,m = map(int,input().split())
a = [tuple(map(int,input().split())) for i in range(n)]
b = [tuple(map(int,input().split())) for i in range(m)]
inf = float("inf")
for ai,bi in a:
    d,num = inf,0
    for i in range(m):
        ci,di = b[i]
        x = abs(ai-ci)+abs(bi-di)
        if d > x:
            d = x
            num = i+1
    print(num)

Solution (Python):
N,M = [int(i) for i in input().split()]
A,B = [],[]
for i in range(N):
    x = [int(i) for i in input().split()]
    A.append(x)
for i in range(M):
    x = [int(i) for i in input().split()]
    B.append(x)

for i in range(N):
    for j in range(M):
        dis = abs(A[i][0] - B[j][0]) + abs(A[i][1] - B[j][1])
        if j == 0:
            min = dis
            tmp = j
        else:
            if dis < min:
                min = dis
                tmp = j
    print(tmp+1)

Solution (Python):

def calc(N, M, student, point) : 
  translatepoint = list()
  for i in range(N) : 
    mindistance = 10 ** 9
    minpoint = -1
    for j in range(M) : 
      distance = abs(student[i][0] - point[j][0]) + abs(student[i][1] - point[j][1])
      if distance < mindistance : 
        mindistance = distance
        minpoint = j + 1
    
    translatepoint.append(minpoint)
  return translatepoint


N, M = tuple(map(int, input().split()))
student = list()
point = list()

for i in range(N) : 
  student.append(tuple(map(int, input().split())))
  
for j in range(M) : 
  point.append(tuple(map(int, input().split())))
  
ans = calc(N, M, student, point)

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

Solution (Python):
def dist(x,y):
  return abs(x[0]-y[0])+abs(x[1]-y[1])

n,m = map(int,input().split())
s = []
for _ in range(n):
  a,b = map(int,input().split())
  s.append((a,b))
c = []
for _ in range(m):
  c_,d = map(int,input().split())
  c.append((c_,d))
for i in range(n):
  p = s[i]
  md = 10**10
  mi = 0
  for j in range(m):
    ch = c[j]
    d = dist(p,ch)
    if md > d:
      md = d
      mi = j
  print(mi+1)

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

students = [[int(i) for i in input().split()] for _ in range(n)]
checkpoints = [[int(i) for i in input().split()] for _ in range(m)]

d = []
for i in range(n) :
    d.clear()
    ans = 0
    for j in range(m) :
        x = abs(students[i][0]-checkpoints[j][0])+abs(students[i][1]-checkpoints[j][1])
        d.append(x)
    ans = d.index(min(d))+1
    print(ans)

Solution (Python):
def list_add(l1, l2):
    tmp = [abs(a-b) for a, b in zip(l1, l2)]
    return tmp



N, M = map(int, input().split())
students = [[int(i) for i in input().split()] for _ in range(N)]
checkpoints = [[int(i) for i in input().split()] for _ in range(M)]

for i in students:
    cur_point = 0
    min_point = 1
    smallest = sum(list_add(i, checkpoints[0]))
    for j in checkpoints:
        cur_point += 1
        sum_li = sum(list_add(i, j))
        if sum_li < smallest:
            smallest = sum_li
            min_point = cur_point
    print(min_point)

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

ans = []
for i in range(n):
  d = {}
  for j in range(m):  
    d[j + 1] = abs(s[i][0] - c[j][0]) + abs(s[i][1] - c[j][1])
  d = sorted(d.items(), key=lambda x:x[1])
  ans.append(d[0][0])
for e in ans:
  print(e)

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



def main():
    N,M = [int(i) for i in input().strip().split()]
    students = [[int(i) for i in input().strip().split()] for _ in range(N)]
    checkpoints = [[int(i) for i in input().strip().split()] for _ in range(M)]
    ans = [0] * N

    for i,student in enumerate(students):
        dist = [float("inf")] * M
        for j, checkpoint in enumerate(checkpoints):
            dist[j] = abs(student[0] - checkpoint[0]) + abs(student[1] - checkpoint[1])
        ans[i] = dist.index(min(dist)) + 1

    return ans


if __name__ == "__main__":
    for n in main():
        print(n)

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):
    x = a[i]
    y = b[i]
    
    for j in range(M):
        
        cx = c[j]
        cy = d[j]
        
        temp = abs(cx-x) + abs(cy-y)
        
        if j==0:
            Min = temp
            result =1
        elif Min > temp:
            result = j+1
            Min = temp
            
            
    print(result)

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

student = list()

for x in range(n):
    student.append(list(map(int, input().split())))

checkpoint = list()

for y in range(m):
    checkpoint.append(list(map(int, input().split())))

INF = 4*(10**8) + 1
tmp = INF
ans = 51

for x in range(n):
    for y in range(m-1, -1, -1):
        distance = abs(student[x][0] - checkpoint[y][0]) + \
            abs(student[x][1] - checkpoint[y][1])

        if tmp >= distance:
            tmp = distance
            ans = y
    print(ans+1)
    tmp = INF

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 a, b in ab:
  cost, idx = 10**18, 0
  for i, (c, d) in enumerate(cd):
    if cost > abs(a - c) + abs(b - d):
      cost = abs(a - c) + abs(b - d)
      idx = i + 1
  print(idx)

Solution (Python):
n, m = map(int, input().split())
a, b, c, d = [], [], [], []
for i in range(n) :
  ai, bi = map(int, input().split())
  a.append(ai), b.append(bi)
for i in range(m) :
  ci, di = map(int, input().split())
  c.append(ci), d.append(di)

for i in range(n) :
  cost, ans = 10**18, 0
  for j in range(m) :
    if cost > abs(a[i] - c[j]) + abs(b[i] - d[j]) :
      cost = abs(a[i] - c[j]) + abs(b[i] - d[j])
      ans = j+1
  print(ans)

Solution (Python):
N,M=map(int,input().split())
students,checks=[],[]
for _ in range(N):
  students.append(list(map(int,input().split())))
  pass
for _ in range(M):
  checks.append(list(map(int,input().split())))
  pass

for i in range(N):
  closed_manhattan=10**16
  closed_j=0
  for j in range(M):
    x=abs(students[i][0]-checks[j][0])
    y=abs(students[i][1]-checks[j][1])
    manhattan=x+y
    if closed_manhattan > manhattan:
      closed_manhattan=manhattan
      closed_j=j+1
  print(closed_j)

Solution (Python):
n,m = map(int,input().split())
ls = [list(map(int,input().split())) for _ in range(n)]
di = [list(map(int,input().split())) for _ in range(m)]
mn = [float("inf")]*n
num = [0]*n
for i in range(n):
    for j in range(m):
        k = abs(ls[i][0]-di[j][0]) + abs(ls[i][1]-di[j][1])
        if k < mn[i]:
            mn[i] = k
            num[i] = j+1
for p in range(n):
    print(num[p])

Solution (Python):

import sys
input = sys.stdin.readline









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

Ans = [-1]*N
for i in range(N):
    a,b = AB[i]
    md0 = 10**10

    for j in range(M):
        c,d = CD[j]
        md = abs(a-c) + abs(b-d)
        if md < md0:
            md0 = md
            Ans[i] = (j+1)

for ans in Ans:
    print(ans)

Solution (Python):
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N, M = map(int, readline().split())
students = []
for _ in range(N):
    a, b = map(int, readline().split())
    students.append((a, b))
flags = []
for _ in range(M):
    c, d = map(int, readline().split())
    flags.append((c, d))



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

ans = [0] * N
distances = [INF] * N
for i, (x1, y1) in enumerate(students):
    for j, (x2, y2) in enumerate(flags):
        dis = calc(x1, y1, x2, y2)
        
        if dis < distances[i]:
            ans[i] = j + 1
            distances[i] = dis

for a in ans:
    print(a)

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

L = []
for i in range(n):
  l = []
  for j in range(m):
    d = abs(A[i][0] - B[j][0]) + abs(A[i][1] - B[j][1])
    l.append(d)
  L.append(l)
  
for i in range(n):
  print(L[i].index(min(L[i]))+1)

Solution (Python):
import numpy as np
s = list(map(int, input().split()))
n=s[0]
m=s[1]
student=[]
check=[]
for i in range(n):
    s = list(map(int, input().split()))
    student.append(s)
for i in range(m):
    s = list(map(int, input().split()))
    check.append(s)
student=np.array(student)
check=np.array(check)
for i in student:
    c=np.copy(check)
    c=np.abs(c-i)
    c=c[:,0]+c[:,1]
    print(np.argmin(c)+1)

Solution (Python):
N,M = map(int,input().split())
s = []
for _ in range(N):
    a,b = map(int,input().split())
    s.append((a,b))
check = []
for _ in range(M):
    c,d = map(int,input().split())
    check.append((c,d))
res_list = []
for i in s:
    a = i[0]
    b = i[1]
    tmp = 1e+9
    res = 0
    for j in range(len(check)):
        c = check[j][0]
        d = check[j][1]
        ans = abs(a-c)+abs(b-d)
        if tmp > ans:
            res = j+1
            tmp = ans
    res_list.append(res)
for i in res_list:
    print(i)

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

a = [list(map(int,input().split())) for x in range(N)]
c = [list(map(int,input().split())) for x in range(M)]

min_cpoint = 0
num_stack = 100100100100100

for i in range(N):
    for j in range(M):
        if num_stack > abs(a[i][0]-c[j][0]) + abs(a[i][1]-c[j][1]):
            num_stack = abs(a[i][0]-c[j][0]) + abs(a[i][1]-c[j][1])
            min_cpoint = j+1
    print(min_cpoint)
    num_stack = 100100100100100

Solution (Python):
n,m=map(int,input().split())
st=[]
for i in range(n):
  s_d=list(map(int,input().split()))
  st.append(s_d)
cp=[]
for i in range(m):
  c_d=list(map(int,input().split()))
  cp.append(c_d)
sc=[]
for i in range(n):
  scd=[]
  for j in range(m):
    scd_d=abs(st[i][0]-cp[j][0])+abs(st[i][1]-cp[j][1])
    scd.append(scd_d)
  sc.append(scd.index(min(scd))+1)
  
for i in range(n):
  print(sc[i])

Solution (Python):
n,m=map(int,input().split())
listn=[]
listm=[]
ans=[]
num=0
for i in range(n):
    listn.append(input().split())
for i in range(m):
    listm.append(input().split())
for i in range(n):
    numx=int(listn[i][0])
    numy=int(listn[i][1])
    count=10**10
    for j in range(m):
        numd=abs(int(listm[j][0])-numx)+abs(int(listm[j][1])-numy)
        if count>numd:
            count=numd
            num=j+1
    ans.append(num)
for i in range(n):
    print(ans[i])

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

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


student = []
for i in range(n):
    array = list(map(int, input().strip().split()))
    student.append(array)

cp = []
for i in range(m):
    array = list(map(int, input().strip().split()))
    cp.append(array)

result = [0] * n
for i in range(n):
  dis_min = 10**9
  for j in range(m):
    dis = abs(student[i][0]-cp[j][0]) + abs(student[i][1] - cp[j][1])
    if dis < dis_min:
      dis_min = dis
      result[i] = j+1

for i in result:
  print(i)

Solution (Python):

if __name__ == '__main__':
    a, b = map(int, input().split())
    lista=[]
    for i in range(a):
        c = [int(i) for i in input().split()]
        lista.append(c)

    listb=[]
    for i in range(b):
        c = [int(i) for i in input().split()]
        listb.append(c)

    listc =[]

    for i in lista:
        min = 10**9
        minroot=-1
        for j in range(len(listb)):
            root = abs(i[0] - listb[j][0])  + abs(i[1] - listb[j][1])
            if root <min:
                min =root
                minroot=j+1
        listc.append(minroot)
    for i in listc:
        print(i)

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

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

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

ans = [-1] * N
for i in range(N):
    min_dist = float("inf")
    min_idx = -1
    for j in range(M):
        dist = abs(students[i][0] - cps[j][0]) + abs(students[i][1] - cps[j][1])
        if dist < min_dist:
            min_dist = dist
            min_idx = j + 1
    ans[i] = min_idx
print("\n".join(map(str, 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 a in A:
    cur = float('inf')
    for i, b in enumerate(B):
        x = abs(a[0] - b[0]) + abs(a[1] - b[1])
        if  x < cur:
            cur = x
            checkpoint = i + 1
    ans.append(checkpoint)
    
for i in range(n):
    print(ans[i])

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

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

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

ans_lis = []


for i in range(len(studentlis)):
    ans = int(10**100)

    tmpstudentlis = studentlis[i]

    x1 = tmpstudentlis[0]
    y1 = tmpstudentlis[1]
    
    for j in range(len(checkpointlis)):
        tmpcheckpointlis = checkpointlis[j]

        x2 = tmpcheckpointlis[0]
        y2 = tmpcheckpointlis[1]
        
        distance = (abs(x1-x2) + abs(y1-y2))

        if distance < ans:
            ans = distance
            num = j

        if j == len(checkpointlis)-1:
            ans_lis.append(num+1)


for i in ans_lis:
    print(i)

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

for i in students:
  d_min=100000000000000000000
  p=0
  for j in checkpoints:
    p+=1
    d = abs(i[0] - j[0])+abs(i[1] - j[1])
    if d < d_min:
      d_min = d
      point=p
  print(point)

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 = 0
    tmp = 10**9
    for j in range(m):
        dt = abs(a[i][0]-b[j][0]) + abs(a[i][1]-b[j][1])
        if dt < tmp:
            ans = j+1
            tmp = dt
    print(ans)