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())
stu=[]
poi=[]
for i in range(n):
    a,b=map(int,input().split())
    stu.append([a,b])
for i in range(m):
    a,b=map(int,input().split())
    poi.append([a,b])
for i in stu:
    ans=float("inf")
    ans_index=0
    ans_lis=[abs(i[0]-j[0])+abs(i[1]-j[1]) for j in poi]
    print(ans_lis.index(min(ans_lis))+1)

Solution (Python):
N,M = map(int,input().split())
stu_loc=[list(map(int,input().split())) for i in range (N)]
ch_loc=[list(map(int,input().split())) for i in range (M)]
for i in range(N):
    dist = 10**9
    num = 100
    for j in range(M):
        
        if dist>abs(stu_loc[i][0]-ch_loc[j][0])+abs(stu_loc[i][1]-ch_loc[j][1]):
            dist=abs(stu_loc[i][0]-ch_loc[j][0])+abs(stu_loc[i][1]-ch_loc[j][1])
            num=j
    print(num+1)

Solution (Python):
import numpy as np,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M = LI()
ab = np.array([LI() for _ in range(N)])
cd = np.array([LI() for _ in range(M)])
for x in ab:
    print(np.abs(cd-x).sum(axis=1).argmin()+1)

Solution (Python):
N,M=list(map(int,input().split()))
l=[]
for i in range(N):
   l.append(list(map(int,input().split())))
point=[]
for i in range(M):
   point.append(list(map(int,input().split())))
for i in range(N):
   X1,Y1=l[i]
   ans=float("INF")
   f_ans=0
   for j in range(M):
      X2,Y2=point[j]
      distance=abs(X1-X2)+abs(Y1-Y2)
      if ans > distance:
         ans=distance
         f_ans=j
   print(f_ans+1)

Solution (Python):
import numpy as np,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M = LI()
ab = np.array([LI() for _ in range(N)])
cd = np.array([LI() for _ in range(M)])
for x in ab:
    print(abs(cd-x).sum(axis=1).argmin()+1)

Solution (Python):
import numpy as np,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M = LI()
ab = np.array([LI() for _ in range(N)])
cd = np.array([LI() for _ in range(M)])
for x in ab:
    print(abs(cd-x).sum(axis=1).argmin()+1)

Solution (Python):
import numpy as np,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M = LI()
ab = np.array([LI() for _ in range(N)])
cd = np.array([LI() for _ in range(M)])
for x in ab:
    print(np.argmin(np.sum(np.abs(cd-x),axis=1))+1)

Solution (Python):
import numpy as np,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M = LI()
ab = np.array([LI() for _ in range(N)],dtype=int)
cd = np.array([LI() for _ in range(M)],dtype=int)
for x in ab:
    vector = np.sum(np.abs(cd-x),axis=1).tolist()
    print(vector.index(min(vector))+1)

Solution (Python):
import numpy as np,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M = LI()
ab = np.array([LI() for _ in range(N)])
cd = np.array([LI() for _ in range(M)])
for x in ab:
    vector = np.sum(np.abs(cd-x),axis=1).tolist()
    print(vector.index(min(vector))+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)]
dist = 10**9


for i, j in ab:
    for o, (p, q) in enumerate(cd):
        dist1 = abs(i - p) + abs(j - q)
        if dist1 < dist:
            dist = dist1
            ch = o + 1
    print(ch)
    dist = 10**9

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)]
dist = 10**9


for i, j in ab:
    for k in range(m):
        dist1 = abs(i - cd[k][0]) + abs(j - cd[k][1])
        if dist1 < dist:
            dist = dist1
            ch = k + 1
    print(ch)
    dist = 10**9

Solution (Python):
import numpy as np

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

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

ab = np.array(ab)
dist = np.full([N, M], np.inf)

for m in range(M):
    tmp = np.array(list(map(int, input().split())))
    for n in range(N):
        dist[n, m] = np.abs(ab[n] - tmp).sum()

dist = dist.astype("int")

for d in dist:
    print(d.argmin()+1)

Solution (Python):
n,m=map(int,input().split())
a=[]
b=[]
c=[]
d=[]

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

def man(x1,y1,x2,y2):
    return(abs(x1-x2)+abs(y1-y2))

