Problem:
 Score : 200 points    Problem Statement There are N students and M checkpoints on the xy -plane. The coordinates of the i -th student (1 \leq i \leq N) is (a_i,b_i) , and the coordinates of the checkpoint numbered j  (1 \leq j \leq M) is (c_j,d_j) . When the teacher gives a signal, each student has to go to the nearest checkpoint measured in Manhattan distance . The Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is |x_1-x_2|+|y_1-y_2| . Here, |x| denotes the absolute value of x . If there are multiple nearest checkpoints for a student, he/she will select the checkpoint with the smallest index. Which checkpoint will each student go to?      Constraints  1 \leq N,M \leq 50  -10^8 \leq a_i,b_i,c_j,d_j \leq 10^8  All input values are integers.         Input The input is given from Standard Input in the following format:  N  M  a_1  b_1  :  a_N  b_N  c_1  d_1  :  c_M  d_M       Output Print N lines. The i -th line (1 \leq i \leq N) should contain the index of the checkpoint for the i -th student to go.        Sample Input 1 2 2
2 0
0 0
-1 0
1 0      Sample Output 1 2
1  The Manhattan distance between the first student and each checkpoint is:   For checkpoint 1 : |2-(-1)|+|0-0|=3  For checkpoint 2 : |2-1|+|0-0|=1   The nearest checkpoint is checkpoint 2 . Thus, the first line in the output should contain 2 .  The Manhattan distance between the second student and each checkpoint is:   For checkpoint 1 : |0-(-1)|+|0-0|=1  For checkpoint 2 : |0-1|+|0-0|=1   When there are multiple nearest checkpoints, the student will go to the checkpoint with the smallest index. Thus, the second line in the output should contain 1 .       Sample Input 2 3 4
10 10
-10 -10
3 3
1 2
2 3
3 5
3 5      Sample Output 2 3
1
2  There can be multiple checkpoints at the same coordinates.       Sample Input 3 5 5
-100000000 -100000000
-100000000 100000000
100000000 -100000000
100000000 100000000
0 0
0 0
100000000 100000000
100000000 -100000000
-100000000 100000000
-100000000 -100000000      Sample Output 3 5
4
3
2
1

Solution (Python):
import sys


def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N, M = ISI()
ab = [list(ISI()) for _ in range(N)]
cd = [list(ISI()) for _ in range(M)]
for i in range(N):
    min = 1000000000000
    for j in range(M):
        n = abs(ab[i][0] - cd[j][0]) +  abs(ab[i][1] - cd[j][1])
        if min > n:
            min = n
            point = j+1
    print(point)

Solution (Python):

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

ans = [0] * N
for i in range(N): 
    D = [10 ** 10] * M
    D_hikaku = 10 ** 10
    for j in range(M): 

        D = abs(P[i][0]-C[j][0]) + abs(P[i][1]-C[j][1])
        if D < D_hikaku:
            D_hikaku = D
            ans[i] = j + 1
        else:
            pass

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

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

for i in range(N):
  min_calc=10e8+10e8
  min_num=N
  for j in range(M):
    calc = abs(a[i] - c[j]) + abs(b[i] - d[j])
    if calc < min_calc:
      min_calc = min(min_calc, calc)
      min_num = j+1
  print(min_num)

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])
ans = []
w = 1000000000000000000000
num = 0
for i in range(n):
    for x in range(m):
        result = abs(ab[i][0] - cd[x][0]) + abs(ab[i][1] - cd[x][1])
        if result < w:
            w = result
            num = x + 1
    ans.append(num)
    w = 1000000000000000000
for i in ans:
    print(i)

Solution (Python):
import sys
import copy
import string
import  math
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n, m = na()
s = []
p = []
for i in range(n):
    a, b = na()
    s.append((a, b))
for i in range(m):
    c, d = na()
    p.append((c, d))
for i in range(n):
    ans = float("inf")
    pt = 0
    for j in range(m):
        dif = abs(s[i][0] - p[j][0]) + abs(s[i][1] - p[j][1])
        if dif < ans:
            ans = dif
            pt = j + 1
    print(pt)

