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



for i,j in l_n:
    distance=0
    cnt = 0
    ans = float ( "inf" )
    for k,l in enumerate(l_m,1):
        a,b=l
        distance=abs(i-a)+abs(j-b)
        if ans>distance:
            ans=min(ans,distance)
            cnt=k
    print(cnt)

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



for i,j in l_n:
    distance=0
    cnt = 0
    ans = float ( "inf" )
    for k,l in enumerate(l_m):
        a,b=l
        distance=abs(i-a)+abs(j-b)
        if ans>distance:
            ans=min(ans,distance)
            cnt=k+1
    print(cnt)

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

for i in range(n):
  d = 10**9
  h = 0
  for j in range(m):
    if d > (abs(num_list[i][0]-check_list[j][0])+abs(num_list[i][1]-check_list[j][1])):
      d = abs(num_list[i][0]-check_list[j][0])+abs(num_list[i][1]-check_list[j][1])
      h = j+1
  print(h)

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 i in S:
  ans = 0
  k = 10 ** 10
  for j in range(M):
    n = abs(i[0] - C[j][0]) + abs(i[1] - C[j][1])
    if k > n:
      k = n
      ans = j + 1
  else:
    print(ans)

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

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

for i in range(n):
  ans = 0
  k = 10**9
  for j in range(m):
    t = abs(pos[i][0] - check[j][0]) + abs(pos[i][1] - check[j][1])
    if k > t:
      k = t
      ans = j + 1
  print(ans)

Solution (Python):
import math
import collections
from sys import exit
from itertools import product

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m  = mi()
ab = [li() for _ in range(n)]
cd = [li() for _ in range(m)]

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

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

for i in range(n):
  sd.append([int(j) for j in input().split()])
for i in range(m):
  cp.append([int(j) for j in input().split()])  
  
dist = [[0 for i in range(m)] for j in range(n)]

for i in range(n):
  for j in range(m):
    dist[i][j] = abs(sd[i][0] - cp[j][0]) + abs(sd[i][1] - cp[j][1])
    
for i in range(n):
  print(dist[i].index(min(dist[i]))+1)

Solution (Python):



from math import gcd
from itertools import combinations,permutations,accumulate, product 

from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq














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


INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
n,m = readInts()
N = [readInts() for _ in range(n)]
M = [readInts() for _ in range(m)]
for a,b in N:
    pos = INF
    ans = None
    for i,(x,y) in enumerate(M):
        if abs(a-x) + abs(b-y) < pos:
            pos = abs(a-x)+abs(b-y)
            ans = i+1
    print(ans)

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


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
    min_dist = float("inf")
    for j in range(M):
        if (d := dist(AB[i], CD[j])) < min_dist:
            ans = j
            min_dist = d
    print(ans + 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)]
ans = []
INF = 10**9+7
for x in s:
  d = INF
  ind = INF
  for i,y in enumerate(c):
    exd = d
    d = min(d,abs(x[0]-y[0])+abs(x[1]-y[1]))
    if d != exd:
      ind = i
  ans.append(ind+1)
for x in ans:
  print(x)

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):
	ans=[]
	for j in range(M):
		tmp=abs(A[i]-C[j])+abs(B[i]-D[j])
		ans.append(tmp)
	T=len(ans)
	for k in range(T):
		if ans[k]==min(ans):
			print(k+1)
			break

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


for x in X:
    d1 = sum(x)
    d2 = x[0] - x[1]
    z = 10 ** 9
    for i, y in enumerate(Y, 1):
        D1 = sum(y)
        D2 = y[0] - y[1]
        Z = max(abs(D1 - d1), abs(D2 - d2))
        if z > Z:
            z = Z
            ans = i
    print(ans)

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

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

Solution (Python):
n, m = map(int, input().split())
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 a, b in AB:
    min_ = 10**18
    j = -1
    for i, (c, d) in enumerate(CD):
        x = abs(c-a)+abs(d-b)
        if x < min_:
            j = i+1
            min_ = x
    print(j)

Solution (Python):
from typing import List


def manhattan_distance(student: List[int], check_point: List[int]) -> int:
    return abs(check_point[0] - student[0]) + abs(check_point[1] - student[1])


