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())
P=[]
for i in range(N):
  x,y=map(int, input().split())
  P.append([x,y])
C=[]
for i in range(M):
  a,b=map(int, input().split())
  C.append([a,b])

for p in P:
  mind=10**18
  for j in range(M):
    d=abs(p[0]-C[j][0])+abs(p[1]-C[j][1])
    if d<mind:
      ans=j+1
      mind=d
  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):
    d = (10**8)*4
    result = 0
    for j in range(m):
        if abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]) < d:
            d = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
            result = j+1
    print(result)

Solution (Python):
n, m = map(int, input().split())
AB = [tuple(map(int, input().split())) for i in range(n)]
CD = [tuple(map(int, input().split())) for i in range(m)]
for a, b in AB:
	minv = p = float('inf')
	for i, (c, d) in enumerate(CD):
		dist = abs(a - c) + abs(b - d)
		if dist < minv:
			minv = dist
			p = i + 1
	print(p)

Solution (Python):
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])
sorted(P)
for s in S:
	sx, sy = s[0], s[1]
	minv = float('inf')
	minvp = -1
	for i, p in enumerate(P):
		px, py = p[0], p[1]
		d = abs(px - sx) + abs(py - sy)
		if d < minv:
			minv = d
			minvp = i
	print(minvp + 1)

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

for i in range(n):
    chk_id = 0
    d = float("inf")
    for j in range(m):
        d1 = abs(std[i][0] - chk[j][0]) + abs(std[i][1] - chk[j][1])
        if d1 < d:
            d = d1
            chk_id = j+1
    print(chk_id)

Solution (Python):
n,m=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(n):
  at,bt=map(int,input().split())
  a.append(at)
  b.append(bt)
for j in range(m):
  ct,dt=map(int,input().split())
  c.append(ct)
  d.append(dt)
for i in range(n):
  temp=0
  man=99999999999999999
  for j in range(m):
    if abs(a[i]-c[j])+abs(b[i]-d[j])<man:
      man=abs(a[i]-c[j])+abs(b[i]-d[j])
      temp=j+1
  print(temp)

Solution (Python):
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(N)]
CD=[list(map(int,input().split())) for j in range(M)]
for i in range(N):
    d=(10**8)*4
    ans=0
    for j in range(M):
        if abs(AB[i][0]-CD[j][0])+abs(AB[i][1]-CD[j][1])<d:
            d=abs(AB[i][0]-CD[j][0])+abs(AB[i][1]-CD[j][1])
            ans=j+1
    print(ans)

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

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

for i in range(n):
    x = loc[i][0]
    y = loc[i][1]
    cnt = int(1e18)
    ans = 0
    for j in range(m):
        x1 = che[j][0]
        y1 = che[j][1]
        u = abs(x-x1)+abs(y-y1)
        if cnt > u:
            ans = j+1
            cnt = u
    print(ans)

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

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

for i in range(n):
    ans = []
    for j in range(m):
        ans.append(abs(x[i][0]-y[j][0]) + abs(x[i][1]-y[j][1]))
    ind = ans.index(min(ans))
    print(ind + 1)

Solution (Python):
n, m = map(int, input().split())
a, b = [0]*n, [0]*n
c, d = [0]*m, [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):
    l = 10 ** 9
    for j in range(m):
        if abs(a[i] - c[j]) + abs(b[i] - d[j]) < l:
            l = abs(a[i] - c[j]) + abs(b[i] - d[j])
            idx = j + 1

    print(idx)

Solution (Python):

import sys

import fractions
import copy
import bisect
import math
import numpy as np
import itertools
from itertools import combinations_with_replacement


from operator import itemgetter
from sys import stdin

from operator import mul
from functools import reduce
from collections import Counter





j=0
k=0
n=3
r=1
a=[0]






"1行1つの整数を入力を取得し、整数と取得する"




"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

for i in number_list:
    print(number_list[i-1])

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''