for i in range(n):
    distance=10**9
    for j in range(m):
        if distance!=min(distance,man(a[i],b[i],c[j],d[j])):
            point=j+1
            distance=min(distance,man(a[i],b[i],c[j],d[j]))

    print(point)

Solution (Python):




n, m = map(int, input().split())
ax = [None]*n
by = [None]*n
cx = [None]*m
dy = [None]*m

d_list = [[None]*m for i in range(n)]

for i in range(n):
    ax[i],by[i] = map(int, input().split())
for i in range(m):
    cx[i],dy[i] = map(int, input().split())

for i in range(n):
    for j in range(m):
        d_list[i][j] = abs(ax[i]-cx[j]) + abs(by[i]-dy[j])
        
for i in range(n):
    print(d_list[i].index(min(d_list[i]))+1)

Solution (Python):
N, M = map(int, input().split())
a_b_tuple = [tuple(map(int, input().split())) for _ in range(N)]
c_d_tuple = [tuple(map(int, input().split())) for _ in range(M)]
for a_b in a_b_tuple:
    flg = 0
    tmp = 20000000000
    for i, c_d in enumerate(c_d_tuple):
        if tmp > abs(a_b[0] - c_d[0]) + abs(a_b[1] - c_d[1]):
            tmp = abs(a_b[0] - c_d[0]) + abs(a_b[1] - c_d[1])
            flg = i
    print(flg + 1)

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

def d(s,p):
  return abs(s[0]-p[0]) + abs(s[1] - p[1])

for std in stds:
  ans = (-1, float('inf'))
  for i, pnt in enumerate(points):
    dst = d(std,pnt)
    if dst < ans[1]:
      ans = (i, dst)
  print(ans[0]+1)

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

ans_list = []
for i in range(N):
    a, b = students[i]
    min_d = float("inf")
    ans = -1
    for j in range(M):
        x, y = check[j]
        d = abs(a-x) + abs(b-y)
        if d < min_d:
            min_d = d
            ans = j
    ans_list.append(ans)
    
for i in range(N):
    print(ans_list[i]+1)

Solution (Python):
n, m = map(int, input().split())
L1 = [list(map(int, input().split())) for _ in range(n)]
L2 = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
    D = 10 ** 10
    ans = 0
    for j in range(m):
        d = abs(L1[i][0] - L2[j][0]) + abs(L1[i][1] - L2[j][1])
        if d < D:
            D = d
            ans = j + 1
    print(ans)

Solution (Python):
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])

for a, b in ab:
    near = 10**32
    for i, n in enumerate(cd):
        tmp = abs(a-n[0])+abs(b-n[1])
        if near == tmp:
            continue
        near = min(near, tmp)
        if near == tmp:
            ans = i + 1
    print(ans)

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

x = [0]*M
y = [0]*M

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

for i in range(N):
    dis = 10000000000000000
    res = 0
    for j in range(M):
        if dis > (abs(a[i]-x[j])+abs(b[i]-y[j])):
            dis = min(dis,(abs(a[i]-x[j])+abs(b[i]-y[j])))
            res = j

    print(res+1)

Solution (Python):

"""
Created on Thu May 14 16:46:38 2020

@author: shinba
"""

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

A = []
B = []

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

C = []
D = []

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

for i in range(n):
    ans = float("inf")
    for j in range(m):
        if ans > abs(A[i]-C[j])+abs(B[i]-D[j]):
            ans = abs(A[i]-C[j])+abs(B[i]-D[j])
            num = j+1
    else:
        print(num)

Solution (Python):

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

for i in range(n):
    dt = 10**9
    for j in range(m):
        dx = abs(ab[i][0]-dxy[j][0])
        dy = abs(ab[i][1]-dxy[j][1])
        if dt > dx+dy:
            ij = j
            dt = dx+dy
    print(ij+1)

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

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

for a, b in start_pos:
    min_dist = 1_000_000_000
    min_dist_pos = 0
    for i, pos in enumerate(check_point):
        c, d = pos
        tmp = abs(a - c) + abs(b - d)
        if tmp < min_dist:
            min_dist = tmp
            min_dist_pos = i + 1

    print(min_dist_pos)

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

    for AB in ABs:
        thresh = float('inf')
        for i, CD in enumerate(CDs, start=1):
            thresh_temp = abs(AB[0]-CD[0])+abs(AB[1]-CD[1])
            if thresh == thresh_temp:
                continue
            if thresh_temp < thresh:
                ans = i
                thresh = thresh_temp
        print(ans)


