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())
ss = [tuple(map(int, input().split())) for _ in range(n)]
ps = [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 s in ss:
    mini = 0
    mind = d(s, ps[0])
    for i in range(1, len(ps)):
        p = ps[i]
        if d(s, p) < mind:
            mini = i
            mind = d(s, p)

    print(mini + 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)]

ans = []
for man in ab:
    min_dis = float("inf")
    place = 0
    for i in range(m):
        cp = cd[i]
        dis = abs(cp[0] -man[0]) + abs(cp[1] -man[1])

        if dis < min_dis:
            min_dis = dis
            place = i + 1

    ans += [place]

for i in ans:
    print(i)

Solution (Python):
import itertools
N,M = list(map(int,input().split(" ")))
humans = []
points = []

for _ in range(N):
    humans.append(list(map(int,input().split(" "))))
for _ in range(M):
    points.append(list(map(int, input().split(" "))))
for human in humans:
    mindis = 10e10
    minind = -1
    a = human[0]
    b = human[1]
    for ind,point in enumerate(points):
        c = point[0]
        d = point[1]
        dist = abs(a-c) + abs(d-b)
        if mindis > dist:
            minind = ind + 1
            mindis = dist
    print(minind)

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

AB = [tuple(map(int, input().split())) for _ in range(N)]
CD = [tuple(map(int, input().split())) for _ in range(M)]
INF = 1000000000

for a, b in AB:
    min_dist = INF
    min_cp = -1
    for cp in range(1, M+1):
        dist = abs(a-CD[cp-1][0]) + abs(b-CD[cp-1][1])
        if dist < min_dist:
            min_dist = dist
            min_cp = cp
    print(min_cp)

Solution (Python):
n,m = map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(n):
    a1,b1=map(int,input().split())
    a.append(a1)
    b.append(b1)
for i in range(m):
    c1,d1=map(int,input().split())
    c.append(c1)
    d.append(d1)
for i in range(n):
    min_len = 1000000000
    cnt = None
    for j in range(m):
        len = abs(c[j]-a[i])+abs(d[j]-b[i])
        if len < min_len:
            min_len=len
            cnt = j+1
    print(cnt)

Solution (Python):
def md(a, b):
    return abs(a[0] - b[0]) + abs(a[1] - b[1])


N, M = map(int, input().split())
P = [tuple(map(int, input().split())) for _ in range(N)]
C = [tuple(map(int, input().split())) for _ in range(M)]
ANS = []

for p in P:
    min_c = None
    min_d = float('inf')
    for c in C:
        d = md(p, c)
        if d < min_d:
            min_c = c
            min_d = d
    ANS.append(min_c)

print(*[C.index(c) + 1 for c in ANS], sep='\n')

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math

mod = 10**9+7

N,M = map(int,input().split())
start = [0 for i in range(N)]
for i in range(N):
    start[i] = [int(i) for i in input().split()]

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


ans = [0 for i in range(N)]
for i in range(N):
    tmp = mod
    for j in range(M):
        if tmp > abs(start[i][0]-goal[j][0])+abs(start[i][1]-goal[j][1]):
            ans[i] = j+1
            tmp = abs(start[i][0]-goal[j][0])+abs(start[i][1]-goal[j][1])
for i in range(N):
    print(ans[i])

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

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

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

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

Solution (Python):
N, M = map(int, input().split())
stu = []
che = []
for i in range(N):
  stu.append(list(map(int, input().split())))
for i in range(M):
  che.append(list(map(int, input().split())))
  
for i in stu:
  x, y = i[0], i[1]
  ans = 0
  tmp = 99999999999999
  for num, j in enumerate(che):
    if abs(x-j[0])+abs(y-j[1]) < tmp:
      tmp = abs(x-j[0])+abs(y-j[1])
      ans = num + 1
  print(ans)

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

for i in range(N):
    l=[]
    for k in range(M):
        l.append(abs(A[i][0]-C[k][0])+abs(A[i][1]-C[k][1]))
    print(l.index(min(l))+1)

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

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

