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 i in range(n)]
cd = [list(map(int,input().split())) for i in range(m)]

def manhattan(place, target):
	return abs(target[0] - place[0]) + abs(target[1] - place[1])
ans = [0] * n
for i in range(n):
	dmin = 10**9
	for j in range(m):
		d = manhattan(ab[i],cd[j])
		if dmin > d:
			dmin = d
			ans[i] = j

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

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

for i in range(a[0]):
  d = []
  for j in range(a[1]):
    d.append(abs(b[i][0]-c[j][0])+abs(b[i][1]-c[j][1]))
  else:
    print(d.index(min(d))+1)

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

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

for i in ans:
    print(i)

Solution (Python):
n,m = map(int,input().split())
lst = []
pnt = []
for i in range(n):
    a,b = map(int,input().split())
    lst.append((a,b))

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

for e in lst:
    for j in range(m):
        d = abs(e[0]-pnt[j][0]) + abs(e[1]-pnt[j][1])
        if j==0:
            mindis = d
            loc = j+1
        elif d < mindis:
            mindis = d
            loc = j+1
    print(loc)

Solution (Python):
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
students = []
for _ in range(N):
    students.append([int(x) for x in stdin.readline().rstrip().split()])

checkpoints = []
for _ in range(M):
    checkpoints.append([int(x) for x in stdin.readline().rstrip().split()])

for i in students:
    tmp = 10**9 
    for ind,j in enumerate(checkpoints):
        dist = abs(i[0] - j[0]) + abs(i[1] - j[1])
        if dist < tmp:
            tmp = dist
            ans = ind+1
    print(ans)

Solution (Python):



N, M = map(int, input().split())
std_li = [list(map(int, input().split())) for i in range(N)]
chk_li = [list(map(int, input().split())) for j in range(M)]
dist = 0

for i in range(N):
    ctr = 0
    min_dist = pow(10,8) * 4 + 1
    for j in range(M):
        dist = abs(std_li[i][0] - chk_li[j][0]) + abs(std_li[i][1] - chk_li[j][1])
        if dist < min_dist:
            min_dist = dist
            ctr = j + 1
    print(ctr)

Solution (Python):
n,m=map(int,input().split())
p=[list(map(int, input().split())) for _ in range(n)]
c=[list(map(int, input().split())) for _ in range(m)]
for i in p:
    d=[abs(i[0]-c[j][0])+abs(i[1]-c[j][1]) for j in range(len(c))]
    print(d.index(min(d))+1)

Solution (Python):
import numpy as np
n, m = map(int,input().split())
l = [list(map(int, input().split())) for _ in range(n)]
l1 = [list(map(int,input().split())) for _ in range(m)]


for i in l:
  l2 = []
  
  for j in l1:
    
    a = abs(i[0]-j[0]) + abs(i[1]-j[1])
    l2.append(a)
  print(np.argmin(l2)+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)]

for (x, y) in A:
    d = np.array([])
    for (a, b) in B:
        d = np.append(d, abs(x-a) + abs(y-b))
    print(np.argmin(d) + 1)

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

for i in range(n):
  ans = 0
  mdist = 10**9
  for j in range(m):
    if abs(man[i][0] - point[j][0]) + abs(man[i][1] - point[j][1]) < mdist:
      ans = j+1
      mdist = abs(man[i][0] - point[j][0]) + abs(man[i][1] - point[j][1])
  print(ans)

Solution (Python):
from sys import exit, stdin

N, M = [int(_) for _ in stdin.readline().rstrip().split()]
ab = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]
cd = [list(map(int, stdin.readline().rstrip().split())) for _ in range(M)]

for i in range(N):
    answers = []
    for j in range(M):
        ans = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        answers.append(ans)
    print(answers.index(min(answers))+1)

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

N, M = map(int, input().split())
students = [tuple(map(int, input().split())) for _ in range(N)]
cps = [tuple(map(int, input().split())) for _ in range(M)]
for s in students:
    ans = (float('inf'), -1)
    for i, cp in enumerate(cps, 1):
        ans = min(ans, (dist(s, cp), i))
    print(ans[1])

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

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

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

for a,b in ab:
    dec = 1e9
    for j, s in enumerate(cd):
        dist = abs(a-s[0])+abs(b-s[1])
        if dist < dec:
            idx = j
            dec = dist
    print(idx+1)

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

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

for a,b in ab:
    ans,distance = 0,float('inf')
    for i,cont in enumerate(cd):
        c,d = cont
        
        if distance > abs(a-c)+abs(b-d):
            ans = i
            distance = abs(a-c)+abs(b-d)
    print(ans+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 i in range(m)]
