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):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


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

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

    for a, b in s:
        ans = 0
        min_dist = INF
        for i, (c, d) in enumerate(p):
            dist = abs(a - c) + abs(b - d)
            if dist < min_dist:
                ans = i + 1
                min_dist = dist
        print(ans)


if __name__ == '__main__':
    main()

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)

for n in range(N):
    a,b = A[n],B[n]
    ind = 0
    for m in range(M):
        c,d = C[m],D[m]
        diff = abs(a-c) + abs(b-d)

        if ind == 0:
            ind = 1
            ans = diff
        elif diff < ans:
            ind = m+1
            ans = diff

    print(ind)

Solution (Python):
import math
def distance(x, y, i, j):
    return abs(x - i) + abs(y - j)

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

for i in student:
    mini = 1000000000000
    minicp = 0
    for k in range(M):
        j = checkpoint[k]
        if distance(i[0], i[1], j[0], j[1]) < mini:
            mini = distance(i[0], i[1], j[0], j[1])
            minicp = k + 1
    print(minicp)

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

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

n,m = li()
stu = []
for _ in range(n):
    stu.append(tuple(li()))
chk = []
for _ in range(m):
    chk.append(tuple(li()))
    
for s in stu:
    ans_cand = []
    for c in chk:
        ans_cand.append(abs(c[0] - s[0]) + abs(c[1] - s[1]))
    
    ans = min(ans_cand)
    print(ans_cand.index(ans) + 1)

Solution (Python):
N,M = map(int,input().split())
A = [tuple(map(int,input().split())) for i in range(N)]
C = [tuple(map(int,input().split())) for i in range(M)]
for ax,ay in A:
    min_d = 10**10
    min_i = -1
    for i,(cx,cy) in enumerate(C):
        d = abs(ax-cx) + abs(ay-cy)
        if d < min_d:
            min_d = d
            min_i = i
    print(min_i + 1)

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

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

def manh_dist(S, C):
  return abs(S[0] - C[0]) + abs(S[1] - C[1])
  