for i in range(N):
    dist = 10 ** 9
    for j in range(M):
        if abs(a[i] - c[j]) + abs(b[i] - d[j]) < dist:
            dist = abs(a[i] - c[j]) + abs(b[i] - d[j])
            index = j + 1
            
    print(index)

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

for i in range(N):
  ans = 0
  min_l = pow(10, 10)
  for j in range(M):
    l = abs(stu[i][0] - che[j][0]) + abs(stu[i][1] - che[j][1])
    if l < min_l:
      min_l = l
      ans = j+1
  print(ans)

Solution (Python):
def ipt(N=0,switch=0):
    if N == 0:
        return list(map(int,input().split()))
    else:
        if switch==0:
            return [list(map(int,input().split())) for _ in range(N)]
        else:
            return [int(input()) for _ in range(N)]

N,M=ipt()
ab=ipt(N)
cd=ipt(M)

def m_dist(a,b,c,d):
    return abs(a-c)+abs(b-d)

for i in range(N):
    ans = ""
    ans_d = 10**9
    for j in range(M):
        m = m_dist(ab[i][0],ab[i][1],cd[j][0],cd[j][1])
        if ans_d > m:
            ans_d = m
            ans = j+1
    print(ans)

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:
    i = -1
    m = 10**9
    for j,tmp in enumerate(cd,1):
        c,d = tmp
        l = abs(a-c)+abs(b-d)
        if l < m:
            m = l
            i = j
    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 j in range(m):
    cd.append(list(map(int,input().split())))

for k in range(n):
    s=[abs(ab[k][0]-cd[l][0])+abs(ab[k][1]-cd[l][1]) for l in range(m)]
    print(s.index(min(s))+1)

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

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

for a,b in ab:
    m = min(cd,key=lambda x:10000*(abs(a-x[0])+abs(b-x[1]))+x[2])
    print(m[2])

Solution (Python):
n, m = [int(i) for i in 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()])
for ni in range(n):
  d = []
  for mi in range(m):
    d.append(abs(ab[ni][0]-cd[mi][0]) + abs(ab[ni][1]-cd[mi][1]))
  print(d.index(min(d))+1)

Solution (Python):

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

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

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

for i in range(N):
  
  d=abs(l1[i][0]-l2[0][0])+abs(l1[i][1]-l2[0][1])

  
  b=1

  
  for j in range(1,M):
    x=abs(l1[i][0]-l2[j][0])+abs(l1[i][1]-l2[j][1])

    
    if x<d:
      d=x
      
      b=j+1

  
  print(b)

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):
    minSum = 999999999999999999
    index = 0
    for j in range(M):
        current = abs(a[i][0] - b[j][0]) + abs(a[i][1] - b[j][1])
        if minSum > current:
            minSum = current
            index = j+1
    print(index)

Solution (Python):
n,m=map(int,input().split())
l_ab=list(list(map(int,input().split())) for _ in range(n))
l_cd=list(list(map(int,input().split())) for _ in range(m))
for i in range(n):
    c=-100
    a=10**9
    for j in range(m):
        if a>(abs(l_ab[i][0]-l_cd[j][0])\
             +abs(l_ab[i][1]-l_cd[j][1])):
                a=abs(l_ab[i][0]-l_cd[j][0])\
                 +abs(l_ab[i][1]-l_cd[j][1])
                c=j+1
    print(c)

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

for i in range(n):
    point = 0
    for j in range(m):
        num = abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1])
        if j == 0:
            prev = num
            point = j + 1
        elif prev > num:
            prev = num
            point = j + 1
    ans[i] += point

print(*ans, sep='\n')

Solution (Python):

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

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

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


for i in range(N):
    
    d=abs(l1[i][0]-l2[0][0])+abs(l1[i][1]-l2[0][1])

    
    b=1

    
    for j in range(1,M):
        x=abs(l1[i][0]-l2[j][0])+abs(l1[i][1]-l2[j][1])

        
        if x<d:
            d=x
            
            b=j+1

    
    print(b)