Solution (Python):
n,m = map(int,input().split())
ab = []
cd = []
for i in range(n):
    ab.append(list(map(int,input().split())))
for j in range(m):
    cd.append(list(map(int,input().split())))
for i in range(n):
    point = 0
    distance = 3*10**8
    for j in range(m):
        if distance > abs(cd[j][0]-ab[i][0]) + abs(cd[j][1]-ab[i][1]):
            distance = abs(cd[j][0]-ab[i][0]) + abs(cd[j][1]-ab[i][1])
            point = j
    print(point+1)

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

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

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

ans = [0 for _ in range(n)]
for i in range(n):
    stux = ab[i][0]
    stuy = ab[i][1]
    minz = 10 ** 9
    for j in range(m):
        pntx = cd[j][0]
        pnty = cd[j][1]
        if minz > abs(stux - pntx) + abs(stuy - pnty):
            ans[i] = j + 1
            minz = abs(stux - pntx) + abs(stuy - pnty)
for i in range(n):
    print(ans[i])

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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

ans = [0] * len(a)

for i in range(len(a)):
    for j in range(len(c)):
        if (abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1]) < abs(a[i][0] - c[ans[i]][0]) + abs(a[i][1] - c[ans[i]][1])):
            ans[i] = j

for i in ans:
    print(i+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)]
l=float('inf')
for i in range(n):
    for j in range(m):
        k=abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1])
        if k<l:
            l=k
            ans=j
    print(ans+1)
    l=float('inf')

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

for i in range(n):
  x, y = student[i]
  ans = 999999999
  ansnum = 0
  distance = 0
  for j in range(m):
    xc, yc = checkpoint[j]
    distance = abs(x-xc) + abs(y-yc)
    if ans - distance >0:
      ans = distance
      ansnum = j + 1
  print(ansnum)

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

distance = [[0 for i in range(M)] for j in range(N)]

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

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

for i in range(N):
    for j in range(M):
        distance[i][j] = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])

for i in range(N):
    print(distance[i].index(min(distance[i])) + 1)

Solution (Python):
def main():
    N, M = map(int, input().split())
    std = []
    for _ in range(N):
        a, b = map(int, input().split())
        std.append([a, b])
    chk = []
    for _ in range(M):
        c, d = map(int, input().split())
        chk.append([c, d])
    for i in range(N):
        min_d = float('inf')
        togo = None
        for j in range(M):
            d = abs(std[i][0]-chk[j][0]) + abs(std[i][1]-chk[j][1])
            if d < min_d:
                min_d = d
                togo = j+1
        print(togo)

if __name__ == '__main__':
    main()

Solution (Python):
N,M = map(int,input().split())
st = [list(map(int,input().split())) for _ in range(N)]
ch = [list(map(int,input().split())) for _ in range(M)]
for i in range(N):
    d = float("inf")
    for j in range(M):
        dj = abs(st[i][0]-ch[j][0])+abs(st[i][1]-ch[j][1])
        if d > dj:
            c = j+1
            d = dj
    print(c)

Solution (Python):
N, M = map(int, input().split())
AB = []
for _ in range(N):
    a, b = map(int, input().split())
    AB.append((a, b))
CD = []
for _ in range(M):
    c, d = map(int, input().split())
    CD.append((c, d))
for a, b in AB:
    i = min(range(M), key=lambda i: abs(a - CD[i][0]) + abs(b - CD[i][1]))
    print(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())) for _ in range(m)]
for i in range(n):
    dist = float('inf')
    index = None
    for j in range(m - 1, -1, -1):
        d = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if d <= dist:
            dist = d
            index = j
    print(index + 1)

Solution (Python):
import sys

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

for s in std:
    a = s[0]
    b = s[1] 
    tmp1 = sys.maxsize
    for i in range(len(cp)):
        tmp2 = abs(a - cp[i][0]) + abs(b - cp[i][1])
        if tmp2 < tmp1:
            tmp1 = tmp2
            ans = i
    print(ans+1)

Solution (Python):


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