for i in range(N):
  index = M+1
  dist = 1e9
  for j in range(M):
    
    if dist > manh_dist(S[i], C[j]):
      dist = manh_dist(S[i], C[j])
      index = j
  print(index+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 ab in AB:
    m=float('inf')
    for i,cd in enumerate(CD):
        if m>abs(ab[0]-cd[0])+abs(ab[1]-cd[1]):
            m=abs(ab[0]-cd[0])+abs(ab[1]-cd[1])
            tmp=i+1
    print(tmp)

Solution (Python):

"""
Created on Sun Sep  2 16:39:28 2018
ABC057B
@author: maezawa
"""

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

sx = []
sy = []
cx = []
cy = []

for i in range(n):
    sxi, syi = list(map(int, input().split()))
    sx.append(sxi)
    sy.append(syi)
    
for i in range(m):
    cxi, cyi = list(map(int, input().split()))
    cx.append(cxi)
    cy.append(cyi)

for i in range(n):
    l = 10**9
    nj = 0
    for j in range(m):
        lj = abs(sx[i]-cx[j])+abs(sy[i]-cy[j])
        if l > lj:
            l = lj
            nj = j
            
    print(nj+1)

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

Solution (Python):
n,m = map(int,input().split())
a = [list(map(int,input().split()))for x in range(n)]
b = [list(map(int,input().split()))for x in range(m)]
for x in range(n):
    c = list()
    for y in range(m):
        c.append(abs(a[x][0]-b[y][0]) + abs(a[x][1]-b[y][1]))
    print(c.index(min(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):
    mindis = 10 ** 9
    for j in range(m):
        dis = abs(s[i][0] - p[j][0]) + abs(s[i][1] - p[j][1])
        if mindis > dis:
            point = j+1
            mindis = dis
    print(point)

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):
    dist = []

    for j in range(M):
        tmp = abs(a[i]-c[j]) + abs(b[i]-d[j])
        dist.append(tmp)

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

Solution (Python):
import numpy as p;
n,m=map(int,input().split())
a=[list(map(int,input().split()))for _ in[0]*(int(n)+int(m))]
for x,y in a[:n]:
    print(1+p.argmin(list(abs(x-X)+abs(y-Y)for X,Y in a[n:])))

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

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

for i in range(n):
    minDistance = 10**9
    for j in range(m):
        d = abs(nList[i][0]-mList[j][0]) + abs(nList[i][1]-mList[j][1])
        if d < minDistance:
            minDistance = d
            mIndex = j + 1
    print(mIndex)

Solution (Python):

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

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

Solution (Python):


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

    ab_list = []
    cd_list = []
    for _ in range(n):
        ab_list.append(list(map(int, input().split())))
    for _ in range(m):
        cd_list.append(list(map(int, input().split())))
    
    for i in ab_list:
        min_distance = float('inf')
        for j in range(m):
            distance = abs(i[0] - cd_list[j][0]) + abs(i[1] - cd_list[j][1])
            if distance < min_distance:
                min_distance = distance
                min_coord = j + 1
        print(min_coord)

if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())
s = [map(int,input().split()) for i in range(N)]
c = [list(map(int,input().split())) for i in range(M)]
for x1, y1 in s:
    m = float('inf')
    mi = 0
    for i,(x2, y2) in enumerate(c):
        if m > abs(x1-x2) + abs(y1-y2):
            m = abs(x1-x2) + abs(y1-y2)
            mi = i+1
    print(mi)

Solution (Python):
f=lambda x,y:abs(x[0]-y[0])+abs(x[1]-y[1])
N,M=map(int,input().split())
l=[tuple(map(int,input().split())) for _ in range(N)]
m=[tuple(map(int,input().split())) for _ in range(M)]
for i in l:
  print(min([(f(i,j),k+1) for (k,j) in enumerate(m)])[1])

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

for a, b in ab:
    min_dist = 4*10**8+1
    for i, (c, d) in enumerate(cd):
        dist = abs(a-c)+abs(b-d)
        if dist < min_dist:
            min_dist = dist
            ans = i+1
    print(ans)

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 nx, ny in ab:
    distances = [abs(nx-mx)+abs(ny-my) for mx, my in cd]
    print(distances.index(min(distances))+1)

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

for a, b in ab:
    ans = [None, float('inf')]
    for i in range(M):
        c, d = cd[i]
        d = abs(a - c) + abs(b - d)
        if ans[1] > d:
            ans = [i + 1, d]
    print(ans[0])

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 j in range(M)]
ans=[]
for i in a:
    temp=4*10**8
    temp2=50
    for j in range(M):
        if abs(i[0]-c[j][0])+abs(i[1]-c[j][1])<temp:
            temp=abs(i[0]-c[j][0])+abs(i[1]-c[j][1])
            temp2=j+1
    ans.append(temp2)
for i in ans:
    print(i)

Solution (Python):
n,m=map(int,input().split())
stu=[]
for i in range(n):
    stu.append(list(map(int,input().split())))
check=[]
for i in range(m):
    check.append(list(map(int,input().split())))
for i in stu:
    res=float('inf')
    point=-1
    for q,j in enumerate(check):
        tmp = abs(i[0]-j[0])+abs(i[1]-j[1])
        if res>tmp:
            res=tmp
            point=q+1
    print(point)

Solution (Python):


















''' 二次元配列を一列ずつ
for i in ans:
	print(*i)
'''
''' heapq
queue = []
heapq.heapify(queue) 
heapq.heappush(queue,num) 
pop = heapq.heappop(queue) 
pop = heapq.heappushpop(queue,num) 

'''

from collections import defaultdict
import sys,heapq,bisect,math,itertools,string
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7

N,M = map(int,input().split())
ab_list = []
ans = [[INF,0]]*N

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