Solution (Python):
N,M = [int(x) for x in input().split()]
S = [[int(x) for x in input().split()]for _ in range(N)]
C = [[int(x) for x in input().split()]for _ in range(M)]
ans = []
for x in S:
  mindist = 10**10
  mincheck = 0
  for ind,j in enumerate(C):
    if(abs(j[0]-x[0])+abs(j[1]-x[1])<mindist):
      mindist = abs(j[0]-x[0])+abs(j[1]-x[1])
      mincheck = ind + 1
  ans.append(mincheck)
for i in ans:
  print(i)

Solution (Python):
n,m=map(int,input().split())
a=[[int(b) for b in input().split()] for _ in range(n)]
c=[[int(d) for d in input().split()] for _ in range(m)]
for i in range(n):
    p=a[i]
    tmp=10**10
    pos=-1
    for j in range(m):
        cp=c[j]
        dist=abs(cp[0]-p[0])+abs(cp[1]-p[1])
        if dist < tmp:
            tmp=dist
            pos=j+1
    print(pos)

Solution (Python):
N,M=map(int,input().split())
a,b=[],[]
for i in range(N):
    s,t=map(int,input().split())
    a.append(s)
    b.append(t)
c,d=[],[]
for i in range(M):
    s,t=map(int,input().split())
    c.append(s)
    d.append(t)
for i in range(N):
    x,y=a[i],b[i]
    dist = []
    for j in range(M):
        z,w=c[j],d[j]
        dist.append(abs(x-z)+abs(y-w))
    print(dist.index(min(dist))+1)

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

student = []

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

point = []

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

for a, b in student:
    length = 10 ** 10
    pn = 0
    for j in range(m):
        c, d = point[j]
        if abs(a-c) + abs(b-d) < length:
            length = abs(a-c) + abs(b-d)
            pn = j + 1
    print(pn)

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 range(N):
    mn = [abs(s[i][0]-c[j][0])+abs(s[i][1]-c[j][1]) for j in range(M)]
    print(mn.index(min(mn))+1)

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

Solution (Python):
n,m=map(int,input().split())
ab=[[int(i) for i in input().split()] for i in range(n)]
cd=[[int(i) for i in input().split()] for i in range(m)]
count=[0]*n
distance=[[] for i in range(n)]
for i in range(n):
    for l in range(m):
        distance[i].append(abs(ab[i][0]-cd[l][0])+abs(ab[i][1]-cd[l][1]))
for i in range(n):
    print(distance[i].index(min(distance[i]))+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)]
for i in ab:
	man = []
	for j in cd:
		man.append(abs(i[0]-j[0])+abs(i[1]-j[1]))
	print(man.index(min(man))+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:
    manh = 10**9
    num = 0
    for c, d in cd:
        if abs(a - c) + abs(b - d) < manh:
            manh = abs(a - c) + abs(b - d)
            num = cd.index([c, d]) + 1
    print(num)

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

for s in students:
    min_d = 10 ** 10
    min_p = 100
    for i in range(M):
        d = abs(points[i][0] - s[0]) + abs(points[i][1] - s[1])
        if d < min_d:
            min_d = d
            min_p = i
    print(min_p + 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 s in S:
    minC = 10**10
    idx = 0
    for i, c in enumerate(C):
        d = abs(s[0]-c[0]) + abs(s[1]-c[1])
        if d < minC:
            minC = d
            idx = i + 1
    print(idx)

Solution (Python):

n, m = list(map(int, input().rstrip().split()))
st = [list(map(int, input().rstrip().split())) for _ in range(n)]
ch = [list(map(int, input().rstrip().split())) for _ in range(m)]
dis_lst = []
for i in st:
    temp_lst = []
    for j in ch:
        temp_lst.append(abs(i[0] - j[0]) + abs(i[1] - j[1]))
    dis_lst.append(temp_lst.index(min(temp_lst)) + 1)

for i in dis_lst:
    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 range(n):
  ret = [0,10**11]
  for j in range(m):
    if abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1]) < ret[1]:
      ret = [j+1, abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1])]
  print(ret[0])