if __name__ == "__main__":
    main()

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))

from fractions import gcd
import math
def resolve():
    N,M=pin()
    students=[tupin() for i in range(N)]
    checkpoints=[tupin() for j in range(M)]
    for stu in range(N):
        temp=10**10
        ind=0
        for pt in range(M):
            dis=abs(students[stu][0]-checkpoints[pt][0])\
            +abs(students[stu][1]-checkpoints[pt][1])
            
            if dis<temp:
                temp=dis
                ind=pt+1
        print(ind)
            
            

resolve()

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

ab=[[int(_) for _ in input().split()]for i in range(n)]
cd=[[int(_) for _ in input().split()]for i in range(m)]


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

for i in range(n):
  d=1000000000
  ans=0
  for j in range(m):
    if d>dist(ab[i],cd[j]):
      ans=j+1
      d=dist(ab[i],cd[j])
  print(ans)

Solution (Python):
import numpy as np
N, M = map(int, input().split())
A, B = np.array(tuple(tuple(map(int, input().split())) for _ in range(N)), dtype=np.int64).T
C, D = np.array(tuple(tuple(map(int, input().split())) for _ in range(M)), dtype=np.int64).T
print(*((np.abs(np.subtract.outer(A, C)) + np.abs(np.subtract.outer(B, D))).argmin(axis=1) + 1), sep="\n")

Solution (Python):
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in [0]*n]
cd = [list(map(int, input().split())) for _ in [0]*m]
for a, b in ab:
    t = 1001001001
    ti = 0
    for i, (c, d) in enumerate(cd):
        e = abs(a-c)+abs(b-d)
        if t > e:
            t = e
            ti = i+1
    print(ti)

Solution (Python):
n,m = map(int,input().split())
stu_list = [list(map(int,input().split())) for nesya in range(n)]
che_list = [list(map(int,input().split())) for mootsu in range(m)]
for stu in stu_list:
  x = stu[0]
  y = stu[1]
  poge = 10**9
  hoge = 0
  i = 0
  for che in che_list:
    hoge += 1
    a = che[0]
    b = che[1]
    l = abs(x-a)+abs(y-b)
    if poge > l:
      poge = l
      i = hoge
  print(i)

Solution (Python):
import sys

N, M = map(int, input().split())
AB = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(N)]
CD = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(M)]

for a, b in AB:
    tmp_d = 10 ** 9
    for i in range(M):
        d = abs(a - CD[i][0]) + abs(b - CD[i][1])
        if d < tmp_d:
            tmp_d = d
            tmp_i = i + 1
    print(tmp_i)

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

for i in range(n):
    distance = []
    minDistance = 10 ** 16
    checkPoint = 1
    for j in range(m):
        distance.append(abs(a[i] - c[j]) + abs(b[i] - d[j]))
        if minDistance > distance[j]:
            minDistance = distance[j]
            checkPoint = j + 1
    print(checkPoint)

Solution (Python):
import sys

readline = sys.stdin.readline

def d(a, x):
    return abs(a[0] - x[0]) + abs(a[1] - x[1])

def main():
    N, M = map(int, readline().split())
    people = []
    for _ in range(N):
        people.append(tuple(map(int, readline().split())))
    check = []
    for _ in range(M):
        check.append(tuple(map(int, readline().split())))
    
    for i in range(N):
        tmp = float('inf')
        jtmp = 0
        for j in range(M):
            dtmp = d(people[i], check[j])
            if dtmp < tmp:
                tmp = dtmp
                jtmp = j
        print(jtmp+1)
    
if __name__ == "__main__":
    main()

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

def distance(i,j):
    return abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
ans = []
for i in range(n):
    mn = 10**18
    s = 0
    for j in range(m):
        if mn > distance(i,j):
            s = j
            mn = distance(i,j)
    ans.append(s)

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

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]

def to_bin(x: int) -> str: return format(x, 'b') 
def to_oct(x: int) -> str: return format(x, 'o') 
def to_hex(x: int) -> str: return format(x, 'x') 
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]

