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())
a=[]
b=[]
c=[]
d=[]
for i in range(n):
	aa,bb=map(int,input().split())
	a.append(aa)
	b.append(bb)
for i in range(m):
	cc,dd=map(int,input().split())
	c.append(cc)
	d.append(dd)
for i in range(n):
	dis=[]
	for j in range(m):
		dis.append(abs(a[i]-c[j])+abs(b[i]-d[j]))
	for j in range(m):
		if min(dis)==dis[j]:
			print(j+1)
			break

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

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

ansLst = [0] * N

for i in range(N):
    tmpMin = 100000000000
    ans = 0
    for j in range(M):
        tmp = abs(abLst[i][0] - cdLst[j][0]) + abs(abLst[i][1] - cdLst[j][1])
        if tmpMin > tmp:
            tmpMin = tmp
            ans = j + 1
    ansLst[i] = ans

for i in ansLst:
    print(i)

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

Solution (Python):
N, M = map(int, input().split())
students = [tuple(map(int, input().split())) for _ in range(N)]
checkpoints = [tuple(map(int, input().split())) for _ in range(M)]
for student in students:
  dist_p = 0
  dist_m = 4*10**8
  for idx, checkpoint in enumerate(checkpoints):
    dist_temp = abs(student[0]-checkpoint[0]) + abs(student[1]-checkpoint[1])
    if dist_temp < dist_m:
      dist_p = idx+1
      dist_m = dist_temp
  print(dist_p)

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

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

X = []
Y = []
for i in range(n):
    a,b = list(map(int,input().split()))
    X.append([a,b])

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

for x in X:
    dist = 1e9
    choise = 1
    for n,y in enumerate(Y):
        mh = manhattan(x[0],x[1],y[0],y[1])
        if mh < dist:
            dist = mh
            choise = n+1
    print(choise)

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

def loc(ab):
  d=10**9
  t=''
  for m in range(M):
    td=abs(ab[0]-cd[m][0])+abs(ab[1]-cd[m][1])
    if td<d:
      d=td
      t=m
  return t

ab=['']*N
cd=['']*M
for i in range(N):
  ab[i]=[int(x) for x in input().split()]

for i in range(M):
  cd[i]=[int(x) for x in input().split()]

for n in range(N):
  print(loc(ab[n])+1)

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

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

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

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

Solution (Python):
n,m = map(int,input().split())
s = []
l = []
for i in range(n):
    a = list(map(int,input().split()))
    s.append(a)
for i in range(m):
    b = list(map(int,input().split()))
    l.append(b)
ansl = []
for i in range(n):
    ans1 = abs(s[i][0]-l[0][0]) + abs(s[i][1]-l[0][1])
    ans = 1
    for j in range(m):
        ans2 = abs(s[i][0] - l[j][0]) + abs(s[i][1] - l[j][1])
        if ans2 < ans1:
            ans1 = ans2
            ans = j + 1
    ansl.append(ans)
for i in range(n):
    print(ansl[i])

Solution (Python):
def main():
    N, M = map(int, input().split())
    S = []
    for n in range(N):
        x, y = map(int, input().split())
        S.append((x, y))
    C = []
    for m in range(M):
        x, y = map(int, input().split())
        C.append((x, y))
    ans = []
    for i, s in enumerate(S):
        d = float('INF')
        ans.append(0)
        for j, c in enumerate(C):
            dd = abs(s[0] - c[0]) + abs(s[1] - c[1])
            if d > dd:
                ans[i] = j + 1
                d = dd
    print('\n'.join(map(str, ans)))


main()

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

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

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

for i in range(len(la)):
    mi = 1000000001
    ans = 0
    for j in range(len(ca)):
        p = abs(la[i][0]-ca[j][0]) + abs(la[i][1]-ca[j][1])
        if  p < mi:
            mi = p
            ans = j+1
    print(ans)

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

for i in range(N):
	students.append([int(x) for x in input().split()])
for i in range(M):
	checkpoints.append([int(x) for x in input().split()])
def distance(s, c):
  return abs(s[0]- c[0]) + abs(s[1]- c[1])

for s in students:
	mind = 10**10
	mini = -1
	for i, c in enumerate(checkpoints):
		d = distance(s, c)
		if d < mind:
			mind = d
			mini = i+1
	print(mini)

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