Solution (Python):
n,m=map(int,input().split())
p=[list(map(int,input().split()))for _ in range(n)]
s=[list(map(int,'0'*m))for _ in range(n)]
for j in range(m):
  c,d=map(int,input().split())
  for i in range(n):
    s[i][j]=abs(p[i][0]-c)+abs(p[i][1]-d)
else:
  for i in range(n):print(1+s[i].index(min(s[i])))

Solution (Python):
N,M = map(int,input().split())
a_list = []
b_list = []
c_list = []
d_list = []
lists = []
for i in range(N):
    a,b = map(int,input().split())
    a_list.append(a)
    b_list.append(b)
for i in range(M):
    c,d = map(int,input().split())
    c_list.append(c)
    d_list.append(d)
for i in range(N):
    min = 9999999999999999999999999
    for j in range(M):
        distance = abs(a_list[i] - c_list[j]) + abs(b_list[i] - d_list[j])
        if min > distance:
            min = distance
            ind = j
    lists.append(ind+1)
for i in range(len(lists)):
    print(lists[i])

Solution (Python):
import sys
from collections import Counter

n, m = map(int, input().split())
ab_list = [ list(map(int, input().split())) for i in range(n)]
cd_list = [ list(map(int, input().split())) for i in range(m)]
ans_list = [[None, None] for i in range(n)]

for i in range(n):
    for j in range(m):
        x_dist = abs(ab_list[i][0] - cd_list[j][0])
        y_dist = abs(ab_list[i][1] - cd_list[j][1])
        tmp = x_dist + y_dist
        if ans_list[i][0] == None or tmp < ans_list[i][1]:
            ans_list[i] = [j+1, tmp]

for i in range(n):
    print(ans_list[i][0])

Solution (Python):
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
cd=[list(map(int,input().split())) for j in range(m)]
for a,b in ab:
    abcd=[abs(a-c)+abs(b-d) for c,d in cd]
    print(abcd.index(min(abcd))+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):
    nearest_diatance = 4*10**8
    ans = 0
    for j in range(M):
        x = abs(ab[i][0] - cd[j][0])
        y = abs(ab[i][1] - cd[j][1])
        if x+y < nearest_diatance:
            nearest_diatance = x+y
            ans = j+1
    else:
        print(ans)

Solution (Python):
N,M = map(int,input().split())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
C = []
D = []
for i in range(M):
    c,d = map(int,input().split())
    C.append(c)
    D.append(d)

for i in range(N):
    ans = float("inf")
    ansidx = 0
    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])
            ansidx = j + 1
    print(ansidx)

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

p = []
for i in range(n):
    p.append([int(n) for n in input().split()])

check_point = []
for j in range(m):
    check_point.append([int(n) for n in input().split()])

for i in range(n):
    l = []
    for j in range(m):
        delta = abs(p[i][0] - check_point[j][0]) + abs(p[i][1] - check_point[j][1])
        l.append(delta)

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

Solution (Python):
N,M=map(int,input().split())
n=[]
m=[]
for i in range(N):
  n.append(list(map(int,input().split())))
for l in range(M):
  m.append(list(map(int,input().split())))
L=[]
for i in n:
  M=[]
  for l in m:
    A=abs(i[0]-l[0])+abs(i[1]-l[1])
    M.append(A)
  print(M.index(min(M))+1)

Solution (Python):


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

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

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

    return n, m, students, checkpoints


def search_nearest_checkpoint(st, checks):
    def manhattan_dist(a, b):
        return abs(a[0] - b[0]) + abs(a[1] - b[1])

    mindist = float('inf')
    minid = None
    for i, check in enumerate(checks):
        mdist = manhattan_dist(st, check)
        if mdist < mindist:
            mindist = mdist
            minid = i + 1

    return minid

def submit():
    n, m, students, checkpoints = read_input()


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


if __name__ == '__main__':
    submit()

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

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