for i in range(M):
	c,d = map(int,input().split())
	for n,[a,b] in enumerate(ab_list):
		dist = abs(a-c)+abs(b-d)
		if ans[n][0] > dist:
			ans[n] = [dist,i]

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

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

ans = []
for s in ss:
    buf = float('inf')
    c_n = -1
    for idx in range(len(ps)):
        dist = abs(s[0] - ps[idx][0]) + abs(s[1] - ps[idx][1])
        if dist < buf:
            buf = dist
            c_n = idx
    ans += [c_n+1]

for x in ans:
    print(x)

Solution (Python):
N, M = map(int, input().split())
student = []
for i in range(N):
    x_y = list(map(int, input().split()))
    student.append(x_y)
    
check = []
for i in range(M):
    x_y = list(map(int, input().split()))
    check.append(x_y)
    
for i in student:
    cnt = []
    for j in check:
        dis = abs(i[0] - j[0]) + abs(i[1] - j[1])
        cnt.append(dis)
    print(cnt.index(min(cnt)) + 1)

Solution (Python):
n, m = [int(i) for i in input().split()]
a = []
b = []
c = []
d = []
for k in range(n):
    tmp = [int(i) for i in input().split()]
    a.append(tmp[0])
    b.append(tmp[1])
for k in range(m):
    tmp = [int(i) for i in input().split()]
    c.append(tmp[0])
    d.append(tmp[1])

for i in range(n):
    point = 1
    min_dis = abs(a[i] - c[0]) + abs(b[i] - d[0])
    for j in range(1, m):
        dis = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if min_dis > dis:
            point = j + 1
            min_dis = dis
    print(point)

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

N_ab = []
M_cd = []

for i in range(n):
  a, b = map(int, input().split())
  N_ab.append([a, b])
  
for i in range(m):
  c, d = map(int, input().split())
  M_cd.append([c, d])
  
for i in range(n):
  Mi = abs(N_ab[i][0]-M_cd[0][0]) + abs(N_ab[i][1]-M_cd[0][1])
  
  num = 0
  for j in range(1, m):
    tmp = abs(N_ab[i][0]-M_cd[j][0]) + abs(N_ab[i][1]-M_cd[j][1])
    
    if tmp<Mi:
      Mi=tmp
      num=j
  print(num+1)

Solution (Python):
import sys
N, M = list(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)]




for i, (a, b) in enumerate(ab):
    
    min_dis = sys.maxsize
    min_idx = -1
    
    for j, (c, d)  in enumerate(cd):
        distance = abs(a-c) + abs(b-d)
        
        if distance < min_dis:
            min_dis = distance
            min_idx = j
    print(min_idx+1)

Solution (Python):
N, M = list(map(int, input().split()))
A, B = [0 for i in range(N)], [0 for i in range(N)]
for i in range(N):
    A[i], B[i] =  list(map(int, input().split()))
C, D =  [0 for i in range(M)], [0 for i in range(M)]
for i in range(M):
    C[i], D[i] =  list(map(int, input().split()))


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


def judge(i):
    tmp = -1
    re = -1
    for j in range(M):
        dis = distance(A[i], B[i], C[j], D[j])
        if tmp == -1 or tmp > dis:
            tmp = dis
            re = j

    return re+1

for i in range(N):
    print(judge(i))

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):
    a = A[i]
    b = B[i]
    min_dist = 10 ** 9
    min_num = -1
    for j in range(m):
        c = C[j]
        d = D[j]
        dist = abs(a-c)+abs(b-d)
        if min_dist > dist:
            min_dist = dist
            min_num = j+1
    print(min_num)

Solution (Python):
N, M = map(int, input().split())
A = []
for i in range(N):
  a, b = map(int, input().split())
  A.append([a, b])
B = []
for i in range(M):
  c, d = map(int, input().split())
  B.append([c, d])