def calc_nearest(student,checkpoints):
    nearest_idx = 50
    max_dist = 10**9
    i = 1
    for checkpoint in checkpoints:
        dist = abs(student[0]-checkpoint[0]) + abs(student[1]-checkpoint[1])
        if max_dist > dist:
            nearest_idx = i
            max_dist = dist
        i += 1
    return nearest_idx

for student in students:
    print(calc_nearest(student,checkpoints))

Solution (Python):

import sys, math, fractions, itertools


def solve(N: int, M: int, a: "List[int]", b: "List[int]", c: "List[int]", d: "List[int]"):
    for i in range(N):
        mn = 1e9
        idx = -1
        for j in range(M):
            dis = abs(a[i] - c[j]) + abs(b[i] - d[j])
            if dis < mn:
                mn = dis
                idx = j+1
        print(idx)

    return



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

if __name__ == '__main__':
    main()

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

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


for s in students:
    tmp_d, tmp_i = 10 ** 18, -1
    for p in points:
        dif = abs(s[0] - p[0]) + abs(s[1] - p[1])
        if dif < tmp_d:
            tmp_d = dif
            tmp_i = p[2]
    print(tmp_i)

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

L = 0
t = 0

for k in range(N):
    L = 1000000000000
    for l in range(M):
        if L > abs(int(S[k][0]) - int(T[l][0])) + abs(int(S[k][1]) - int(T[l][1])):
            L = abs(int(S[k][0]) - int(T[l][0])) + abs(int(S[k][1]) - int(T[l][1]))
            t = l+1
    print(t)

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

for a,b in students:
    min_d = 10**9 
    min_i = 0
    for i,(c,d) in enumerate(checks):
        dis = abs(a-c) + abs(b-d)
        if dis < min_d:
            min_d = dis
            min_i = i

    print(min_i+1)

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

check = [[0]*M for _ in range(N)]

for i in range(N):
    for j in range(M):
        check[i][j] = max(a[i]-c[j],c[j]-a[i]) + max(b[i]-d[j],d[j]-b[i])
    print(check[i].index(min(check[i])) + 1)

Solution (Python):
n, m = map(int, input().split())
a_b = [list(map(int, input().split())) for _ in range(n)]
c_d = [list(map(int, input().split())) for _ in range(m)]
ans = []
for i in range(n):
    ans_sub = []
    for j in range(m):
        ans_sub.append(abs(a_b[i][0]-c_d[j][0]) + abs(a_b[i][1]-c_d[j][1]))
    ans.append(ans_sub.index(min(ans_sub)) + 1)
for i in range(n):
    print(ans[i])

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

nearest=m
nearestdistance=2*10**8
distance=0
for s in range(n):
  for c in range(m):
    distance=abs(int(students[s][0])-int(checkpoints[c][0]))+abs(int(students[s][1])-int(checkpoints[c][1]))
    if distance<nearestdistance:
      nearest=c+1
      nearestdistance=distance
      
  print(nearest)
  nearest=m
  nearestdistance=2*10**8

Solution (Python):
N,M=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(N)]
c=[list(map(int,input().split())) for _ in range(M)]
for i in range(N):
  d=10**9
  n=0
  for j in range(M):
    x=abs(s[i][0]-c[j][0])+abs(s[i][1]-c[j][1])
    if x<d:
      d=x
      n=j+1
  print(n)

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

for a, b in ab :
    mi, mv = 0, float('inf')
    for i, (c, d) in enumerate(cd) :
        if abs(a-c) + abs(b-d) < mv :
            mi = i
            mv = abs(a-c) + abs(b-d)
    print(mi+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 j in range(m)]
for i in range(n):
    dist = []
    x = ab[i][0]
    y = ab[i][1]
    for j in range(m):
        dist.append(abs(x - cd[j][0]) + abs(y - cd[j][1]))

    print(dist.index(min(dist))+1)

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

Solution (Python):
a, b = map(int, input().split())
c = []
d = []
g = []
for i in range(a):
    e, f = map(int, input().split())
    c.append([e, f])
for i in range(b):
    e, f = map(int, input().split())
    d.append([e, f])
for i in range(a):
    f = 10 ** 9
    h = 0
    for j in range(b):
        if f > abs(c[i][0] - d[j][0]) + abs(c[i][1] - d[j][1]):
            f = abs(c[i][0] - d[j][0]) + abs(c[i][1] - d[j][1])
            h = j + 1
    g.append(h)
for i in g:
    print(i)

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

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

for s in student_list:
    tmp = []
    for c in check_list:
        tmp.append(abs(s[0]-c[0]) + abs(s[1]-c[1]))
    print(tmp.index(min(tmp))+1)

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

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

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