N, M = map(int, input().split())
A = [] * N
B = [] * N
C = [] * M
D = [] * M

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

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

def get_dists(a, b):
    ret = []
    for i in range(M):

        ret.append(abs(a-C[i])+abs(b-D[i]))

    return ret

def nearest_idx(dists):
    near = float('inf')
    idx = -1
    for i in range(M):
        if near > dists[i]:
            near = dists[i]
            idx = i+1

    return idx


for i in range(N):
    dists = get_dists(A[i], B[i])
    print(nearest_idx(dists))

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):
  check = []
  for j in range(M):
    check.append(abs(AB[i][0] - CD[j][0]) + abs(AB[i][1] - CD[j][1]))
  print(check.index(min(check)) + 1)

Solution (Python):


import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n, m = map(int, input().split())

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

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

    for a,b in abl:
        checkpoints = sorted(cdl, key=lambda cd: abs(a - cd[0]) + abs(b - cd[1]))
        print(checkpoints[0][2] + 1)


if __name__ == '__main__':
    main()

Solution (Python):
n,m = map(int,input().split())
place = []
check = []
gap = []
g = 0
for i in range(n):
    place.append(list(map(int,input().split())))
for j in range(m):
    check.append(list(map(int,input().split())))
for i in range(n):
    for j in range(m):
        g = abs(place[i][0] - check[j][0]) + abs(place[i][1] - check[j][1])
        gap.append(g)
    print(gap.index(min(gap)) + 1)
    gap = []

Solution (Python):
import numpy as np

N, M = map(int, input().split())

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

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

for person in persons:
    distance_min=4*10**8+1
    number=0
    for i, position in enumerate(positions):
        distance_pp = np.abs(person[0]-position[0])+np.abs(person[1]-position[1])
        if distance_min> distance_pp:
            distance_min= distance_pp
            number=i+1
    print(number)

Solution (Python):
n,m=map(int,input().split())
ab=[]
cd=[]
for i in range(n):
    ab.append([int(j) for j in input().split()])
for i in range(m):
    cd.append([int(j) for j in input().split()])
a=[]
for i,j in ab:
    tmp=10**100
    ans=0
    k=1
    for x,y in cd:
        if tmp>abs(i-x)+abs(j-y):
            tmp=abs(i-x)+abs(j-y)
            ans=k
        k+=1
    a.append(ans)
for i in a:
    print(i)

Solution (Python):
n, m = map(int, input().split())
a = [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):
    dist_min = float('inf')
    dist_min_pos = 0
    for j in range(m):
        dist = abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1])
        if dist < dist_min:
            dist_min = dist
            dist_min_pos = j + 1
    print(dist_min_pos)

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):
    min=4*10**8
    num=0
    for j in range(m):
        d=abs(A[i][0]-B[j][0])+abs(A[i][1]-B[j][1])
        if d<min:
            min=d
            num=j+1
    print(num)

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

for abn in abns:
  ans=10**9
  num=10*9
  for j,abm in enumerate(abms):
    if ans>abs(abn[0]-abm[0])+abs(abn[-1]-abm[-1]):
      ans=abs(abn[0]-abm[0])+abs(abn[-1]-abm[-1])
      num=j+1
  print(num)

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

for i in range(n):
    d_min = 1000000000
    p_num = 0
    for j in range(m):
        cur_d = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if cur_d < d_min:
            d_min = cur_d
            p_num = j + 1
    print(p_num)

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

for i in range(m):
    cd1=input().split()
    cd.append((int(cd1[0]),int(cd1[1])))

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

Solution (Python):
n, m = map(int, input().split())
a = [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):
  dist = []
  for k in range(m):
    dist.append(abs(a[i][0]-c[k][0])+abs(a[i][1]-c[k][1]))
  print(dist.index(min(dist))+1)

Solution (Python):
n, m = map(int, input().split())
a = []
b = []
c = []
d = []
for i in range(n):
    _a, _b = map(int, input().split())
    a.append(_a)
    b.append(_b)
for i in range(m):
    _c, _d = map(int, input().split())
    c.append(_c)
    d.append(_d)