for student in students:
    mini = [1e20, -1]
    for i in range(m):
        if dist(student,checkpoints[i]) < mini[0]:
            mini = [dist(student, checkpoints[i]),i]
    print(mini[1]+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 si in s:
    di = 10 ** 10
    ans = 0
    for j, cj in enumerate(c):
        dij = abs(si[0] - cj[0]) + abs(si[1] - cj[1])
        if dij < di:
            di = dij
            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):
  l = float('inf')
  min_j = -1
  for j in range(M):
    tmp = abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1])
    if tmp < l:
      l = tmp
      min_j = j
  print(min_j+1)

Solution (Python):
n,m=map(int,input().split())
p=[list(map(int,input().split()))for _ in range(n)]
s=[list(map(int,'0'*m))for _ in range(n)]
for j in range(m):
  c,d=map(int,input().split())
  for i in range(n):
    s[i][j]=abs(p[i][0]-c)+abs(p[i][1]-d)
else:
  for i in range(n):print(1+s[i].index(min(s[i])))

Solution (Python):
n, m = [int(i) for i in 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] = [int(i) for i in input().split(" ")]
for i in range(m):
    c[i], d[i] = [int(i) for i in input().split(" ")]

res = []
for i in range(n):
    tmp = 10 ** 10
    resj = 0
    for j in range(m):
        tmo = abs(a[i]-c[j]) + abs(b[i]-d[j])
        if tmo < tmp:
            tmp = tmo
            resj = j
    res.append(resj)

for i in res:
    print(i+1)

Solution (Python):
[N,M] = list(map(int,input().split()))
students = [list(map(int,input().split())) for i in range(N)]
check_points = [list(map(int,input().split())) for i in range(M)]
for sy,sx in students:
    min_dis = 10**9
    ans = -1
    for i,[gy,gx] in enumerate(check_points):
        dis = abs(sy-gy) + abs(sx-gx)
        if dis < min_dis:
            min_dis = dis
            ans = i+1
    print(ans)

Solution (Python):
N, M = map(int,input().split())
student = []
for i in range (N):
    a, b = map(int,input().split())
    student.append([a,b])
 
flags = []
for i in range (M):
    c, d = map(int,input().split())
    flags.append([c,d])
    
    
for n in range (N):
    x = student[n][0]
    y = student[n][1]
    lowest_score = 10**10
    lowest= 0
    for m in range (M):
        x_m  = flags[m][0]
        y_m  = flags[m][1]
        temp_score = abs(x-x_m) + abs(y-y_m) 
        if temp_score < lowest_score:
            lowest_score = temp_score
            lowest = m
    print(lowest+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)]

ans = []
for i in ab:
    a, b = i
    Min = 10**9
    num = 1
    for j in cd:
        c, d = j
        L = abs(a-c) + abs(b-d)
        if L < Min:
            pt = num
            Min = L
        num += 1
    ans.append(pt)

for i in ans:
    print(i)

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):
    check = int(1e9)
    point = -1
    for j in range(M):
        dis = abs(a[i]-c[j]) + abs(b[i]-d[j])
        if dis < check:
            check = dis
            point = j+1
    print(point)

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 j in range(M):
    x, y = map(int, input().split())
    c.append(x)
    d.append(y)

for i in range(N):
    ans = 0
    minDist = 10**8 * 2
    for j in range(M):
        dist = abs(c[j]-a[i]) + abs(d[j]-b[i]) 
        if dist < minDist:
            minDist = dist
            ans = j
        
    print(ans+1)

Solution (Python):
n,m=map(int,input().split())
Ans,G,C=[],[],[]
for i in range(n):
  a,b=map(int,input().split())
  G.append([a,b])
for i in range(m):
  c,d=map(int,input().split())
  C.append([c,d])
for i in range(n):
  dis=float("inf")
  ct=0
  for j in range(m):
    a,b=G[i][0],G[i][1]
    c,d=C[j][0],C[j][1]
    dis_c=abs(a-c)+abs(b-d)
    if dis_c<dis:
      ct=j
      dis=dis_c
  Ans.append(ct+1)
print(*Ans,sep="\n")