Solution (Python):
n,m=map(int,input().split())
student=[list(map(int,input().split())) for _ in range(n)]
checkpoint=[list(map(int,input().split())) for _ in range(m)]
for i in range(n):
    distance=[]
    for j in range(m):
        calc=0
        calc=abs(student[i][0]-checkpoint[j][0])+abs(student[i][1]-checkpoint[j][1])
        distance.append(calc)
    print(distance.index(min(distance))+1)

Solution (Python):
a, b = map(int, input().split())
c = [list(map(int, input().split()))for _ in range(a)]
d = [list(map(int, input().split()))for _ in range(b)]
e = []
for i in range(a):
    f = 10 ** 9
    g = 0
    for j in range(b):
        if f > abs(c[i][0] - d[j][0]) + abs(c[i][1] - d[j][1]):
            f = abs(c[i][0] - d[j][0]) + abs(c[i][1] - d[j][1])
            g = j + 1
    e.append([g, f])
for i in range(a):
    print(e[i][0])

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


for i in range(m):
    temp = list(map(int, input().split()))
    c.append(temp[0])
    d.append(temp[1])

ans = []

for i in range(n):
    min_dis = 10 ** 9
    for j in range(m):

        distance = abs(c[j] - a[i]) + abs(d[j] - b[i])

        
        
        
        if min_dis > distance:
            min_dis = distance
            min_num = j
            
        
    ans.append(min_num)
    
for i in range(n):
    print(ans[i] + 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()))+[i] for i in range(M)]
INF = 10**10

for pos in AB:
    dist = INF
    res = 0
    ai = pos[0]
    bi = pos[1]
    for check in CD:
        ci = check[0]
        di = check[1]
        t = abs(ai-ci)+abs(bi-di)
        if t < dist:
            dist = t
            res = check[2]+1
    print(res)

Solution (Python):

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def main():
    num_people, num_check = map(int, input().split())
    data_people = [list(map(int, input().split())) for i in range(num_people)]
    data_check = [list(map(int, input().split())) for i in range(num_check)]

    for i in range(num_people):
        ans_ind = 1
        kyori = abs(data_people[i][0] - data_check[0][0]) + abs(data_people[i][1] - data_check[0][1])
        for j in range(1, num_check):
            kari = abs(data_people[i][0] - data_check[j][0]) + abs(data_people[i][1] - data_check[j][1])
            if kari < kyori:
                kyori = kari
                ans_ind = j + 1
        print(ans_ind)

if __name__ == '__main__':
    main()

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    a, b = LI()
    print((a+b)%24)
    return


def B():
    n, m = LI()
    ab = LIR(n)
    cd = LIR(m)
    for a, b in ab:
        ans = inf
        an = 0
        for num, cdi in enumerate(cd):
            c, d = cdi
            if ans > abs(a - c) + abs(b - d):
                ans = abs(a - c) + abs(b - d)
                an = num
        print(an+1) 
    return


def C():
    return


def D():
    return


if __name__ == '__main__':
    B()

Solution (Python):
def main():
    n,m=map(int,input().split(' '))
    n_list=[[int(i) for i in list(input().split(' '))] for i in range(n)]
    m_list=[[int(i) for i in list(input().split(' '))] for i in range(m)]
    inf = 4*10**8+1
    for i in n_list:
        tmp = inf
        ans = 1
        for num,j in enumerate(m_list):
            m_dis=abs(i[0]-j[0]) +abs(i[1]-j[1])
            if m_dis < tmp:
                tmp = m_dis
                ans = num+1
        print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n, m = map(int, input().split())
    students = [tuple(map(int, input().split())) for i in range(n)]
    check_points = [tuple(map(int, input().split())) for i in range(m)]

    for a, b in students:
        dist = [abs(a - c) + abs(b - d) for c, d in check_points]
        print(dist.index(min(dist)) + 1)

    
    
    
    
    
    
    


if __name__ == "__main__":

    main()

Solution (Python):
def main():
    n, m = map(int, input().split())
    students = [tuple(map(int, input().split())) for i in range(n)]
    check_points = [tuple(map(int, input().split())) for i in range(m)]

    for st in students:
        min_pt = check_points[0]
        for pt in check_points:
            if abs(pt[0] - st[0]) + abs(pt[1] - st[1]) < \
               abs(min_pt[0] - st[0]) + abs(min_pt[1] - st[1]):
                min_pt = pt
        print(check_points.index(min_pt) + 1)