ans = [99 for i in range(n)]
for i in range(n):
    mini = 9999999999
    for j in range(m):
        mnhtn = abs(a[i]-c[j]) + abs(b[i]-d[j])
        if mnhtn < mini:
            mini = mnhtn
            ans[i] = j+1
for i in ans:
    print(i)

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 i in ab:
    m_d = 10 ** 9
    m_n = 0
    for k, j in enumerate(cd):
        if abs(i[0] -j[0]) + abs(i[1] - j[1]) < m_d:
            m_d = abs(i[0] -j[0]) + abs(i[1] - j[1])
            m_n = k + 1
    print(m_n)

Solution (Python):
N,M = map(int, input().strip().split(' '))
persons = [list(map(int, input().strip().split(' '))) for _ in range(N)]
checkpoints = [list(map(int, input().strip().split(' '))) for _ in range(M)]

def distance(person, checkpoint):
  return sum(abs(a-b) for a,b in zip(person, checkpoint))
  
for person in persons:
  print(sorted([[distance(person, checkpoint), i+1] for i,checkpoint in enumerate(checkpoints)])[0][1])

Solution (Python):
n,m = map(int,input().split())
s = [tuple(map(int,input().split())) for i in range(n)]
c = [tuple(map(int,input().split())) for i in range(m)]
a = [0] * n
for i,sp in enumerate(s):
  m = 10**9
  for j,cp in enumerate(c):
    d = abs(sp[0]-cp[0]) + abs(sp[1]-cp[1])
    if d < m:
      m = d
      a[i] = j+1
print('\n'.join(map(str,a)))

Solution (Python):
import numpy as np
N, M  = map(int, input().split())
A = np.array([list(map(int, input().split())) for i in range(N)])
B = np.array([list(map(int, input().split())) for i in range(M)])
for i in A:
  L2 = [np.linalg.norm(i-b, ord=1) for b in B]
  print (L2.index(min(L2))+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 ab:
  nearst = 10 ** 9
  for j in range(m - 1, -1, -1):
    mandist = abs(i[0] - cd[j][0]) + abs(i[1] - cd[j][1])
    if mandist <= nearst:
      nearst = mandist
      num = j + 1
  print(num)

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 a,b in A:
  l=[abs(a-c)+abs(b-d) for c,d in C]
  print(l.index(min(l))+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)]

for i in range(N):
    min_dis = float("inf")
    min_dis_idx = 0
    for j in range(M):
        dis = abs(s[i][0]-c[j][0]) + abs(s[i][1]-c[j][1])
        if min_dis > dis:
            min_dis = dis
            min_dis_idx = j+1
    print(min_dis_idx)

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_diff = 10 ** 9
    for j in range(M):
        diff = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if min_diff > diff:
            min_diff = diff
            ans = j + 1
    print(ans)

Solution (Python):
N, M = map(int, input().split())
ABs = []
for i in range(N):
  a, b = map(int, input().split())
  ABs.append((a, b))
CDs = []
for i in range(M):
  c, d = map(int, input().split())
  CDs.append((c, d))
for a, b in ABs:
  r = -1
  mindist = 1000000000
  for i in range(M):
    c, d = CDs[i]
    dist = abs(c-a)+abs(d-b)
    if dist < mindist:
      r = i
      mindist = dist
  print(r+1)

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

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

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

for n in range(N):
  a,b = students[n]
  index = -1
  best = 99999999999
  for m in range(M):
    c,d = points[m]
    dist = abs(a-c)+abs(b-d)
    if dist<best:
      best = dist
      index = m
  print(index+1)

Solution (Python):
n,m=map(int,input().split())
pos=[]
for _ in range(n):
    x,y=map(int,input().split())
    pos.append((x,y))
dist=[10**9]*n
ans=[0]*n
for goal in range(m):
    p,q=map(int,input().split())
    for i in range(n):
        x,y=pos[i]
        d=abs(x-p)+abs(y-q)
        if d<dist[i]:
            dist[i]=d
            ans[i]=goal+1

for i in ans:
    print(i)

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

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

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