"正方行列にstr型の値を入力"
'''




'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"


'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''











'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''




"aという変数に入っているものを大文字にして出力"

















'''
コンビネーションの組み合わせの中身を出力する形式
for i in itertools.combinations(brray, 2)
combinationsをpermutationsにすれば順列になる
今回なら(abc133B)
入力
1 2
5 5
-2 8
出力
[[1, 2], [5, 5], [-2, 8]]
もちろん一次元リストでも使えるし
何よりiもリストのように使えるので便利
'''


'''
def cmb(n,r):
    
    r= min(n-r,r)
    
    if r == 0: return 1
    over = reduce(mul, range(n, n-r, -1))
    
    
    

    under = reduce(mul, range(1, r+1))
    
    
    
    

    return over // under
    
    
    
    
a = cmb(n, r)

'''

'''
import itertools
from itertools import combinations_with_replacement

combinationについて
以下の違いを意識しよう
combinations() p, r 長さrのタプル列、ソートされた順で重複なし

combinations_with_replacement() p, r 長さrのタプル列、ソートされた順で重複あり


使用例 　　　　　　　　　　　                  出力　　
combinations('ABCD', 2)　　　　　　　　　　　　AB AC AD BC BD CD

combinations_with_replacement('ABCD', 2)　　 AA AB AC AD BB BC BD CC CD DD
'''



'''




for i in a.most_common(n):print(i)





 


'''









'''
bisect.bisect_left(a, x, lo=0, h=len(a))
引数
a: ソート済みリスト
x: 挿入したい値
lo: 探索範囲の下限
hi: 探索範囲の上限
(lo, hiはスライスと同様の指定方法)
bisect_leftはソートされたリストaに対して順序を保ったままxを挿入できる箇所を探索します。leftが示す通り、aにすでにxが存在している場合は、挿入箇所は既存のxよりも左側になります。また、lo, hiを指定することで探索範囲を絞り込むことも可能です。デフォルトはaの全体が探索対象です。
'''

'''
素数の判定
'''


def is_prime(n):
    if n == 1: return False

    for k in range(2, int(np.sqrt(n)) + 1):
        
        if n % k == 0:
            return False
            
    return True


'''
npのmaxとmaximumの違い
xs = np.array([1, -2, 3])
np.max(xs, 0)
この出力は3となります．[1, -2, 3]と0の4つの数字のうち，最も大きい値を出力します．

一方で，[max(1, 0), max(-2, 0), max(3, 0)]を出力したい時があります．
その時は，numpyのmaximum関数を用います．

xs = np.array([1, -2, 3])
np.maximum(xs, 0)  

'''

def factorial(x, mod=10**9+7):
    
    
    
    tmp = 1
    for i in range(1, x+1):
        tmp = (tmp * i) % mod
    return tmp
    '''
    Basically, when you do a**d % n, you actually have to calculate a**d, which could be quite large.
    But there are ways of computing a**d % n without having to compute a**d itself, and that is what pow does.
    '''











'''
ascii_letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
digits = '0123456789'
hexdigits = '0123456789abcdefABCDEF'
letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv...\xaf\xb0...
lowercase = 'abcdefghijklmnopqrstuvwxyz'
octdigits = '01234567'
printable = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTU...
punctuation = '!"
uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
whitespace = '\t\n\x0b\x0c\r '
'''
'''
引数endに任意の文字列を指定すると、その文字列が改行の代わりに最後に挿入される。例えば連続するprint()の出力を改行なしで単純に連結したい場合は空文字列''を指定すればよい。

print('abc', end='---')
print('xyz')


print('abc', end='')
print('xyz')