if __name__ == "__main__":

    main()

Solution (Python):
N,M=map(int,input().split())
S=[list(map(int,input().split())) for _ in range(N)]
C=[list(map(int,input().split())) for _ in range(M)]
for a,b in S:
	m=10**9
	cnt=0
	for c,d in C:
		l=abs(c-a)+abs(d-b)
		cnt+=1
		if m>l:
			m=min(m,l)
			ans=cnt
	print(ans)

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

starts = [0]*N
for _ in range(N):
    starts[_] = list(map(int, input().split()))

ends = [0]*M
for _ in range(M):
    ends[_] = list(map(int, input().split()))

for _ in range(N):
    cand = [abs(starts[_][0] - e[0]) + abs(starts[_][1] - e[1]) for e in ends]
    print(cand.index(min(cand))+1)

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

for i in range(n):
    l=[abs(c[j][0]-a[i][0])+abs(c[j][1]-a[i][1]) for j in range(m)]
    print(l.index(min(l))+1)

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

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

for i in range(n):
    ans = []
    for j in range(m):
        s = abs(li_student[i][0] - li_check[j][0]) + abs(li_student[i][1] - li_check[j][1])
        ans.append(s)
    t = ans.index(min(ans)) + 1
    print(t)

Solution (Python):
a, b = map(int, input().split())
c = [list(map(int, input().split()))for _ in range(a)]
d = [list(map(int, input().split()))for _ in range(b)]
for i in range(len(c)):
    e = 10**9
    f = 0
    for j in range(len(d)):
        g = abs(c[i][0] - d[j][0]) + abs(c[i][1] - d[j][1])
        if e > g:
            e = g
            f = j + 1
    print(f)

Solution (Python):

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


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

Solution (Python):
n,m = map(int, input().split())
a = [];b=[];c=[];d=[]
for i in range(n):
    x,y = map(int, input().split())
    a.append(x)
    b.append(y)
for i in range(m):
    x,y = map(int, input().split())
    c.append(x)
    d.append(y)
    
for i in range(n):
    min_dist=abs(a[i]-c[0])+abs(b[i]-d[0])
    checkpoint=1
    for j in range(1,m):
        cur_dist=abs(a[i]-c[j])+abs(b[i]-d[j])
        if min_dist>cur_dist:
            min_dist = cur_dist
            checkpoint = j+1
    print(checkpoint)

Solution (Python):
MOD = 10**9 + 7

N,M = map(int,input().split())
a = [0] * N
b = [0] * N
c = [0] * M
d = [0] * M
min = [MOD] * N
min_num = [0] * N
for i in range(N): a[i],b[i] = map(int,input().split())
for t in range(M): c[t],d[t] = map(int,input().split())

for j in range(N):
    for q in range(M):
        dist = abs(a[j] - c[q]) + abs(b[j] - d[q])
        if dist < min[j]:
            min[j] = dist
            min_num[j] = q + 1
for k in min_num: print(k)

Solution (Python):
MOD = 10**9 + 7

N,M = map(int,input().split())
a = [0] * N
b = [0] * N
c = [0] * M
d = [0] * M
min = [MOD] * N
min_num = [0] * N
for i in range(N):
    a[i],b[i] = map(int,input().split())
for t in range(M):
    c[t],d[t] = map(int,input().split())

for j in range(N):
    for q in range(M):
        dist = abs(a[j] - c[q]) + abs(b[j] - d[q])
        if dist < min[j]:
            min[j] = dist
            min_num[j] = q + 1
for k in min_num:
    print(k)

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

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

for student in students:
    list_ = []
    for i in range(len(checkpoints)):
        list_.append((abs(student[0] - checkpoints[i][0]) + abs(student[1] - checkpoints[i][1]), i+1))
    print(sorted(list_)[0][1])

Solution (Python):


def main(N,M,A,B,C,D):
    for i in range(N):
        res = []
        for j in range(M):
            res.append(abs(A[i]-C[j])+abs(B[i]-D[j]))
        print(res.index(min(res))+1)
 
    