def answer(n: int, m: int, students: List[List[int]], check_points: List[List[int]]) -> str:
    students_destination = []
    for student in students:
        mds = {}
        for i, check_point in enumerate(check_points, start=1):
            md = manhattan_distance(student, check_point)
            if md not in mds.keys():
                mds[md] = str(i)
        students_destination.append(mds[min(mds.keys())])

    return '\n'.join(students_destination)


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)]
    print(answer(n, m, ab, cd))


if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())
Nlist, Mlist = [], []
res = []

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

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

for i in range(N):
    res = 0
    mini = float('inf')
    for j in range(M):
        calc = abs(Nlist[i][0] - Mlist[j][0]) + abs(Nlist[i][1] - Mlist[j][1])
        if calc < mini:
            mini = calc
            res = j+1
    print(res)

Solution (Python):
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq
import sys
n,m = ma()
ckp = []
st = []

for i in range(n):
    st.append(lma())
for i in range(m):
    ckp.append(lma())
for a,b in st:
    tmp=10**15
    ans=0
    for i  in range(m):
        c,d=ckp[i]
        if tmp>abs(a-c)+abs(b-d):
            tmp=abs(a-c)+abs(b-d)
            ans=i+1
    print(ans)

Solution (Python):
n,m = map(int,input().split())
ab = [0]*n
cd = [0]*m

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

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

def check(a,b):
    x = a[0] - b[0]
    y = a[1] - b[1]
    if x < 0:
        x = -x
    if y < 0:
        y = -y
    return x + y

for a in al:
    min = 1000000000
    cnt = 1
    for b in bl:
        tmp = check(a,b)
        if tmp < min:
            ans = cnt
            min = tmp
        cnt += 1
    print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

for a_p_b, a_m_b in students:
    current_distance = 10 ** 10
    current_point = None
    for i, c_d in enumerate(checkpoints):
        c_p_d, c_m_d = c_d
        if max(abs(a_p_b - c_p_d), abs(a_m_b - c_m_d)) < current_distance:
            current_point = i + 1
            current_distance = max(abs(a_p_b - c_p_d), abs(a_m_b - c_m_d))
    print(current_point)

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

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

Solution (Python):
lst = input().split()

N = int(lst[0])
M = int(lst[1])

students = []
checkpoints = []

for i in range(N):
   students.append(input().split())

for i in range(M):
   checkpoints.append(input().split())

def distance(P, Q):
   return abs(int(P[0]) - int(Q[0])) + abs(int(P[1]) - int(Q[1]))

for s in students:
   l1 = [10 ** 10]
   l2 = [0]
   for i in range(M):
      if distance(s, checkpoints[i]) < l1[-1]:
         l1.append(distance(s, checkpoints[i]))
         l2.append(i+1)
   print(l2[-1])

Solution (Python):
N, M = map(int, input().split())
ab = []
for _ in range(N):
    ab.append(list(map(int, input().split())))
cd = []
for _ in range(M):
    cd.append(list(map(int, input().split())))
    
for x in ab:
    a = x[0]
    b = x[1]
    cnt = []
    for y in cd:
        c = y[0]
        d = y[1]
        k = abs(a-c)+abs(b-d)
        cnt.append(k)
    print(cnt.index(min(cnt))+1)

Solution (Python):
def f(gx,gy):
    ans = 10**9
    no = 0
    for i in range(m):
        tmp = abs(gx-checkpoint[i][0]) + abs(gy-checkpoint[i][1])
        if tmp < ans:
            ans = tmp
            no = i
    return no+1

n,m = map(int,input().split())
gakusei = []
for i in range(n):
    x,y = map(int,input().split())
    gakusei.append([x,y])
checkpoint = []
for j in range(m):
    x,y = map(int,input().split())
    checkpoint.append([x,y])


for i in range(n):
    print(f(gakusei[i][0],gakusei[i][1]))

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

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

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