arr=[0]*len(ab)
for i in range(len(ab)):
  min_d=float('inf')
  for j in range(len(cd)):
    d=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])	
    if d<min_d:
      min_d=d
      arr[i]=j+1
print(*arr,sep='\n')

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

for ab in ablist:
  d=float("inf")
  index=-1
  tmp=0
  for n,cd in enumerate(cdlist):
    tmp=abs(ab[0]-cd[0])+abs(ab[1]-cd[1])
    if tmp<d:
      d=tmp
      index=n
  print(index+1)

Solution (Python):
import sys
n,m = list(map(int, input().split()))
students = [list(map(int, input().split())) for _ in range(n)]
ckeckpoints = [list(map(int, input().split())) for _ in range(m)]
for i, student in enumerate(students):
  min_j = 0
  min_norm = sys.maxsize
  for j, ckeckpoint in enumerate(ckeckpoints):
    norm = abs(student[0] - ckeckpoint[0]) + abs(student[1] - ckeckpoint[1])
    if norm < min_norm:
      min_j = j
      min_norm = norm
  print(min_j+1)

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

x = []
ans = []
for i in a:
  for j in c:
    x.append(abs(i[0]-j[0])+abs(i[1]-j[1]))


  print(x.index(min(x))+1)
  x = []

Solution (Python):

import sys
INF = float("inf")


def solve(N: int, M: int, a: "List[int]", b: "List[int]", c: "List[int]", d: "List[int]"):
    
    for aa, bb in zip(a, b):
        m, mi = INF, -1
        for i, (cc, dd) in enumerate(zip(c, d)):
            dist = abs(aa-cc)+abs(bb-dd)
            if m > dist:
                m = dist
                mi = i
        print(mi+1)

    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())
z=[list(map(int,input().split())) for i in range(N)]
c=[list(map(int,input().split())) for i in range(M)]
for i in z:
    d=10**9
    ans=C=0
    for j in c:
        C+=1
        k=abs(i[0]-j[0])+abs(i[1]-j[1])
        if d>k:
            ans=C
            d=k
    print(ans)

Solution (Python):
N, M = map(int,input().split())
st = [[int(i) for i in input().split()] for j in range(N)]
cp = [[int(i) for i in input().split()] for j in range(M)]
for i in st:
    L = [abs(i[0] - j[0])+abs(i[1] - j[1]) for j in cp]
    m = min(L)
    print(L.index(m)+1)

Solution (Python):
import numpy as np
N,M = map(int,input().split())
s = np.zeros([N,2])
c = np.zeros([M,2])

for i in range(N):
  s[i,:] = np.array(list(map(int,input().split())))
for i in range(M):
  c[i,:] = np.array(list(map(int,input().split())))
  
for i in range(N):
  temp_c = np.abs(c-s[i,:])
  temp_c = np.sum(temp_c,axis=1)
  print(np.argmin(temp_c)+1)

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

for i in range(N):
  d = []
  for j in range(M):
    d_x = abs(S[i][0] - P[j][0])
    d_y = abs(S[i][1] - P[j][1])
    d.append(d_x + d_y)
  print(d.index(min(d)) + 1)

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

ans = []
for i in range(N):
  distances = []
  for j in range(M):
    d_x = abs(students[i][0] - points[j][0])
    d_y = abs(students[i][1] - points[j][1])
    distances.append(d_x + d_y)
  ans.append(distances.index(min(distances)) + 1)

for x in ans:
  print(x)

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 




 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,M = inputMap()
    ab = []
    for i in range(N):
        a,b = inputMap()
        ab.append((a,b))
        
    cd = []
    for i in range(M):
        c,d = inputMap()
        cd.append((c,d))
        
    man = []
    for i,val in enumerate(ab):
        a,b = val
        tmp = []
        for j,vol in enumerate(cd):
            c,d = vol
            tmp.append(abs(a-c)+abs(b-d))
        
        tmptmp = 0
        ind = 0
        for k, v in enumerate(tmp):
            if k == 0:
                tmptmp = v
            else:
                if tmptmp > v:
                    tmptmp = v
                    ind = k
        print(ind+1)
        
        
    