M = [[[abs(b[0] - a[0]) + abs(b[1] - a[1]), i] for i, b in enumerate(B)] for a in A]
for m in M:
  print(sorted(m, key=lambda x:x[0])[0][1] + 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)

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


for i in range(N):
    min_dist = float('inf')
    min_checkpoint = -1
    for j in range(M):
        dist = distance(a[i], c[j], b[i], d[j])
        if dist < min_dist:
            min_dist = dist
            min_checkpoint = j + 1
    print(min_checkpoint)

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

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

for i in range(N):
	L = []
	for j in range(M):
		L.append(abs(AB[i][0] - CD[j][0]) + abs(AB[i][1] - CD[j][1]))
	print(L.index(min(L)) + 1)

Solution (Python):
n, m = list(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):
  t = float("INF")
  for j in range(m):
    if abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])<t:
      t = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
      ans = j+1
  print(ans)

Solution (Python):
import math
def getinputdata():

    
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])
m = int(arr_data[0][1])

arr_chk = []
for j in range(1 + n, 1 + n + m):
    
    arr_temp = []
    arr_temp.append(int(arr_data[j][0]))
    arr_temp.append(int(arr_data[j][1]))
    arr_chk.append(arr_temp)
    

for i in range(1, 1 + n):
    
    x1 = int(arr_data[i][0])
    y1 = int(arr_data[i][1])
    
    l = abs(x1-arr_chk[0][0]) + abs(y1-arr_chk[0][1])
    
    seq=0
    
    
    for j in range(1,len(arr_chk)):
     
        ltemp = abs(x1-arr_chk[j][0]) + abs(y1-arr_chk[j][1])
        
        if l>ltemp:
            
            seq=j
            l=ltemp
            
    print(seq+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):
    c = 0
    for j in range(M):
        if abs(S[i][0] - C[j][0]) + abs(S[i][1] - C[j][1]) < abs(S[i][0] - C[c][0]) + abs(S[i][1] - C[c][1]):
            c = j
    print(c + 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)]
for a in A:
    dis = 10**100
    ans = None
    for i in range(len(C)):
        c = C[i]
        if abs(a[0]-c[0])+abs(a[1]-c[1]) < dis:
            dis = abs(a[0]-c[0])+abs(a[1]-c[1])
            ans = i + 1
    print(ans)

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

for i in range(n):
  student_positions.append(list(map(int, input().split())))

for i in range(m):
  checkpoints.append(list(map(int, input().split())))

for i in range(n):
  max = 0
  for j in range(1, m):
    if abs(student_positions[i][0] - checkpoints[j][0]) + abs(student_positions[i][1] - checkpoints[j][1]) < abs(student_positions[i][0] - checkpoints[max][0]) + abs(student_positions[i][1] - checkpoints[max][1]):
      max = j

  print(max + 1)

Solution (Python):
"""
https://abc057.contest.atcoder.jp/tasks/abc057_b
"""
[n,m]=[int(i) for i in input().split()]
ab=[]
cd=[]
k=[]
box=[]
l=0
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 i in range(n):
    for j in range(m):
        k.append(abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]))
    
    box.append(k)
    k=[]


for i in range(n):
    for j in box[i]:
        if j == min(box[i]):
            l=l+1
            print(l)
            break
        l=l+1
    l=0

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):
    t=[]
    for j in range(m):
        t.append(abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]))
    k=min(t)
    for j in range(m):
        if k==(abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])):
            print(j+1)
            break

Solution (Python):


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


for i in range(N):
    
    min_point = float("inf")
    ans = 0
    
    for j in range(M):
        
        x = abs(N_list[i][0] - M_list[j][0])
        y = abs(N_list[i][1] - M_list[j][1])
        tmp = x + y
        
        if tmp < min_point:
            min_point = tmp
            ans = j + 1
    print(ans)

