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())
Std = [tuple(map(int, input().split())) for _ in range(N)]
Chp = [tuple(map(int, input().split())) for _ in range(M)]
INF = 10e9
Arrv = []
Mdist = lambda x,y,u,v:abs(x-u)+abs(y-v)
for s in Std:
    close = INF
    for i in range(M):
        dist = Mdist(*s,*Chp[i])
        if dist < close:
            close = dist
            arrv = i+1
    Arrv.append(arrv)
for ar in Arrv:
    print(ar)

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 = [0] * m
for i in range(n):
    a, b = ab[i][0], ab[i][1]
    dist = [0] * m
    for j in range(m):
        dist[j] = abs(a - cd[j][0]) + abs(b - cd[j][1])
    dm = min(dist)
    for j in range(m):
        if dist[j] == dm:
            print(j+1)
            break

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

tmp = []
for i in range(len(student)):
    for j in range(len(check)):
        x = abs(student[i][0] - check[j][0])
        y = abs(student[i][1] - check[j][1])
        tmp.append(x+y)
    print(tmp.index(min(tmp))+1)
    tmp = []

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

Solution (Python):
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext

def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n, m = i_map()
    n_list = i_row_list(n)
    m_list = i_row_list(m)

    for num in n_list:
        min_dist = INF
        min_point = 0
        for i, check in enumerate(m_list):
            dist = abs(num[0]-check[0]) + abs(num[1]-check[1])
            if min_dist > dist:
                min_dist = dist
                min_point = i + 1
        print(min_point)

if __name__ == '__main__':
    main()

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, M = map(int, readline().split())

    students = []

    for _ in range(N):
        a, b = map(int, readline().split())
        students.append((a, b))

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

    for i in range(N):
        dist_min = INF
        idx = -1
        x1, y1 = students[i]
        for j in range(M):
            x2, y2 = cp[j]
            dist_cur = abs(x2 - x1) + abs(y2 - y1)
            if dist_cur < dist_min:
                dist_min = dist_cur
                idx = j + 1
        print(idx)


if __name__ == '__main__':
    main()

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):
  Min=4*(10**8)+1
  for j in range(m):
    d = abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1])
    
    if Min > d:
      Min = d
      ans = j+1
  print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
import bisect

def main():
    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):
        dist = []
        for j in range(m):
            dist.append(abs(AB[i][0]-CD[j][0]) + abs(AB[i][1] - CD[j][1]))
        dist_min = min(dist)
        for k in range(len(dist)):
            if dist[k] == dist_min:
                print(k+1)
                break


if __name__ == '__main__':
    main()

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


for a, b in A_B:
    temp_distance = 10**10
    temp_checkpoint = -1
    checkpoint_count = 1
    for c, d in C_D:
        manhattan_distance = abs(a-c) + abs(b-d)
        if temp_distance > manhattan_distance:
            temp_distance = manhattan_distance
            temp_checkpoint = checkpoint_count
        checkpoint_count += 1
    print(temp_checkpoint)

Solution (Python):
n,m = map(int,input().split())
coordinate = [list(map(int,input().split())) for c in range(n)]
point = [list(map(int,input().split())) for c in range(m)]
for c in coordinate:
  num = 10**9
  ans = []
  for index,p in enumerate(point):
    tmp = abs(c[0]-p[0])+abs(c[1]-p[1])
    ans.append(tmp)
  print(ans.index(min(ans))+1)

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

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

for a, b in s:
    d = float('inf')
    for i in range(m):
        x, y = c[i]
        if abs(a - x) + abs(b - y) < d:
            d = abs(a - x) + abs(b - y)
            ans = i + 1
    print(ans)

Solution (Python):
N, M = map(int, input().split())
a = []
c = []
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())
  c.append([x, y])

for i in a:
  tmp = 10**9
  for l in range(M):
    j = c[l]
    x = abs(i[0]-j[0]) + abs(i[1]-j[1])
    if tmp > x:
      tmp = x
      ans = l + 1
  print(ans)

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

ans = []