from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left


def main():
    n, m = MII()
    ab = [MII() for _ in range(n)]
    cd = [MII() for _ in range(m)]
    for a,b in ab:
        minidx = 0
        mind = 4*(10**8)
        for i,(c,d) in enumerate(cd):
            dist = abs(a-c)+abs(b-d)
            if dist < mind:
                mind = dist
                minidx = i+1
        print(minidx)


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

Solution (Python):
N,M = map(int,input().split())
A = []
B = []
C = []
D = []
ans = []

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)

for i in range(N):
    item = abs(A[i]-C[0])+abs(B[i]-D[0])
    index = 1
    for j in range(M):
        if item > abs(A[i]-C[j])+abs(B[i]-D[j]):
            item = abs(A[i]-C[j])+abs(B[i]-D[j])
            index = j+1
    ans.append(index)

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

Solution (Python):
from collections import defaultdict
d = defaultdict(int)
N, M = map(int, input().split())
abL = [list(map(int, input().split())) for _ in range(N)]
cdL = [list(map(int, input().split())) for _ in range(M)]

for i in range(N):
    for j in range(M):
        d[j] = abs(abL[i][0] - cdL[j][0]) + abs(abL[i][1] - cdL[j][1])

    m = min(d.values())
    for k, v in d.items():
        if (v == m):
            print(k + 1)
            break

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):
    m=0
    for j in range(M):
        if j==0:
            m=abs(cd[j][0]-ab[i][0])+abs(cd[j][1]-ab[i][1])
            ans=j+1
        else:
            if m>abs(cd[j][0]-ab[i][0])+abs(cd[j][1]-ab[i][1]):
                m=abs(cd[j][0]-ab[i][0])+abs(cd[j][1]-ab[i][1])
                ans=j+1
        
    print(ans)

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

ablist=[]
for i in range(N):
  a,b=map(int,input().split())
  ablist.append((a,b))
  
cdlist=[]
for i in range(M):
  c,d=map(int,input().split())
  cdlist.append((c,d))
  
for i in range(N):
  a,b=ablist[i]
  min_dist_arg=-1
  min_dist=float("inf")
  for j in range(M):
    c,d=cdlist[j]
    if min_dist>abs(a-c)+abs(b-d):
      min_dist_arg=j+1
      min_dist=abs(a-c)+abs(b-d)
  print(min_dist_arg)

Solution (Python):
def manhattan_distance(s, c):
    return abs(s[0] - c[0]) + abs(s[1] - c[1])


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

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

for s in students:
    ans = 0
    min_distance = manhattan_distance(s, checkpoints[0])
    for i in range(1, M):
        distance = manhattan_distance(s, checkpoints[i])
        if min_distance > distance:
            min_distance = distance
            ans = i
    print(ans + 1)

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

for i in range(n):
    a,b = map(int,ab_input[i])
    
    tmp=float('inf')
    for j in range(m):
        c,d = map(int,cd_input[j])
        dist=abs(a-c)+abs(b-d)
        if tmp>dist:
            tmp=dist
            ans=j
    print(ans+1)

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):
    z=10**10
    ans=0
    for t in range(M):
        if (abs(A[i][0]-C[t][0])+abs(A[i][1]-C[t][1]))<z:
            z=(abs(A[i][0]-C[t][0])+abs(A[i][1]-C[t][1]))
            ans=t+1
        else:
            continue
    print(ans)

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

for i in range(N):
    x, y = Student[i]
    destination = 0
    distance = float('inf')
    for j in range(M):
        nx, ny = Checkpoint[j]
        dis = abs(x-nx) + abs(y-ny)
        if dis < distance:
            distance = dis
            destination = j
    print(destination+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:
    distance = float('inf')
    ans = 0
    for i in range(M):
        newDistance = abs(a - CD[i][0]) + abs(b - CD[i][1])
        if distance > newDistance:
            distance = newDistance
            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)]