for a,b in ab:
    ma=10**10
    tp=0
    for i in range(m):
        if ma>abs(a-cd[i][0])+abs(b-cd[i][1]):
            ma=abs(a-cd[i][0])+abs(b-cd[i][1])
            tp=i+1
    print(tp)

Solution (Python):

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

Solution (Python):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, M = nl()

students = []
for i in range(N):
    students.append(nl())

points = []
for i in range(M):
    points.append(nl())

for student in students:
    min_dist = 300000000
    min_i = M
    for i in range(M):
        dist = abs(points[i][0] - student[0]) + abs(points[i][1] - student[1])
        if dist < min_dist:
            min_dist = dist
            min_i = i
    print(min_i+1)

Solution (Python):
def abc():
    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 _a in a:
        md = 10 ** 9
        ans = 0
        for i, _b in enumerate(b):
            tmp = abs(_a[0]-_b[0])+abs(_a[1]-_b[1])
            if tmp < md:
                md = tmp
                ans = i + 1
        print(ans)


abc()

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

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

Solution (Python):
n,m = map(int,input().split())
a = []
b = []
for i in range(n):
    a_i, b_i = map(int,input().split())
    a.append(a_i)
    b.append(b_i)
c = []
d = []
for i in range(m):
    c_i, d_i = map(int,input().split())
    c.append(c_i)
    d.append(d_i)

for i in range(n):
    z = 1
    l = abs(a[i] - c[0]) + abs(b[i] - d[0])
    for j in range(1,m):
        if abs(a[i] - c[j]) + abs(b[i] - d[j]) < l:
            z = j+1
            l = abs(a[i] - c[j]) + abs(b[i] - d[j])
    print(z)

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

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

for n in range(N):
    mindis = 10 ** 9
    for m in range(M):
        dis = abs(student[n][0] - point[m][0]) + abs(student[n][1] - point[m][1])
        if mindis > dis:
            mindis = dis
            ans = m + 1
    print(ans)

Solution (Python):
from itertools import permutations as perm
man = lambda a,b:abs(a[0]-b[0])+abs(a[1]-b[1])
N,M = map(int, input().split())

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

inf = float('INF')
ans_lst = [[inf, 0] for i in range(N)]
for i in range(M):
    c,d = map(int, input().split())
    for j in range(N):
        if ans_lst[j][0] > man(XY[j], [c,d]):
            ans_lst[j] = [man(XY[j], [c,d]), i+1]
for i in range(N):
    print(ans_lst[i][1])

Solution (Python):
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]
l = []
for i in range(n) :
	Min = 10**9
	ans = 0
	for j in range(m) :
		if abs(a[i][0] - b[j][0]) + abs(a[i][1] - b[j][1]) < Min :
			Min = abs(a[i][0] - b[j][0]) + abs(a[i][1] - b[j][1])
			ans = j + 1
	l.append(ans)
for i in l :
	print(i)

Solution (Python):
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))


n, m = MI()
student = [LI() for i in range(n)]
checkpoint = [LI() for i in range(m)]
for i in student:
    tmp = INF
    ans = 0
    for index, j in enumerate(checkpoint):
        if abs(i[0] - j[0]) + abs(i[1] - j[1]) < tmp:
            tmp = abs(i[0] - j[0]) + abs(i[1] - j[1])
            ans = index + 1 
    print(ans)

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

Solution (Python):
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
import string

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, M = list(map(int, sys.stdin.readline().split()))
A, B = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)]))
C, D = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(M)]))

C = np.array(C)
D = np.array(D)

for a, b in zip(A, B):
    c = abs(C - a)
    d = abs(D - b)
    xy = (c + d).argmin()
    print(xy + 1)

Solution (Python):
n, m = map(int, input().split())
ab = [input() for _ in range(n)]
cd = [input() for _ in range(m)]
target = []
for x1y1 in ab:
    x1, y1 = map(int, x1y1.split())
    dist = float('inf')
    for i, x2y2 in enumerate(cd):
        x2, y2 = map(int, x2y2.split())
        temp_dist = abs(x1 - x2) + abs(y1 - y2)
        if temp_dist < dist:
            dist = temp_dist
            temp_target = i+1
    target.append(temp_target)
for i in target:
    print(i)

Solution (Python):
n,m = map(int, input().split())
dat_n = []
dat_m = []
for i in range(n):
    a,b = map(int, input().split())
    dat_n.append((a, b))
for i in range(m):
    a,b = map(int, input().split())
    dat_m.append((a, b))