source: print_basic.py
なお、デフォルトで改行されるのは引数endのデフォルト値が改行文字'\n'に設定されているから。
'''

def main():
    n=3
    steps=0
    state=0
    w=1
    j=0
    k=0
    
    
    
    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 j in range(m):
        c[j],d[j]=map(int, input().split(" "))
    ansln=[10**10]*n
    ansin=[0]*n
    for i in range(n):
     for j in range(m):
        
        lengh=abs(a[i]-c[j])+abs(b[i]-d[j])
        if lengh < ansln[i]:
         ansln[i]=lengh
         ansin[i]=j+1
    for i in range(n):
     print(ansin[i])


    
    
    
    
    


    
    
     

    l = ['aaa', 'bbb', 'ccc']
    x=l.index('aaa')
    
    
    
    

    
        
    
    

    
    
    
    
    DP = np.zeros(w+1, dtype=int)
    exdp=np.zeros((3,4)) 
    
    
    
        
        
    
    
        
        
    


    
    



    '''
    入力
    1234
    出力
    [1, 2, 3, 4]
    '''
    pin_l=["x" for i in range(10)]
    

    ls = ["a", "b", "c", "d", "e"]


    
    

    
    

    
    
    
    
    
    '''
    lsというリストの場合に、1つ飛びの値を取得したい場合には
    ls[::2]
    のようにします。こうすると、
    ["a", "c", "d"]と出力される
    '''

if __name__ == "__main__":
    main()

Solution (Python):

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

x = []
y = []

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

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

for i in range(n):
    ans = []
    for j in range(m):
        ans.append(abs(x[i][0]-y[j][0]) + abs(x[i][1]-y[j][1]))
    ind = ans.index(min(ans))
    print(ind + 1)

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

idou = []
for a, b in student:
  idousaki = -1
  nearest = 1000000000
  for i, xy in enumerate(cp):
    d = abs(xy[0]-a) + abs(xy[1]-b)
    if d < nearest:
      nearest = d
      idousaki = i+1
      
  idou.append(idousaki)
  
for i in idou:
  print(i)

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

for x in range(N):
    d1 = 999999999999999999
    for y in range(M):
        d = abs(ab[x][0] - cd[y][0]) + \
            abs(ab[x][1] - cd[y][1])
        if d < d1:
            d1 = d
            ans = y + 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)]

ans = []
for i, (a, b) in enumerate(ab):
  min_dist = 10**20
  idx = -1
  for j, (c, d) in enumerate(cd):
    dij = abs(a - c) + abs(b - d)
    if dij < min_dist:
      min_dist = dij
      idx = j
  ans.append(idx+1)

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

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

for student in students:
  a, b = student
  ans = None
  dist = 10**10
  for i in range(len(points)):
    c, d = points[i]
    tmp = abs(a-c) + abs(b-d)
    if tmp < dist:
      ans = i+1
      dist = tmp
      
  print(ans)

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:
    distance = 10**9
    point = 0
    for i, c in enumerate(C):
        if abs(a[0] - c[0]) + abs(a[1] - c[1]) < distance:
            distance = abs(a[0] - c[0]) + abs(a[1] - c[1])
            point = i
    print(point + 1)

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

Solution (Python):


import sys






























def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, m = mi()
    person = [lmi() for _ in range(n)]
    check = [lmi() for _ in range(m)]

    for x, y in person:
        nearest = None
        dist = inf
        for i in range(m):
            cx, cy = check[i]
            if dist > abs(cx - x) + abs(cy - y):
                dist = abs(cx - x) + abs(cy - y)
                nearest = i
        print(nearest + 1)



if __name__ == "__main__":
    main()

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

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

    ans = list()
    for student_num in range(n):
        delta_list = list()
        for point_num in range(m):
            x = abs(student_position[student_num][0] - check_point[point_num][0])
            y = abs(student_position[student_num][1] - check_point[point_num][1])
            delta = x + y
            delta_list.append(delta * 100 + point_num)
        nearest_index = min(delta_list)
        point = nearest_index % 100 + 1
        ans.append(point)
    
    for an in ans:
        print(an)
resolve()

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


for a, b in ab:
    num = float('inf')
    for i in range(M):
        if num > abs(a - cd[i][0]) + abs(b - cd[i][1]):
            num = abs(a - cd[i][0]) + abs(b - cd[i][1])
            check = i + 1
    ans.append(check)

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

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

for a, b in ab:
    ans = []
    for c, d in cd:
        tmp = abs(a - c) + abs(b - d)
        ans.append(tmp)
    print(ans.index(min(ans)) + 1)

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

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

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

for i in range(n):
    ans = 0
    min_man = 10e8
    num=0
    for j in range(m):
        man = abs(a[i]-c[j])+abs(b[i]-d[j])
        num+=1
        if min_man > man:
            min_man = man
            ans = num
    print(ans)

Solution (Python):

n, m = map(int, input().split())
students = []
cpoints = []
ans = []
for i in range(n):
    students.append(list(map(int,input().split())))
for i in range(m):
    cpoints.append(list(map(int,input().split())))
for i in range(n):
    nearest = 10**9
    a = students[i][0]
    b = students[i][1]
    for j in range(m):
        if nearest == abs(a-cpoints[j][0]) + abs(b-cpoints[j][1]):
                    continue
        if nearest > abs(a-cpoints[j][0]) + abs(b-cpoints[j][1]):
                    i_point = j
                    nearest = abs(a-cpoints[j][0]) + abs(b-cpoints[j][1])
    ans.append(i_point+1)
for i in range(n):
    print(ans[i])

Solution (Python):
def manhattan_distance(p, q) -> int:
    return abs(p[0] - q[0]) + abs(p[1] - q[1])


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

for student in students:
    p = min([(manhattan_distance(student, checkpoint), idx) for idx, checkpoint in enumerate(checkpoints, start=1)])
    print(p[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):
    check = 0
    point = abs(A[i][0]-C[0][0])+abs(A[i][1]-C[0][1])
    change = point
    for j in range(1,M):
        point = min(point,abs(A[i][0]-C[j][0])+abs(A[i][1]-C[j][1]))
        if point != change:
            check = j
            change = point
    print(check+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 ab in AB:
    MIN = float('inf')
    MIN_I = 0
    for i,cd in enumerate(CD):
        distance = abs(ab[0]-cd[0])+abs(ab[1]-cd[1])
        if MIN > distance:
            MIN = distance
            MIN_I = i
    print(MIN_I+1)

Solution (Python):
from sys import stdin
input = stdin.readline



def VI(N, init=0):
  return [init for _ in range(N)]
def VVI(N, M, init=0):
  return [[init for _ in range(M)] for _ in range(N)]

def VD(N, init=0.0):
  return [init for _ in range(N)]
def VVD(N, M, init=0.0):
  return [[init for _ in range(M)] for _ in range(N)]

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

A = VI(N)
B = VI(N)
C = VI(M)
D = VI(M)

for i in range(N):
  A[i], B[i] = map(int, input().rstrip().split())

for i in range(M):
  C[i], D[i] = map(int, input().rstrip().split())

INF = int(1e18)

ans = VI(N)
for i in range(N):
  a = A[i]
  b = B[i]
  ddist = INF
  for j in range(M):
    c = C[j]
    d = D[j]
    dist = abs(a-c)+abs(b-d)
    if (dist < ddist):
      ans[i] = j+1
      ddist = dist

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

for i in ab:
    l = []
    for j in cd:
        distance = abs(i[0]-j[0])+abs(i[1]-j[1])
        l.append(distance)
    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())
    
def Main(N, M, A, B, C, D):
    ans = []
    for i in range(N):
        min_dist = 10**9
        min_ind = 1
        for j in range(M):
            dist = abs(A[i]-C[j])+abs(B[i]-D[j])
            if min_dist > dist:
                min_dist = dist
                min_ind = j+1
        ans.append(min_ind)
    return ans
    
res = Main(N, M, A, B, C, D)
for e in res:
    print(e)

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

for a,b in ab:
    tmp = []
    for c,d in cd:
        tmp.append(abs(a-c)+abs(b-d))
    
    print(tmp.index(min(tmp))+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 x1, y1 in ab:
    l = 10**10
    index = 0
    for i, (x2, y2) in enumerate(cd):
        if l > abs(x1-x2)+abs(y1-y2):
            l = abs(x1-x2)+abs(y1-y2)
            index = i + 1
    print(index)

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

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

ans_list = []

for s_point in students:
    
    min_mhd = 9999999999
    p_index = 0
    for index, t_point in enumerate(t_points):
        temp_mhd = abs(s_point[0] - t_point[0]) + abs(s_point[1] - t_point[1])
        if min_mhd > temp_mhd:
            min_mhd = temp_mhd
            p_index = index
    ans_list.append(p_index+1)

for ans in ans_list:
    print(ans)

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

def dist(p, q):
    xp, yp = p
    xq, yq = q
    return abs(xp - xq) + abs(yp - yq)

for i in range(N):
    d = 10 ** 18
    p = -1
    for j in range(M):
        if dist(student[i], point[j]) < d:
            d = dist(student[i], point[j])
            p = j
    print(p + 1)

Solution (Python):
n, m = list(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):
    l_min = float('inf')
    ans = 0
    for j in range(m):
        l = abs(S[i][0] - C[j][0]) + abs(S[i][1] - C[j][1])
        if l < l_min:
            l_min = l
            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 x1, y1 in ab:
    l = 10**10
    index = 0
    for i, (x2, y2) in enumerate(cd):
        if l > abs(x1-x2)+abs(y1-y2):
            l = abs(x1-x2)+abs(y1-y2)
            index = i + 1
    print(index)

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

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 i in range(n):
  a, b = ab[i]
  
  dist = 1e+15
  ans = 0
  for j in range(m):
    c, d = cd[j]    

    if dist > abs(a - c) + abs(b - d):
      ans = j
      dist = abs(a - c) + abs(b - d)
  
  print(ans+1)

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]


def Yes(): print("Yes"); return
def No(): print("No"); return


def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def Base_10_to_n(X, n):
  if X//n:
    return Base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def Base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





N,M = inputIL()
n = inputILL(N)
m = inputILL(M)

ans = []
for c,d in n:
  MIN = (INF,INF)
  count = 0
  for a,b in m:
    count += 1
    dis = abs(a-c)+abs(d-b)
    if dis < MIN[0]:
      MIN = (dis,count)
  ans.append(str(MIN[1]))

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

Solution (Python):
n,m = map(int,input().split())
student = [[0]*2 for _ in range(n)]
check = [[0]*2 for _ in range(m)]
for i in range(n):
    student[i][0],student[i][1] = map(int,input().split())
for i in range(m):
    check[i][0],check[i][1] = map(int, input().split())

INF = 10**9
for i in range(n):
    zantei = INF
    ans = 1
    for j in range(m):
        dum = abs(student[i][0] - check[j][0]) + abs(student[i][1] - check[j][1])
        if dum < zantei:
            ans = j+1
            zantei = dum
    print(ans)

Solution (Python):

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

for std in students:
    cp_idx = 0
    dist = abs(std[0] - cps[0][0]) + abs(std[1] - cps[0][1])
    for i in range(1, M):
        new_dist = abs(std[0] - cps[i][0]) + abs(std[1] - cps[i][1])
        if new_dist < dist:
            cp_idx = i
            dist = new_dist
    print(cp_idx + 1)

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    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 x,y in a:
        tmp=INF
        for i,(xx,yy) in enumerate(b):
            if abs(xx-x)+abs(yy-y)<tmp:
                tmp=abs(xx-x)+abs(yy-y)
                ans=i+1
        print(ans)

if __name__ == '__main__':
    main()

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

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

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

for i in range(n):
    d = abs(ln[i][0] - lm[0][0]) + abs(ln[i][1] - lm[0][1])
    ans = 1
    for j in range(1, m):
        if d > abs(ln[i][0] - lm[j][0]) + abs(ln[i][1] - lm[j][1]):
            d = abs(ln[i][0] - lm[j][0]) + abs(ln[i][1] - lm[j][1])
            ans = j+1
    print(ans)

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

def dist(a, b):
    return abs(a[0] - b[0]) + abs(a[1] - b[1])

for i in range(n):
    minx = 10**9
    goto = 0
    for j in range(m):
        tmp = dist(student[i], chkpoint[j])
        if minx > tmp:
            minx = tmp
            goto = j+1
    print(goto)

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

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

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

res_min = [10**9]*N 
res = [0]*N 


for i in range(N):
    for j in range(M):
        temp = abs(a[i]-c[j]) + abs(b[i]-d[j])
        if res_min[i] > temp:
            res_min[i] = temp
            res[i] = j+1
for i in range(N):
    print(res[i])