ans=[0]*N
i=0
while i<N:
    count=0
    j=0
    distance=abs(AB[i][0]-CD[j][0])+abs(AB[i][1]-CD[j][1])
    while j<M:
        if distance>abs(AB[i][0]-CD[j][0])+abs(AB[i][1]-CD[j][1]):
            count=j
            distance=abs(AB[i][0]-CD[j][0])+abs(AB[i][1]-CD[j][1])
        j+=1
    ans[i]=count
    i+=1

for k in ans:
    print(k+1)

Solution (Python):
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):
  a, b = map(int, input().split())
  checkpoints.append((a, b))

for student in students:
  ans = (-1, float('inf'))
  for i, point in enumerate(checkpoints):
    distance = abs(student[0]-point[0]) + abs(student[1]-point[1])
    if ans[1] > distance:
      ans = (i, distance)
  print(ans[0]+1)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
ab = [LIST() for _ in range(N)]
cd = [LIST() for _ in range(M)]

def M_dist(p1, p2):
	return abs(p1[0]-p2[0]) + abs(p1[1]-p2[1])

for i in range(N):
	dist = M_dist(ab[i], cd[0])
	ans = 1
	
	for j in range(1, M):
		if dist > M_dist(ab[i], cd[j]):
			dist = M_dist(ab[i], cd[j])
			ans = j+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 i in range(N):
  ans = 10**18
  for j in range(M-1,-1,-1):
    abs_num = abs(AB[i][0]-CD[j][0])+abs(AB[i][1]-CD[j][1])
    ans = min(ans, abs_num)
    if ans == abs_num:
      count = j+1
  print(count)

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

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

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

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

Solution (Python):
n,m=map(int,input().split())
stu=[list(map(int,input().split()))for i in range(n)]
po=[list(map(int,input().split()))for i in range(m)]
for i in stu:
    tmp=10**12
    for j in po:
        ab=abs(i[0]-j[0])+abs(i[1]-j[1])
        if ab<tmp:
            tmp=ab
            ans=po.index(j)
    print(ans+1)

Solution (Python):

import re
import math
from collections import defaultdict
import itertools
from copy import deepcopy
import random
from heapq import heappop,heappush
import time
import os
import queue
import sys
import datetime
from functools import lru_cache

readline=sys.stdin.readline
sys.setrecursionlimit(2000000)

alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=""):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
def hani(x,min_,max_):
    ret=x
    if x<min_:ret=min_
    if x>max_:ret=max_
    return ret
def seifu(x):
    return x//abs(x)


def main():
    N,M=map(int,input().split())
    AB=[]
    CD=[]
    ABdict={}
    CDdict={}
    for a in range(N):
        AB.append(list(map(int,input().split())))
    for a in range(M):
        CD.append(list(map(int,input().split())))
    for a in range(N):
        mmin=[inf,inf]
        for b in range(M-1,-1,-1):
            d=abs(AB[a][0]-CD[b][0])+abs(AB[a][1]-CD[b][1])
            if mmin[0]>=d:
                mmin=[d,b+1]
        print(mmin[1])
main()

Solution (Python):
N, M = map(int, input().split())
a = [0] * N
b = [0] * N
for i in range(N):
    a[i], b[i] = map(int, input().split())
c = [0] * M
d = [0] * M
for i in range(M):
    c[i], d[i] = map(int, input().split())
for i in range(N):
    mi = 1000000000
    mid = -1
    for j in range(M):
        di = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if mi > di:
            mi = di
            mid = j + 1
    print(mid)

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(len(ab)):
    ans.append(1)
    dist_min = abs(cd[0][0] - ab[i][0]) + abs(cd[0][1] - ab[i][1])
    for j in range(len(cd)):

        dist = abs(cd[j][0] - ab[i][0]) + abs(cd[j][1] - ab[i][1])

        if dist < dist_min:
            dist_min = dist
            ans[-1] = j+1


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

Solution (Python):
N, M = map(int, input().split())
a, b = [], []
for _ in range(N):
    A, B = map(int, input().split())
    a.append(A)
    b.append(B)
    
c, d = [], []
for _ in range(M):
    C, D = map(int, input().split())
    c.append(C)
    d.append(D)
    
for A, B in zip(a, b):
    ans = 0
    mn = 10**9
    for i, (C, D) in enumerate(zip(c, d)):
        s = abs(A - C) + abs(B - D)
        if mn > s:
            ans = i
            mn = s
            
    print(ans+1)