for i in range(n):
    a, b = dat_n[i]
    index = -1
    distance = 1000000001
    for j in range(m):
        c,d = dat_m[j]
        t = abs(a-c) + abs(b-d)
        if t < distance:
            index = j + 1
            distance = t
    print(index)

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

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

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


for i in range(n):
    num=0
    dist=10**20
    for j in range(m):
        dist1=abs(xy[i][0]-xy1[j][0])+abs(xy[i][1]-xy1[j][1])
        if dist>dist1:
            dist=dist1
            num=j+1
    print(num)

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

def dist(ab,cd):
  return abs(ab[0]-cd[0]) + abs(ab[1]-cd[1])

AB = [[int(x) for x in input().split()] for _ in range(N)]
CD = [[int(x) for x in input().split()] for _ in range(M)]

answer = []
for ab in AB:
  min_dist = 10**15
  target = 0
  for j,cd in enumerate(CD,1):
    x = dist(ab,cd)
    if min_dist > x:
      min_dist = x
      target = j
  answer.append(target)

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

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

for student in students:
    dist=10**10
    ans=0
    for i,point in enumerate(points,start=1):
        if abs(student[0]-point[0])+abs(student[1]-point[1]) < dist:
            dist=abs(student[0]-point[0])+abs(student[1]-point[1])
            ans=i
    print(ans)

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

for a, b in A:
    mi = 1e10
    ans = 0
    for i, (c, d) in enumerate(C):
        t = abs(a - c) + abs(b - d)
        if t < mi:
            mi = t
            ans = i
    print(ans + 1)

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

for px,py in pl: 
  ans = 0
  cnt = 1
  minmd = 10**10
  for cx,cy in cp:
    nowmd = abs(px-cx) + abs(py-cy)
    if nowmd < minmd:
      ans = cnt
      minmd = nowmd
    cnt += 1
  print(ans)

Solution (Python):
n,m=map(int,input().split())
p=[]
for i in range(n):
    p.append(tuple(map(int,input().split())))
c=[]
for i in range(m):
    c.append(tuple(map(int,input().split())))
for e in p:
    ans=0
    mh=float('inf')
    for i,f in enumerate(c,1):
        tmp=abs(e[0]-f[0])+abs(e[1]-f[1])
        if tmp<mh:
            mh=tmp
            ans=i
    print(ans)

Solution (Python):
N, M = tuple(map(int, input().split()))
student = []
check = []
ans = []

for i in range(N):
    student.append(list(map(int, input().split())))

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

for s in student:
    x = 10**9
    tmp = 0
    index = 1
    for c in check:
        y = abs(s[0]-c[0])+abs(s[1]-c[1])
        if (x > y):
            x = y
            tmp = index
        index+=1
    ans.append(tmp)

for a in ans:
    print(a)

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):
    far=float("inf")
    number=0
    for j in range(len(cd)):
        ans0=abs(ab[i][0]-cd[j][0])
        ans1=abs(ab[i][1]-cd[j][1])
        ans=ans0+ans1
        if far>ans:
            far=ans
            number=j+1
    print(number)

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:
    res = [0, float("inf")]
    for i, (c, d) in enumerate(CD):
        if res[1] > abs(a - c) + abs(b - d):
            res[0] = i
            res[1] = abs(a - c) + abs(b - d)
    print(res[0] + 1)

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(len(ab)):
    number=0
    far=float("inf")
    for j in range(len(cd)):
        ans0=abs(ab[i][0]-cd[j][0])
        ans1=abs(ab[i][1]-cd[j][1])
        ans=ans0+ans1
        if far>ans:
            far=ans
            number=j+1
    print(number)

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)]
tmp = 0

for i in range(len(ab)):
    mnh = 10**20
    for j in range(len(cd)):
        a, b = ab[i]
        c, d = cd[j]
        if mnh > abs(a-c) + abs(b-d):
            mnh = abs(a-c) + abs(b-d)
            tmp = j
    print(tmp+1)

Solution (Python):
N, M = map(int, input().split())
students = []
for i in range(0, N):
	students.append(list(map(int, input().split())))
checkpoints = []
for i in range(0, M):
	checkpoints.append(list(map(int, input().split())))
for i in range(0, N):
	nearest = 0
	min = 5000000000000000
	for j in range(0, M):
		d = abs(students[i][0]-checkpoints[j][0]) + abs(students[i][1]-checkpoints[j][1])
		if d < min:
			min = d
			nearest = j+1
	print(nearest)