for i in range(n):
    min_dist = 10 ** 16
    c_index = 0
    for j in range(m):
        dist = abs(s_pos[i][0] - c_pos[j][0]) + abs(s_pos[i][1] - c_pos[j][1])
        if dist < min_dist:
            min_dist = dist
            c_index = j + 1
    print(c_index)

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)]
ans=[]
for i in range(n):
  dis = 10**9
  plc = -1
  for j in range(m):
    if dis > abs(AB[i][0]-CD[j][0])+abs(AB[i][1]-CD[j][1]):
      plc = j+1
      dis = abs(AB[i][0]-CD[j][0])+abs(AB[i][1]-CD[j][1])
  ans.append(plc)
for i in range(n):
  print(ans[i])

Solution (Python):
n,m = map(int,input().split())
st = []
co = []
for i in range(n):
  a,b = map(int,input().split())
  st.append([a,b])
for i in range(m):
  c,d = map(int,input().split())
  co.append([c,d])
for a,b in st:
  tmp = 10**9
  output = 0
  for i in range(m):
    if tmp > (new:=abs(a-co[i][0])+abs(b-co[i][1])):
      output = i+1
      tmp = new
  print(output)

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

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

for i in range(n):
    distance = 10000000000
    for j in range(m):
        temp = abs(int(a[i][0]) - int(b[j][0])) + abs(int(a[i][1]) - int(b[j][1]))
        if distance > temp:
            ans = j + 1
        distance = min(temp,distance)
    print(ans)

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

for ax, ay in a:
  c = []
  for bx, by in b:
    c.append(abs(bx-ax)+abs(by-ay))
  print(c.index(min(c)) + 1)

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

student = [None]*n
for i in range(n):
  student[i] = tuple(map(int, input().split()))

point = [None]*m
for i in range(m):
  point[i] = tuple(map(int, input().split()))

for i in range(n):
  dist = pow(10, 9)
  ans = 0
  x, y = student[i]
  for j in range(m):
    sub = abs(point[j][0]-x) + abs(point[j][1]-y)
    if dist > sub:
      dist = sub
      ans = j+1
  print(ans)

Solution (Python):
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for p in range(n)]
cd = [list(map(int, input().split())) for q in range(m)]
for i in range(n):
    x = 10**10
    ans = 0
    for j in range(m):
        if abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]) < x:
            ans = j+1
            x = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
    print(ans)

Solution (Python):
n,m = map(int,input().split())
stu = []
che = []
kyori = []
ans = []
for _ in range(n):
  stu.append(list(map(int,input().split())))
for _ in range(m):
  che.append(list(map(int,input().split())))
for x in range(n):
  for y in range(m):
    kyori.append(abs(stu[x][0]-che[y][0])+abs(stu[x][1]-che[y][1]))
  z = min(kyori)
  ans.append(kyori.index(z)+1)
  kyori = []
for i in range(len(ans)):
  print(ans[i])

Solution (Python):
n, m = map(int,input().split())
s_x_plus_y = []
s_x_minus_y = []
p_x_plus_y = []
p_x_minus_y = []

for student in range(n):
    x, y = map(int,input().split())
    s_x_plus_y.append(x + y)
    s_x_minus_y.append(x - y)

for i in range(m):
    x, y = map(int,input().split())
    p_x_plus_y.append(x + y)
    p_x_minus_y.append(x - y)