Solution (Python):
n, m = map(int,input().split())
students = []
marks = []
for _ in range(n):
    student = list(map(int,input().split()))
    students.append(student)
for i in range(m):
    mark = list(map(int,input().split()))
    mark.append(i+1)
    marks.append(mark)
INF = 10**10 
for a, b in students:
    mdist = INF
    for c, d, m in marks:
        if abs(a-c) + abs(b-d) < mdist:
            move_mark = m
            mdist = abs(a-c) + abs(b-d)
    print(move_mark)

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

Solution (Python):
N, M = map(int, input().split())
students = []
checkpoint = []
for i in range(N):
    students.append(list(map(int, input().split())))
for j in range(M):
    checkpoint.append(list(map(int, input().split())))
for k in students:
    a, b = k[0], k[1]
    distance = []
    for l in checkpoint:
        c, d = l[0], l[1]
        distance.append(abs(a - c) + abs(b - d))
    print(distance.index(min(distance))+1)

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

for j, (a,b) in enumerate(ab):
    ans = 10**10 
    prev = 10**10
    for i in range(m):
        c, d = cd[i] 
        ans = min(ans, abs(a-c) + abs(b-d))
        if ans != prev:
            id = i+1
        prev = ans
    print(id)

Solution (Python):


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

A=[list(map(int,input().split())) for i in range(n)]
B=[list(map(int,input().split())) for j in range(m)]


for a in A:
    D=[]
    for i in range(m):
        D.append([abs(a[0]-B[i][0])+abs(a[1]-B[i][1]),i+1])
    D=sorted(D,key=lambda x:(x[0],x[1]))
    print(D[0][1])

Solution (Python):
N, M = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(N)]
R = [list(map(int, input().split())) for _ in range(M)]
for a, b in S:
    min_j = -1
    min_d = 10 ** 10
    for j, (c, d) in enumerate(R):
        distance = abs(a - c) + abs(b - d)
        if distance < min_d:
            min_j = j
            min_d = distance
    print(min_j + 1)

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

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

for i in range(n):
  a,b = map(int, input().split())
  A.append([a,b])
  
C = []
for i in range(m):
  c,d = map(int, input().split())
  C.append([c,d])
  
ans = [0 for i in range(n)]
infinity = float("infinity")
for i in range(n):
  min_length = infinity
  for j  in range(m):
    if abs(A[i][0] - C[j][0]) + abs(A[i][1] - C[j][1]) < min_length:
      min_length = abs(A[i][0] - C[j][0]) + abs(A[i][1] - C[j][1])
      ans[i] = j+1
      
for i in range(len(ans)):
  print(ans[i])

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

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

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

for i in range(0,N):
    mnh = 10 ** 10
    point = 100
    h = 0
    for h in range(0,M):
        tmp = abs(cd_a[h][0] - ab_a[i][0]) + abs(cd_a[h][1] - ab_a[i][1])
        if tmp < mnh:
            mnh = tmp
            point = h
    print(point + 1)

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


for i in range(n):
    tmp = 1000000000
    ans = 0

    for j in range(m):
        x = abs(piv[i][0] - check[j][0]) + abs(piv[i][1] - check[j][1])
        if tmp > x:
            ans = j + 1
            tmp = x

    print(ans)

Solution (Python):
from functools import reduce
import math

def main():
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    N,M = (int(_) for _ in input().split())
    a = []
    b = []
    c = []
    d = []
    ans = []
    for i in range(N):
        t1, t2 = (int(_) for _ in input().split())  
        a.append(t1)
        b.append(t2)
    for i in range(M):
        t1, t2 = (int(_) for _ in input().split())  
        c.append(t1)
        d.append(t2)

    for i in range(N):
        min_dist = 1e10
        ans.append(0)
        for j in range(M):
            dist = abs(a[i]-c[j])+abs(b[i]-d[j])
            if min_dist > dist:
                ans[i] = str(j+1)
                min_dist = dist
    print('\n'.join(ans))
    
if __name__ == '__main__':
    main()