Solution (Python):
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for x in range(N)]
cd = [list(map(int, input().split())) for x in range(M)]
for i in range(N):
    ans = 0
    dist = 10 ** 9
    for j in range(M):
        di = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if di < dist:
            dist = di
            ans = j + 1

    print(ans)

Solution (Python):

import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n, m = readmi()
N = []
M = []
for i in range(n):
    N.append(readl())
for i in range(m):
    t = list(readl())
    t.append(i + 1)
    M.append(t)

for i in N:
    s = 0xFFFFFFFF
    index = 0
    nx = i[0]
    ny = i[1]
    for j in M:
        mx = j[0]
        my = j[1]
        mindex = j[2]
        t = abs(nx - mx) + abs(ny - my)
        if s > t:
            s = t
            index = mindex
    print(index)

Solution (Python):
n,m = map(int,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)]


for i in range(n):
    cnt = 10**9
    num = 0
    for j in range(m):
        c = abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1])
        if c<cnt:
            cnt = c
            num = j+1
    print(num)

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

li = [ [int(it) for it in input().split()] for i in range(N) ]
lj = [ [int(it) for it in input().split()] for i in range(M) ]

for a,b in li:
  mi = 100000000000
  kk = -1
  k = 0
  for c,d in lj:
    if ( mi > abs(a-c)+abs(b-d) ):
      mi = abs(a-c)+abs(b-d)
      kk = k 
    k += 1
  print ( kk+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 student in ab:
    min_distance = 10**9
    min_idx = 0
    for idx in range(M)[::]:
        check = cd[idx]
        distance = abs(student[0] - check[0]) + abs(student[1] - check[1])
        if distance < min_distance:
            min_distance = distance
            min_idx = idx
    print(min_idx+1)

Solution (Python):
n,m = map(int,input().split())
stu_pos = [[i for i in map(int,input().split())] for j in range(n)]
check_pos = [[i for i in map(int,input().split())] for j in range(m)]

for i in range(n):
    count = m+1
    dis = 10**9+7
    for j in range(m):
        a  = abs(stu_pos[i][0] - check_pos[j][0]) + abs(stu_pos[i][1] - check_pos[j][1])
        if dis > a : 
            dis = a 
            count = j + 1 
    print("{}".format(count))

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):
    md = []
    for j in range(m):
        md.append(abs(a[i]-c[j])+abs(b[i]-d[j]))
    print(md.index(min(md))+1)

Solution (Python):

def manhattan(inlist1,inlist2):
	return abs(inlist1[0]-inlist2[0]) + abs(inlist1[1]-inlist2[1])

n, m = [ int(v) for v in input().split() ]


student_list = [ [ int(v) for v in input().split() ] for i in range(n) ]
point_list = [ [ int(v) for v in input().split() ] for i in range(m) ]
for i in range(n):
	ans = [10**9,0]
	for j in range(m):
		d = manhattan(student_list[i],point_list[j])
		if d < ans[0]:
			ans = [d, j+1]
	print(ans[1])

Solution (Python):
n,m=map(int,input().split())
s=[]
c=[]
def mdistance(a,b,c,d):
  return abs(a-c)+abs(b-d)
for i in range(n):
  a=list(map(int,input().split()))
  s.append(a)
for i in range(m):
  c.append(list(map(int,input().split())))
for i in range(n):
  anspoint=0
  for j in range(m):
    if mdistance(s[i][0],s[i][1],c[j][0],c[j][1])<mdistance(s[i][0],s[i][1],c[anspoint][0],c[anspoint][1]):
      anspoint=j
  print(anspoint+1)

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

Solution (Python):
n, m = map(int, input().split())
a = []
b = []
for _ in range(n):
    aa, bb = map(int, input().split())
    a.append(aa)
    b.append(bb)

c = []
d = []
for _ in range(m):
    cc, dd = map(int, input().split())
    c.append(cc)
    d.append(dd)

for aa, bb in zip(a, b):
    l = 2 * 10 ** 8
    num = 1
    for i, (cc, dd) in enumerate(zip(c, d)):
        dis = abs(aa - cc) + abs(bb - dd)
        if dis < l:
            l = dis
            num = i + 1
    print(num)

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

for i in range(n):
    minNum = float('inf')
    ans = 0
    for j in range(m):
        if abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]) < minNum:
            minNum = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
            ans = j + 1
    print(ans)

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

for i in range(n):
  min_c = 0
  min_d = float('inf')
  for j in range(m):
    d = abs(s[i][0]-c[j][0]) + abs(s[i][1]-c[j][1])
    if d < min_d:
      min_c = j+1
      min_d = d
  print(min_c)

Solution (Python):