if __name__ == "__main__":
	main()

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

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

chk = []
for j in range(m):
  chk.append(list(map(int,input().split())))

min_chk=[[float('inf')]*2]*n
for i in range(n):
    min_index=0
    for j in range(m):
        if (abs(std[i][0]-chk[j][0])+abs(std[i][1]-chk[j][1])) < (abs(std[i][0]-min_chk[i][0])+abs(std[i][1]-min_chk[i][1])):
            min_chk[i]=chk[j]
            min_index=j
    print(min_index+1)

Solution (Python):
import sys

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

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

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

for i in range(n):
    min = sys.maxsize
    ans = -1
    for j in range(m):
        distance = abs(students[i][0] -
                       checkpoints[j][0]) + abs(students[i][1] -
                                                checkpoints[j][1])
        if min > distance:
            min = distance
            ans = j + 1
    print(ans)

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

ans = []
for s in students:
  dist = float("inf")
  nearest = -1
  for idx, c in enumerate(checkpoints):
    d_i = abs(int(s[0])-int(c[0])) + abs(int(s[1])-int(c[1]))
    if dist > d_i:
      dist = d_i
      nearest = idx+1
  ans.append(nearest)
for a in ans:
  print(a)

Solution (Python):
n,m = map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(n):
    A,B=map(int,input().split())
    a.append(A)
    b.append(B)
for j in range(m):
    C,D=map(int,input().split())
    c.append(C)
    d.append(D)
ans=[]
for k in range(n):
    L=[]
    for l in range(m):
        L.append(abs(a[k]-c[l])+abs(b[k]-d[l]))
    ans.append(L.index(min(L))+1)
for o in ans:
    print(o)

Solution (Python):
N,M = map(int,raw_input().split())
A = []
T = []
for i in range(0,N):
        a,b = raw_input().split()
        A.append(a)
        A.append(b)
        T.append(A)
        A = []
B = []
S = []
for i in range(0,M):
        c,d = raw_input().split()
        B.append(c)
        B.append(d)
        S.append(B)
        B = []
ans = []
for i in range(0,N):
        for j in range(0,M):
                t = abs(int(T[i][0])-int(S[j][0])) + abs(int(T[i][1])-int(S[j][1]))
                ans.append(t)
                
        print ans.index(min(ans))+1
        ans = []

Solution (Python):
n,m = map(int,input().split())
std = []
for i in range(n):
  std.append(list(map(int,input().split())))
chk = []
for j in range(m):
  chk.append(list(map(int,input().split())))
for i in range(n):
  can = []
  for j in range(m):
    can.append([abs(std[i][0]-chk[j][0])+abs(std[i][1]-chk[j][1]),j+1])
  print(min(can)[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)]
ans = []
for i in range(n):
    mm = 10 ** 9
    nn = 0
    for j in range(m):
        if mm > abs(a[i][0] - b[j][0]) + abs(a[i][1] - b[j][1]):
            mm = abs(a[i][0] - b[j][0]) + abs(a[i][1] - b[j][1])
            nn = j + 1
    ans.append(nn)
for i in range(n):
    print(ans[i])

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

ab = []
for _ 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, i + 1])

INF = 10 ** 9
def check_point(a, b): 
    distance = INF
    ans = 1
    for c, d, i in cd:
        if distance > abs(a - c) + abs(b - d):
            distance = abs(a - c) + abs(b - d)
            ans = i
    return ans

for a, b in ab:
    print (check_point(a, b))

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

ans = []
for i in range(n):
    dis = float("inf")
    index = 0
    for j in range(m):
        if dis > abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1]):
            dis = abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1])
            index = j+1
    ans.append(index)

for i in ans:
    print(i)

Solution (Python):


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

n, m = [int(el) for el in input().split(' ')]
S = []
for i in range(n):
    a, b = input().split(' ')
    S.append((int(a), int(b)))

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


for i in range(n):
    D = []
    for j in range(m):
        D.append(dist(S[i], T[j]))
    print(D.index(min(D))+1)

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

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

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

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