Solution (Python):
x=input().split()
n=int(x[0])
m=int(x[1])
stu=[[]*i for i in range(n)]
che=[[]*i for i in range(m)]
for i in range(n):
    x=input().split()
    x[0]=int(x[0])
    x[1]=int(x[1])
    stu[i]=x
for i in range(m):
    x=input().split()
    x[0]=int(x[0])
    x[1]=int(x[1])
    che[i]=x

for i in stu:
    di=[]
    mini=9999999999
    for j in che:
        x=abs(i[0]-j[0])+abs(i[1]-j[1])
        di.append(x)
        mini=min(mini,x)
    print(di.index(mini)+1)

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

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

for n in n_list:
    distance = 10 ** 16
    ans = 0
    for i in range(len(m_list)):
        this_distance = cal_distance(n[0], m_list[i][0], n[1], m_list[i][1])
        if distance > this_distance:
            distance = this_distance
            ans = (i + 1)

    print(ans)

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

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

for n in n_list:
    distance = 10 ** 16
    index = 0
    ans = 0
    for m in m_list:
        index += 1
        if distance > cal_distance(n[0], m[0], n[1], m[1]):
            distance = cal_distance(n[0], m[0], n[1], m[1])
            ans = index

    print(ans)

Solution (Python):
N, M = list(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 ab_i in ab:
    min_j = -1
    min_manh = float('inf')
    for j, cd_j in enumerate(cd):
        if min_manh > abs(ab_i[0]-cd_j[0])+abs(ab_i[1]-cd_j[1]):
            min_manh = abs(ab_i[0]-cd_j[0])+abs(ab_i[1]-cd_j[1])
            min_j = j+1
    print(min_j)

Solution (Python):
N, M = list(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 ab_i in ab:
    min_j = -1
    min_manh = float('inf')
    for j, cd_j in enumerate(cd):
        if min_manh > abs(ab_i[0]-cd_j[0])+abs(ab_i[1]-cd_j[1]):
            min_manh = abs(ab_i[0]-cd_j[0])+abs(ab_i[1]-cd_j[1])
            min_j = j+1
    print(min_j)

Solution (Python):
N,M=map(int,raw_input().split())
xs=[]
cs=[]
for i in xrange(N):
  x=map(int,raw_input().split())
  xs.append(x)
for i in xrange(M):
  c=map(int,raw_input().split())
  cs.append(c)
for x in xs:
  cp = -1
  cd = 1e9
  for j,c in enumerate(cs):
    md = abs(c[0]-x[0]) + abs(c[1]-x[1])
    if md < cd:
      cd = md
      cp = j
  print 1+cp

Solution (Python):
n,m=map(int,input().split())
a=[[int(i) for i in input().split()] for j in range(n)]
c=[[int(i) for i in input().split()] for j in range(m)]
for x1,y1 in a:
  d=10**9
  n=1
  s=0
  for x2,y2 in c:
    if abs(x1-x2)+abs(y1-y2)<d:
      s=n
      d=abs(x1-x2)+abs(y1-y2)
    n+=1
  print(s)

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

Solution (Python):
N,M=map(int,input().split())
s=[list(map(int,input().split()))for _ in[0]*N]
c=[list(map(int,input().split()))for _ in[0]*M]
for x,y in s:
    d={k+1:abs(x-t[0])+abs(y-t[1])for k,t in enumerate(c)}
    print(min(d,key=d.get))

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

ans = []
for sx,sy in st:
    minci = 1
    mind = float('inf')
    for i,(cx,cy) in enumerate(ch):
        d = abs(sx-cx) + abs(sy-cy)
        if d < mind:
            mind = d
            minci = i+1
    ans.append(str(minci))
print(*ans, sep='\n')

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

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

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


closest = N*[0]

for i in range(N):
    minimum = abs(a[i]-c[0])+abs(b[i]-d[0])
    number = 1
    for j in range(1,M):
        distance = abs(a[i]-c[j])+abs(b[i]-d[j])
        if distance < minimum:
            minimum = distance
            number = j+1
    closest[i] = number

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

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

Solution (Python):
N,M = map(int,input().split())
A,B,C,D,Ans = [],[],[],[],[]
for _ in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
for _ in range(M):
    c,d = map(int,input().split())
    C.append(c)
    D.append(d)
for i in range(N):
    d,t = 10**10,-1
    for j in range(M):
        if d > abs(A[i]-C[j])+abs(B[i]-D[j]):
            d = abs(A[i]-C[j])+abs(B[i]-D[j])
            t = j
    Ans.append(t)
for i in range(N):
    print(Ans[i]+1)

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

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

rec = []
for i in range(n):
    a, b = rec1[i]
    num = float("inf")
    for j in range(m):
        c, d = rec2[j]
        if abs(a - c) + abs(b - d) < num:
            index = j
            num = abs(a - c) + abs(b - d)
    rec.append(index)


for i in range(n):
    print(rec[i] + 1)

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

INF = 10**9
d = lambda x, y: abs(x[0]-y[0]) + abs(x[1]-y[1])

for s in st:
    ans = 0
    dist = INF
    for i, c in enumerate(ch):
        dist_ = d(s, c)
        if dist_ < dist:
            dist = dist_
            ans = i
    print(ans+1)

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

for a,b in mapN:
    ans = 0
    intInf = float('inf')
    i = 1
    for c,d in mapM:
        work = abs(a - c) + abs(b - d)
        if work < intInf:
            intInf = work
            ans = i
        i += 1
    print(ans)

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

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

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

for i in student:
    min_idx = 0
    min_k = abs(i[0]-check[0][0]) + abs(i[1]-check[0][1])
    for j in range(1, len(check)):
        k = abs(i[0]-check[j][0]) + abs(i[1]-check[j][1])
        if k < min_k:
            min_k = k
            min_idx = j

    print(min_idx+1)

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

for s in S:
    d = 10**9
    t = 0
    for c in range(M):
        if d > abs(s[0]-C[c][0])+abs(s[1]-C[c][1]):
            d = abs(s[0]-C[c][0])+abs(s[1]-C[c][1])
            t = c
    print(t+1)

Solution (Python):
N, M = map(int, input().split(' '))
st = {i: list(map(int, input().split(' '))) for i in range(N)}
chk = {i: list(map(int, input().split(' '))) for i in range(M)}
num_chk = [0] * N
for s_k, s_v in st.items():
    prev = float('inf')
    for c_k, c_v in chk.items():
        dist = abs(c_v[0] - s_v[0]) + abs(c_v[1] - s_v[1])
        if dist < prev:
            prev = dist
            num_chk[s_k] = c_k + 1
for i in num_chk:
    print(i)

Solution (Python):
n,m = map(int,input().split())
n_p = list()
m_p = list()
ans = 1


for i in range(n):
    n_p.append(list(map(int,input().split()))    )
for j in range(m):
    m_p.append(list(map(int,input().split())))
    
for i in range(n):
    ans = 1
    d=abs(n_p[i][0]-m_p[0][0])+abs(n_p[i][1]-m_p[0][1])
    for j in range(m):
        if d != min(d,abs(n_p[i][0]-m_p[j][0])+abs(n_p[i][1]-m_p[j][1])):
            d = min(d,abs(n_p[i][0]-m_p[j][0])+abs(n_p[i][1]-m_p[j][1]))
            ans = j+1
    print(ans)

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

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

for _ in range(m):
    a, b = map(int, input().split())
    ms.append((a, b))

for x, y in ns:
    diff = abs(x - ms[0][0]) + abs(y - ms[0][1])
    ans = 1
    for i, e in enumerate(ms):
        d = abs(x - e[0]) + abs(y - e[1])
        if d < diff:
            ans = i + 1
            diff = d
    print(ans)