def solve():
    N, M = list(map(int, input().split()))
    start = []
    for i in range(N):
        a, b = list(map(int, input().split()))
        start.append((a, b))
    
    checkpoints = []
    for i in range(M):
        c, d = list(map(int, input().split()))
        checkpoints.append((c, d))
    
    

    for i in range(N):
        min_d = float("inf")
        for j in range(M):
            d = abs(start[i][0]-checkpoints[j][0]) + abs(start[i][1]-checkpoints[j][1])
            if d < min_d:
                min_d = d
                ans = j + 1
        print(ans)


if __name__ == "__main__":
    solve()

Solution (Python):
N, M = map(int, input().split())
a, b, c, d = [0] * N, [0] * N, [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 j in range(N):
	ans = "nan"
	diff = float("inf")
	for k in range(M):
		if abs(a[j] - c[k]) + abs(b[j] - d[k]) < diff:
			diff = abs(a[j] - c[k]) + abs(b[j] - d[k])
			ans = k
	print(ans + 1)

Solution (Python):
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for x in [0]*n]
cd = [list(map(int,input().split())) for x in [0]*m]
for a,b in ab:
    l = [abs(a-c)+abs(b-d) for c,d in cd]
    print(l.index(min(l))+1)

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

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:
    min_distance = float("inf")
    min_checkpoint = 0
    for i, cd in enumerate(checkpoints):
        c, d = cd
        if abs(c - a) + abs(d - b) < min_distance:
            min_checkpoint = i + 1
            min_distance = abs(c - a) + abs(d - b)
    print(min_checkpoint)

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

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

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

for val in ab:
  tmp = []
  for point in cd:
    tmp.append(abs(val[0]-point[0])+abs(val[1]-point[1]))
  print(tmp.index(min(tmp))+1)

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


for k in student:
    manhattan = 100000000000
    number = 0
    for u in range(m):
        manhattann = abs(k[0]-Coodinate[u][0])+abs(k[1]-Coodinate[u][1])
        if manhattann < manhattan:
            manhattan = manhattann
            number = u+1
    ans.append(number)
for y in ans:
    print(y)

Solution (Python):
N,M = map(int,input().split())
students = [[int(i) for i in input().split()]+[j] for j in range(N)]
checkP = [[int(i) for i in input().split()]+[j] for j in range(M)]
ans = [0]*N
Inf = 10**9
dif = [Inf]*N


for a,b,c in students:
    for i,j,k in checkP:
        if abs(a-i)+abs(b-j) < dif[c]:
            dif[c] = abs(a-i) + abs(b-j)
            ans[c] = k+1

for i in ans:
    print(i)

Solution (Python):
N,M = map(int,input().split())
s,c,d = [],[],[0 for i in range(M)]
for i in range(N):
    s += [[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):
    for j in range(M):
        d[j] = abs(s[i][0] - c[j][0]) + abs(s[i][1] - c[j][1])
    print(d.index(min(d))+1)

Solution (Python):
n, m = map(int, input().split())
li = []
cp = []
ans = 4*10**8
anscp = 0
for i in range(n):
    a, b = map(int, input().split())
    li.append((a, b))
for j in range(m):
    c, d = map(int, input().split())
    cp.append((c, d))
for k in range(n):
    for l in range(m):
        num = abs(li[k][0]-cp[l][0]) + abs(li[k][1]-cp[l][1])
        if num < ans:
            ans = num
            anscp = l+1
    print(anscp)
    ans = 4*10**8

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

for i in range(N):
    student_x = student[i][0]
    student_y = student[i][1]
    distance = []
    for j in range(M):
        point_x = point[j][0]
        point_y = point[j][1]
        distance.append(abs(student_x - point_x) + abs(student_y - point_y))
    distance_min = min(distance)
    n = 0
    while True:
        if distance_min == distance[n]:
            print(n+1)
            break
        else:
            n += 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:
  x1, y1 = i[0], i[1]
  ans = 0
  MIN = 10 ** 9 + 7
  for key,j in enumerate(cd): 
    x2, y2 = j[0], j[1]
    manhattan = abs(x2-x1) + abs(y2-y1)
    if MIN > manhattan:
      ans = key + 1
      MIN = manhattan
  print(ans)

Solution (Python):
def dist(w, x, y, z):
    return abs(w-y)+abs(x-z)

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


for i in range(n):
    tmp = 10**9
    a, b = s[i][0], s[i][1]
    for j in range(m):
        c, d = p[j][0], p[j][1]
        if dist(a, b, c, d) < tmp:
            ans = j+1
            tmp = dist(a, b, c, d)
    print(ans)