for i in range(n):
    p_dist = []
    for j in range(m):
        p1 = abs(s_x_plus_y[i] - p_x_plus_y[j])
        p2 = abs(s_x_minus_y[i] - p_x_minus_y[j])
        d = max(p1, p2)
        p_dist.append(d)
    print(p_dist.index(min(p_dist))+1)

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 range(n):
  min_dist = 10**18
  idx = 0
  for j in range(m):
    dist = abs(P[i][0]-C[j][0]) + abs(P[i][1]-C[j][1])
    if min_dist > dist:
      idx = j + 1
      min_dist = dist
  print(idx)

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 range(n):
  d = 10**18
  t = 0
  for j in range(m):
    dist = abs(P[i][0]-C[j][0]) + abs(P[i][1]-C[j][1])
    if d > dist:
      t = j
      d = dist
  print(t+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 i in range(N):
  dist = float("inf")
  ans = 0
  a,b = ab[i][0],ab[i][1]
  
  for j in range(M)[::-1]:
    c,d = cd[j][0],cd[j][1]
    if abs(a-c) + abs(b-d) <= dist:
      dist = abs(a-c) + abs(b-d)
      ans = j + 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 i in range(m):
    c[i],d[i]=map(int,input().split())

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

Solution (Python):
N, M = map(int, input().split())
X = []
for i in range(N):
    x = list(map(int, input().split()))
    X.append(x)
Y = []
for i in range(M):
    y = list(map(int, input().split()))
    Y.append(y)


for i in X:
    len = []
    for j in Y:
        len.append(abs(i[0]-j[0])+abs(i[1]-j[1]))
    print(len.index(min(len))+1)

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

def distance(x,y,i,j):
    return abs(x-i) + abs(y-j)

for a,b in ab:
    
    dists = [distance(a, b, c, d) for c,d in cd]
    print(dists.index(min(dists)) + 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 i in range(n):
    num = 0
    ans = float('inf')
    for j in range(m):
        man = abs(ab[i][0]-cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if man < ans :
            ans = man
            num = j
    print(num+1)

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

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

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):
    shortest = 4*10**8 + 5
    for j in range(m):
        distance = abs(a[i][0] - b[j][0]) + abs(a[i][1] - b[j][1])
        if distance < shortest:
            idx = j
            shortest = distance
    print(idx + 1)

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

for i in range(N):
    k=0
    d=abs(ab[i][0]-cd[0][0])+abs(ab[i][1]-cd[0][1])
    for j in range(1,M):
        if abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])<d:
            k=j
            d=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
    print(k+1)

Solution (Python):
N, M = map(int, input().split())
A = []
B = []
for i in range(N):
  A.append(list(map(int, input().split())))
for i in range(M):
  B.append(list(map(int, input().split())))
for i in range(N):
  ans = M
  d = abs(A[i][0] - B[M-1][0]) + abs(A[i][1] - B[M-1][1])
  for j in range(M-2, -1, -1):
    dis = abs(A[i][0] - B[j][0]) + abs(A[i][1] - B[j][1])
    if d >= dis:
      d = dis
      ans = j + 1
  print(ans)

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

targets = [list(map(int, input().split())) for i in range(m)]
x = 0
snumber = [(0, x)] * n
  
def md(s, t):
  d = abs(s[0] - t[0]) + abs(s[1] - t[1])
  return d

for i in range(n):
  x = 4 * 10 ** 8
  for j in range(m):    
    if x > md(students[i], targets[j]):
      x = md(students[i], targets[j])
      snumber[i] = (j+1, md(students[i], targets[j]))
      
for i in range(n):      
  print(snumber[i][0])

Solution (Python):
n, m = map(int, input().split())
al = list(list(map(int, input().split())) for _ in range(n))
cl = list(list(map(int, input().split())) for _ in range(m))

for a in al:
    ans = 1001001001
    no = 0
    for i in range(m):
        dis = abs(a[0]-cl[i][0])+abs(a[1]-cl[i][1])
        if dis < ans:
            ans = dis
            no = i
    print(no+1)

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

for a,b in ab:
  cpt=-1
  mind=10**9
  for j in range(len(cd)):
    c,d=cd[j]
    d=abs(a-c)+abs(b-d)
    if d<mind:
      cpt=j+1
      mind=min(mind,d)
  print(cpt)

Solution (Python):
import itertools
url = "https://atcoder.jp//contests/abc057/tasks/abc057_a"