for i in range(n):
    judge = 10 ** 9
    num = 0
    for j in range(m):
        if judge > abs(a[i]-c[j])+abs(b[i]-d[j]):
            judge = abs(a[i]-c[j])+abs(b[i]-d[j])
            num = j+1
    ans.append(num)

for i in ans:
    print(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:
    check_point_dist = 10 ** 8 * 4 + 1
    check_point = 0
    count = 0
    for c, d in cd:
        count += 1
        if check_point_dist > abs(a - c) + abs(b - d):
            check_point = count
            check_point_dist = abs(a - c) + abs(b - d)
    else:
        print(check_point)

Solution (Python):
def distance(coordinate1, coordinate2):
    x1 = coordinate1[0]
    y1 = coordinate1[1]
    x2 = coordinate2[0]
    y2 = coordinate2[1]
    return abs(x1 - x2) + abs(y1 - y2)


def main():
    n, m = map(int, input().split())
    ab_lst = [list(map(int, input().split())) for _ in range(n)]
    cd_lst = [list(map(int, input().split())) for _ in range(m)]
    point_lst = []

    for i in range(n):

        distance_lst = []
        for j in range(m):

            coordinate1 = ab_lst[i]
            coordinate2 = cd_lst[j]
            distance_lst.append(distance(coordinate1, coordinate2))

        minimum = min(distance_lst)
        for k in range(m):
            if distance_lst[k] == minimum:
                point_lst.append(k + 1)
                break

    for i in range(n):
        print(point_lst[i])


if __name__ == '__main__':
    main()

Solution (Python):
N,M = map(int,input().split())
place = [list(map(int,input().split())) for _ in range(N)]
check = [list(map(int,input().split())) for _ in range(M)]
for x,y in place:
    tmp = 10**9
    for i in range(M):
        dis = abs(x-check[i][0]) + abs(y-check[i][1])
        if tmp > dis:
            tmp = dis
            ans = i+1
    print(ans)

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

INF=float('inf')
ans=[[0,INF]]*N
for i in range(N):
  for j in range(M):
    x=abs(S[i][0]-C[j][0])
    y=abs(S[i][1]-C[j][1])
    if x+y<ans[i][1]:
      ans[i]=[j+1,x+y]
for i in range(N):
  print(ans[i][0])

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

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

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

Solution (Python):




import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 2
2 0
0 0
-1 0
1 0"""
        output = """2
1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 4
10 10
-10 -10
3 3
1 2
2 3
3 5
3 5"""
        output = """3
1
2"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5 5
-100000000 -100000000
-100000000 100000000
100000000 -100000000
100000000 100000000
0 0
0 0
100000000 100000000
100000000 -100000000
-100000000 100000000
-100000000 -100000000"""
        output = """5
4
3
2
1"""
        self.assertIO(input, output)


def resolve():
    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)]

    ans = []
    for s in S:
        D = float("inf")
        t = 0
        for i in range(M):
            d = abs(s[0]-C[i][0]) + abs(s[1]-C[i][1])
            if d < D:
                D = d
                t = i
        ans.append(t+1)

    for a in ans:
        print(a)


if __name__ == "__main__":
    
    resolve()

Solution (Python):
N, M = map(int, input().split())
ab = []
cd = []
for i in range(N):
  tmp = list(map(int, input().split()))
  ab.append(tmp)
for j in range(M):
  tmp = list(map(int, input().split()))
  cd.append(tmp)
for i in range(N):
  tmp = 10**10
  tmp2 = 0
  for j in range(M):
    if tmp > abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]):
      tmp = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
      tmp2 = j
  print(tmp2+1)

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

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

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

for a,b in AB:
    tmp_point = -1
    tmp_root = 100000000000
    for i,cd in enumerate(CD):
        c,d = cd
        if abs(a-c)+abs(b-d) < tmp_root:
            tmp_root = abs(a-c)+abs(b-d)
            tmp_point = i+1
    print(tmp_point)

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

Solution (Python):
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
cd=[list(map(int,input().split())) for _ in range(m)]
r=[]
for i in ab:
  x1,y1=i[0],i[1]
  temp=[]
  for j in cd:
    x2,y2=j[0],j[1]
    temp.append(abs(x1-x2)+abs(y1-y2))
  r.append(temp.index(min(temp))+1)
print(*r,sep='\n')

Solution (Python):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,m=nii()
ab=[lnii() for i in range(n)]
cd=[lnii() for i in range(m)]

ans=[]
for a,b in ab:
  min_dist=10**10
  for i in range(m):
    c,d=cd[i]
    if abs(a-c)+abs(b-d)<min_dist:
      t_ans=i
      min_dist=abs(a-c)+abs(b-d)
  ans.append(t_ans+1)

for i in ans:
  print(i)

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

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


stumo = [0]*N
for i in range(N):
    min_move = 10000000000000000000000000
    for j in range(M):
        min_his = min_move 
        mhd = abs(stu[i][0]-cp[j][0]) + abs(stu[i][1]-cp[j][1])
        min_move = min(min_move,mhd)
        if(min_move != min_his):
            stumo[i] = j+1

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

Solution (Python):
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N,M = MI()
ab = [tuple(MI()) for _ in range(N)]
cd = [tuple(MI()) for _ in range(M)]

for i in range(N):
    a,b = ab[i]
    min_dis = 10**10
    k = 100
    for j in range(M):
        c,d = cd[j]
        if min_dis > abs(a-c) + abs(b-d):
            k = j+1
            min_dis = abs(a-c) + abs(b-d)
    print(k)

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

n, m = map(int, input().split())
ab = []
cd = []
for _ in range(n):
    a, b = map(int, input().split())
    ab.append((a, b))
for _ in range(m):
    c, d = map(int, input().split())
    cd.append((c, d))
ans = []
for a, b in ab:
    t = 10**18
    checkpoint = -1
    for i, cdi in enumerate(cd):
        c, d = cdi
        dist = abs(a-c)+abs(b-d)
        if dist < t:
            t = dist
            checkpoint = (i+1)
    ans.append(checkpoint)
print(*ans, sep='\n')

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

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

ab=[[int(a) for a in input().split()]for _ in range(n)]

cd=[[int(a) for a in input().split()]for _ in range(m)]


INF=float("inf")
for (a,b) in ab:
  tmp=INF
  now=0
  for i,(c,d) in enumerate(cd):
    if tmp>abs(a-c)+abs(b-d):
      now=i+1
      tmp=abs(a-c)+abs(b-d)
    else:
      pass
    
  print(now)

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 i in range(n):
    x = 1 << 30
    y = -1
    a, b = ab[i]
    for j in range(m):
        c, d = cd[j]
        d = abs(a - c) + abs(b - d)
        if x > d:
            x = d
            y = j
    print(y + 1)

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)]
where=[]
for i in range(n):
    distance=10**9
    for j in range(m):
        if distance>abs(s[i][0]-c[j][0])+abs(s[i][1]-c[j][1]):
            distance=abs(s[i][0]-c[j][0])+abs(s[i][1]-c[j][1])
            w=j
    where.append(w+1)
[print(i) for i in where]

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

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

for a, b in AB:
    dist = 10**18
    ans = -1
    for i in range(M):
        c, d = CD[i]
        if abs(a-c)+abs(b-d)<dist:
            ans = i+1
            dist = abs(a-c)+abs(b-d)
    print(ans)

Solution (Python):
import numpy as np

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

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

result = np.zeros([m, n], dtype=np.int64)

cd = []
for i in range(m):
    c, d = map(int, input().split())
    for j, (a, b) in enumerate(ab):
        result[i, j] = abs(a - c) + abs(b - d)

print(*result.argmin(axis=0) + 1, sep="\n")

Solution (Python):
def LI():
    return list(map(int, input().split()))


def LIHW(h):
    return [list(map(int, input().split())) for _ in range(h)]


N, M = LI()
Nlist = LIHW(N)
Mlist = LIHW(M)
anslist = [0]*N
for i in range(N):
    a, b = Nlist[i]
    ans = 10**9
    for j in range(M):
        c, d = Mlist[j]
        kyori = abs(c-a)+abs(d-b)
        if ans > kyori:
            ansind = j+1
            ans = kyori
    anslist[i] = ansind

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

Solution (Python):
import sys

input = sys.stdin.readline

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

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

ans = []
for i in range(N):
    a, b = s[i]
    i_ans = -1
    tmp = float("inf")
    for j in range(M):
        c, d = g[j]
        dist = abs(c-a) + abs(d-b)
        
        if dist < tmp:
            i_ans = j
            tmp = dist
    ans.append(i_ans)

for a in ans:
    print(a+1)

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

for i in range(N):
    MIN = 10 ** 10
    index = -1
    for j in range(M):
        if MIN > abs(students[i][0] - points[j][0]) + abs(students[i][1] - points[j][1]):
            MIN = abs(students[i][0] - points[j][0]) + abs(students[i][1] - points[j][1])
            index = j
    print(index + 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)]
B.insert(0,0)
for i in range(N):
    a,b = A[i]
    dmin = 10**9
    ind = M
    for j in range(M,0,-1):
        c,d = B[j]
        dist = abs(a-c)+abs(b-d)
        if dist<=dmin:
            dmin = dist
            ind = j
    print(ind)

Solution (Python):
N,M = map(int,input().split())
point = []
target = []
ans = []
for i in range(N):
    person = list(map(int,input().split()))
    point.append(person)
for j in range(M):
    goal = list(map(int,input().split()))
    target.append(goal)
for k in point:
    check = []
    for l in target:
        a = 0
        a += abs(k[0]-l[0])+abs(k[1]-l[1])
        check.append(a)
    b = min(check)
    ans.append(check.index(b))
for m in ans:
    print(m+1)

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

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

for i in range(n):
    s = student[i]
    dist = float('inf')

    num=0
    for j in range(m):
        c=checkpoint[j]
        tmp = abs(s[0]-c[0]) + abs(s[1]-c[1])

        if tmp < dist:
            dist = tmp
            num=j+1

    print(num)

Solution (Python):
N,M = map(int,input().split())
X = []
for i in range(N):
  a,b = map(int,input().split())
  X.append((a,b))
C = []
for i in range(M):
  c,d = map(int,input().split())
  C.append((c,d))
ans = [0 for _ in range(N)]
INF = float("inf")
for i in range(N):
  MIN = INF
  check = -1
  for y in range(M):
    temp = abs(X[i][0]-C[y][0]) + abs(X[i][1]-C[y][1])
    if temp < MIN:
      MIN = temp
      check = y+1
  ans[i] = check
print(*ans,sep="\n")

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  

N,M = MI()
ab = [tuple(MI()) for _ in range(N)]
cd = [tuple(MI()) for _ in range(M)]

for i in range(N):
    a,b = ab[i]
    min_dis = 10**10
    k = 100
    for j in range(M):
        c,d = cd[j]
        if min_dis > abs(a-c) + abs(b-d):
            k = j+1
            min_dis = abs(a-c) + abs(b-d)
    print(k)

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

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


for a,b in abl:
    cmin = 10**10
    mini = -1
    for i,(c,d) in enumerate(cdl):
        v = abs(a-c)+abs(b-d)
        if v < cmin:
            cmin = v
            minc,mind = c,d
            mini = i+1
    print(mini)

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

Solution (Python):
N,M = map(int,input().split())
stu = []
for v in range(N):
    ai,bi = map(int,input().split())
    stu.append((v,ai,bi))
cp = []
for w in range(M):
    ci,di = map(int,input().split())
    cp.append((w,ci,di))

cp = cp[::-1]
ans = [0]*N

for i,x,y in stu:
    
    mindist = 10**16
    cp_num = 0
    for j,k,l in cp:
        dist = abs(x-k) + abs(y-l)
        if mindist >= dist:
            mindist = dist
            cp_num = j+1
    ans[i] = cp_num
for n in ans:
    print(n)

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 j in range(m):
    c[j], d[j] = map(int, input().split())
for i in range(n):
    e = []
    for j in range(m):
        e.append(abs(a[i] - c[j]) + abs(b[i] - d[j]))
    f = e.index(min(e))
    print(f + 1)

Solution (Python):

import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


n, m = zz()
A, B = [], []
for i in range(n):
    a, b = zz()
    A.append(a)
    B.append(b)
C, D = [], []
for i in range(m):
    c, d = zz()
    C.append(c)
    D.append(d)

dist = [[0]*m for i in range(n)]
for i in range(n):
    for j in range(m):
        dist[i][j] = abs(A[i] - C[j]) + abs(B[i] - D[j])


for i in range(n):
    print(np.argmin(dist[i])+1)

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

for j in range(m):
    c.append(list(map(int, input().split())))
    
for k in range(n):
    cnt = []
    for l in range(m):
        kyori = abs(s[k][0]-c[l][0])+abs(s[k][1]-c[l][1])
        cnt.append(kyori)
    print(cnt.index(min(cnt))+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())))
def Mandis(x1,x2,y1,y2):
    e=abs(x1-x2)+abs(y1-y2)
    return e
for i in range(N):
    g=0
    for j in range(M-1):
        if Mandis(ab[i][0],cd[j+1][0],ab[i][1],cd[j+1][1])<Mandis(ab[i][0],cd[g][0],ab[i][1],cd[g][1]):
            g=j+1
    print(g+1)

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

for i in range(n + m):
    x, y = map(int, input().split())
    lx.append(x)
    ly.append(y)

for i in range(n):
    r = []
    for j in range(n, m + n):
        r.append(abs(lx[i] - lx[j]) + abs(ly[i] - ly[j]))
    print(r.index(min(r)) + 1)

Solution (Python):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n,m = LI()
    student = []
    spot = []
    for _ in range(n):
        a,b = LI()
        student.append([a,b])

    for _ in range(m):
        c,d = LI()
        spot.append([c,d])
    inf = float("inf")
    for x,y in student:
        near = (0,inf)
        area_num = 1
        for s,t in spot:
            dist = abs(x-s) + abs(y-t)
            if near[1] > dist:
                near = (area_num,dist)
            area_num += 1
        print(near[0])
main()

Solution (Python):
def dis(a, b, c, d):
    num = abs(a - c) + abs(b - d)
    return num

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

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

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

As = []
for _ in range(0, N):
    x, y = input().split()
    As.append((int(x), int(y)))

Cs = []
for _ in range(0, M):
    x, y = input().split()
    Cs.append((int(x), int(y)))

for a in As:
    d = {}
    minI = -1
    minM = float('inf')
    for i, c in enumerate(Cs):
        ax, ay = a
        cx, cy = c
        m = abs(ax - cx) + abs(ay - cy)
        if m < minM:
            minI = i + 1
            minM = m

    print(minI)

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rf = lambda: map(float, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, m = rm()
stu = [rl() for _ in range(n)]
poi = [rl() for _ in range(m)]
for lis in stu:
    x, y = lis
    min_ = inf
    ans = ''
    for idx, li in enumerate(poi, 1):
        x1, y1 = li
        t = abs(x1-x)+abs(y1-y)
        if min_ > t:
            min_ = t
            ans = idx
    print(ans)

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

for i in range(n):
    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):
from sys import stdin
def input():
    return stdin.readline().strip()

n, m = map(int, input().split())
a, b, c, d = [], [], [], []
for _ in range(n):
    i, j = map(int, input().split())
    a.append(i)
    b.append(j)
for _ in range(m):
    i, j = map(int, input().split())
    c.append(i)
    d.append(j)

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

for i in l:
    print(i)

Solution (Python):
def minDistPoint(Student,List):
    ans_dist = 500000000
    res = 0
    for k,pos in List.items():
        dist = abs(Student[0]-pos[0])+abs(Student[1]-pos[1])
        if dist<ans_dist:
            ans_dist = dist
            res=k
    return res+1

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

cp = [0]*N

for i in range(len(AB)):
    cp[i] = minDistPoint(AB[i],CD)
    
for i in cp:
    print(i)