if __name__ == '__main__':
    N, M = map(int, input().split())
    A, B = [], []
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
    C, D = [], []
    for i in range(M):
        c, d = map(int, input().split())
        C.append(c)
        D.append(d)
    
    main(N,M,A,B,C,D)

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):
    mi = float('inf')
    x,y = ab[i]
    for j in range(m):
        c,d = cd[j]
        if mi > abs(x-c) + abs(y-d):
            ans = j+1
            mi = abs(x-c) + abs(y-d)
    print(ans)

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

    pno = 0
    now = float("inf")

    for j in range(M):

        if now > abs( i[0] - cd[j][0] ) + abs( i[1] - cd[j][1] ):
            
             pno = j+1
             now = abs( i[0] - cd[j][0] ) + abs( i[1] - cd[j][1] )

    print (pno)

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

for i in range(n):
    md = 0
    for j in range(m):
        d = abs(cs[j][0] - ss[i][0]) + abs(cs[j][1] - ss[i][1])
        if d < abs(cs[md][0] - ss[i][0]) + abs(cs[md][1] - ss[i][1]):
            md = j
    print(md + 1)

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

for n in range(N):
    closest = 1
    dist = abs(CD[0][0] - AB[n][0]) + abs(CD[0][1] - AB[n][1])
    for m in range(1, M):
        tmp_dist = abs(CD[m][0] - AB[n][0]) + abs(CD[m][1] - AB[n][1])
        if tmp_dist < dist:
            dist = tmp_dist
            closest = m+1
    print(closest)

Solution (Python):
N, M = map(int,input().split())
sp = []
cp = []
move = [0] * N
min_dis = 10**9

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

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

for i in range(N):
    for j in range(M):
        distance = abs(sp[i][0]-cp[j][0]) + abs(sp[i][1]-cp[j][1])
        if distance < min_dis:
            move[i] = j + 1
            min_dis = distance
    min_dis = 10**9

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

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

for i in range(n):
    ans = 0
    mincp = 100000000000
    for j in range(m):
        dist = abs(a[i]-c[j])+abs(b[i]-d[j])
        if dist < mincp:
            ans = j+1
            mincp = dist
    print(ans)

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

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


for sx,sy in student:
    dist=2*10**10
    pnum=0
    for i, p in enumerate(point):
        px,py=p[0],p[1]
        pdist=abs(sx-px)+abs(sy-py)
        if pdist<dist:
            dist=pdist
            pnum=i+1
    print(pnum)

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

a = [0] * N
b = [0] * N
c = [0] * M
d = [0] * M
for _ in range(N):
    a[_], b[_] = map(int, input().split())

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


for i in range(N):
    min_dist = float('inf')
    ans = 0
    for j in range(M):
        distance = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if min_dist > distance:
            min_dist = distance
            ans = j + 1
    print(ans)

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

for i in range(n):
    mn = 10**17
    for j in range(m)[::-1]:
        if mn >= abs(students[i][0] - checks[j][0]) + abs(students[i][1] - checks[j][1]):
            mn = abs(students[i][0] - checks[j][0]) + abs(students[i][1] - checks[j][1])
            ans = j + 1
    print(ans)

Solution (Python):

import sys
sys.setrecursionlimit(300000)


def solve(N: int, M: int, a: "List[int]", b: "List[int]", c: "List[int]", d: "List[int]"):
    for i in range(N):
        mn = float('inf')
        for j in range(M):
            e = abs(a[i] - c[j]) + abs(b[i] - d[j])
            if e < mn:
                ret = j + 1
                mn = e
        print(ret)
    return


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

if __name__ == '__main__':
    main()

Solution (Python):
def main():
	N, M = map(int, input().split())
	st = [0]*N
	p = [0]*M
	INF = 10**9+7
	ans = [[INF, N] for _ in range(N)]
	for i in range(N):
		st[i] = list(map(int, input().split()))
	for i in range(M):
		p[i] = list(map(int, input().split()))
	for i in range(N):
		for j in range(M):
			dist = abs(st[i][0]-p[j][0])+abs(st[i][1]-p[j][1])
			if dist < ans[i][0]:
				ans[i][0] = dist
				ans[i][1] = j

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


if __name__ == '__main__':
	main()

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

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

def check(i):
    min_d = 10 ** 9
    x = H[i][0]
    y = H[i][1]
    idx = -1
    for i, p in enumerate(P):
        d = abs(x - p[0]) + abs(y - p[1])
        if d < min_d:
            min_d = d
            idx = i
    return idx

for i in range(N):
    near = check(i)
    print(near + 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 = manhattan(ab[i],cd[0])
	for j in range(1,m):
		d = manhattan(ab[i],cd[j])
		if dmin > d:
			dmin = d
			ans[i] = j

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