def main():
    n, m = list(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(len(ab)):
        dist = []
        for k in range(len(cd)):
            tmp = abs(ab[i][0] - cd[k][0]) + abs(ab[i][1] - cd[k][1])
            dist.append(tmp)
        print(dist.index(min(dist)) + 1)


if __name__ == '__main__':
    main()

Solution (Python):
n,m = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
b = [list(map(int,input().split())) for i in range(m)]
for i in range(n):
    c = float("inf")
    e = 0
    g = 0
    for j in range(m):
        d = abs(a[i][0]-b[j][0])+abs(a[i][1]-b[j][1])
        g+=1
        if d <c:
            c,e=d,g
    print(e)

Solution (Python):
n,m = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
b = [list(map(int,input().split())) for i in range(m)]
for i in range(n):
    c = float("inf")
    e = 0
    g = 0
    for j in range(m):
        d = abs(a[i][0]-b[j][0])+abs(a[i][1]-b[j][1])
        g+=1
        if d <c:
            c,e=d,g
    print(e)

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

    for ab in ab_list:
        a = ab[0]
        b = ab[1]
        min_diff = 10 ** 9
        ans = 0
        for i in range(m):
            c = cd_list[i][0]
            d = cd_list[i][1]
            diff = abs(a - c) + abs(b - d)
            if diff < min_diff:
                min_diff = diff
                ans = i + 1
        print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right 
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return map(int,input().split())
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

N,M = mint()
student = [0]*N
point = [0]*M
for i in range(N):
    x,y = mint()
    student[i] = (x,y)
for j in range(M):
    x,y = mint()
    point[j] = (x,y)
    
ans = [0]*N
for i in range(N):
    x1,y1 = student[i]
    tmp = INF
    k = 0
    for j in range(M):
        x2,y2 = point[j]
        if abs(x1-x2)+abs(y1-y2)<tmp:
            tmp = abs(x1-x2)+abs(y1-y2)
            k = j+1
    ans[i] = str(k)

lprint(ans)

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

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

for i in range(n):
  num=0
  ans=10**10
  for j in reversed(range(m)):
    a=a_lis[i]
    c=c_lis[j]
    num=abs(a[0]-c[0])+abs(a[1]-c[1])
    ans=min(ans,num)
    if num==ans:
      cnt=j+1
  print(cnt)

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):
N, M = map(int, input().split())
ab = tuple(tuple(a for a in map(int, input().split())) for _ in range(N))
cd = tuple(tuple(a for a in map(int, input().split())) for _ in range(M))
for i in range(N):
	ckp = 1
	dist_min = 10**9
	for j in range(M):
		dist = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
		if dist < dist_min:
			dist_min = dist
			ckp = j + 1
	print(ckp)

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

def main():
    n, m = map(int, input().split())
    a_b = [input().split() for i in range(n)]
    c_d = [input().split() for i in range(m)]

    for i in range(n):
        temp = []
        for j in range(m):
            temp.append(abs(int(a_b[i][0])-int(c_d[j][0]))+abs(int(a_b[i][1])-int(c_d[j][1])))
        else:
            print(temp.index(min(temp))+1)


        
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 j in range(m)]
for i in range(n):
  dis=float('inf')
  ch=0
  for j in range(m):
    if dis>abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]):
      dis=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
      ch=j
  print(ch+1)

Solution (Python):
n,m = map(int, input().split())
st = []
pt = []
ch = []
for i in range(n):
  st.append(list(map(int, input().split())))
for i in range(m):
  pt.append(list(map(int, input().split())))
for j in st:
  for k in pt:
    d = abs(j[0]-k[0]) + abs(j[1]-k[1])
    ch.append(d)
  print(ch.index(min(ch))+1)
  ch = []

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

for i in range(n):
    distance = 0
    shortest_cp = 0
    for j in range(m):
        if j == 0:
            distance = 1
            shortest_cp = abs(st[i][0]-cp[j][0]) + abs(st[i][1]-cp[j][1])
        else:
            if (abs(st[i][0]-cp[j][0]) + abs(st[i][1]-cp[j][1])) < shortest_cp:
                distance = j + 1
                shortest_cp = abs(st[i][0]-cp[j][0]) + abs(st[i][1]-cp[j][1])
                
    print(distance)

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

for i in range(N):
    idx = 1
    mindis = abs(students[i][0]-checkPoints[0][0])+ abs(students[i][1]-checkPoints[0][1])
    sx,sy = students[i]
    for j in range(1,M):
        cx,cy = checkPoints[j]
        distance = abs(sx-cx)+ abs(sy-cy)
        if mindis > distance:
            idx = j+1
            mindis = distance
    print(idx)

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

for i in range(N):
    idx = -1
    mindis = 3*10**8
    sx,sy = students[i]
    for j in range(M):
        cx,cy = checkPoints[j]
        distance = abs(sx-cx)+ abs(sy-cy)
        if mindis > distance:
            idx = j+1
            mindis = distance
    print(idx)