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())
A = []
B = []
C = []
D = []
check = []

def Manhattan(a,b,c,d):
  distant = abs(a-c)+abs(b-d)
  return distant

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 i in range(N):
  for j in range(M):
   if(j == 0):
    min = Manhattan(A[i],B[i],C[j],D[j])
    check.append(j+1)
   else:
    tmp = Manhattan(A[i],B[i],C[j],D[j])
    if(min > tmp):
      min = tmp
      check[i] = j+1
  print(check[i])

Solution (Python):
N,M = map(int,input().split())
a = []
b = []
c = []
d = []
for i in range(N+M):
    x,y = map(int,input().split())
    if i<N:
        a.append(x)
        b.append(y)
    else:
        c.append(x)
        d.append(y)
for i in range(N):
    min_man = 10**10
    min_j = 0
    for j in range(M):
        man = abs(a[i]-c[j])+abs(b[i]-d[j])
        if min_man > man:
            min_man = man
            min_j = j
    print(min_j+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)]
for i, j in st:
    min = float('inf')
    min_num = 0
    for num, xy in enumerate(ch):
        if abs(i - xy[0]) + abs(j - xy[1]) < min:
            min = abs(i - xy[0]) + abs(j - xy[1])
            min_num = num + 1
    print(min_num)

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

for stu in range(n):
  ans = float("inf")
  for che in range(m):
    tmp_ans = abs(coord_student[stu][0]-coord_check[che][0])+abs(coord_student[stu][1]-coord_check[che][1])
    if tmp_ans < ans:
      ans = tmp_ans
      index = che
  print(index+1)

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

for i in range(N):
    point = 1
    min_dst = 1e20
    for j in range(M):
        dst = abs(a[i]-c[j]) + abs(b[i]-d[j])
        if dst < min_dst:
            min_dst = dst
            point = j+1
    print(point)

Solution (Python):
n,m = map(int, input().split())
aa = [0] * n
bb = [0] * n
cc = [0] * m
dd = [0] * m

for i in range(n):
    aa[i], bb[i] = map(int, input().split())
for i in range(m):
    cc[i], dd[i] = map(int, input().split())

for i in range(n):
    d = [abs(aa[i] - cc[j]) + abs(bb[i] - dd[j]) for j in range(m)]
    print(d.index(min(d))+1)

Solution (Python):
N,M = map(int,input().split())
L = []
ans = 0
for i in range(N):
  L.append(list(map(int,input().split())))
K = []
for i in range(M):
  K.append(list(map(int,input().split())))
for j in range(N):
  S = float('inf')
  ans = 0
  for k in range(M):
    if abs(L[j][0]-K[k][0])+abs(L[j][1]-K[k][1]) < S:
      S = abs(L[j][0]-K[k][0])+abs(L[j][1]-K[k][1])
      ans = k+1 
  print(ans)

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):
    u,v=map(int,input().split())
    c.append(u)
    d.append(v)

for i in range(n):
    min=19**9+1
    arg=1
    for j in range(m):
        if min > abs(a[i]-c[j])+abs(b[i]-d[j]):
            min = abs(a[i]-c[j])+abs(b[i]-d[j])
            arg = j+1
    print(arg)

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

for a, b in AB:
    dist = 10 ** 12
    for i, cd in enumerate(CD):
        tmp = abs(a - cd[0]) + abs(b - cd[1])
        if tmp < dist:
            dist = tmp
            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 i in range(n):
    index = 0
    dmin = float("inf")
    for j in range(m):
        d = abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1])
        if d < dmin:
            dmin = d
            index = j
    print(index+1)

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

for i in range(N):
  ans = -1
  for j in range(M):
    if ans==-1 or abs(a[i]-c[j])+abs(b[i]-d[j]) < abs(a[i]-c[ans])+abs(b[i]-d[ans]):
      ans = j
  print ans+1

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

result = []
for a, b in AB:
  tmp = []
  for c, d in CD:
    tmp.append(abs(a-c) + abs(b-d))
  result.append(tmp.index(min(tmp))+1)
for r in result:
  print(r)

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(1000000)



def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))



def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v



def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk



def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False



dp = None


def calc_distance(s, p):
    x, y = s
    x_, y_ = p

    return abs(x - x_) + abs(y - y_)


def main():
    N, M = li_input()
    S = [li_input() for _ in range(N)]
    P = [li_input() for _ in range(M)]

    for s in S:
        ans_d = -1
        ans_i = -1
        for i, p in enumerate(P, start=1):
            d = calc_distance(s, p)

            if ans_d == -1 or d < ans_d:
                ans_d = d
                ans_i = i
        
        print(ans_i)

main()

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

for _ in [0]*N:
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

for _ in [0]*M:
    c, d = map(int, input().split())
    C.append(c)
    D.append(d)

for i in range(N):
    ans = [300000000, 0]
    for j in range(M):
        s = abs(A[i] - C[j]) + abs(B[i] - D[j])
        if ans[0] > s:
            ans = [s, j+1]
    print(ans[1])

Solution (Python):
n,m=map(int,input().split())
h=[]
p=[]
def man(a,c,b,d):
    s=abs(a-c)+abs(b-d)
    return s
for i in range(n):
    h.append(list(map(int,input().split())))
for j in range(m):
    p.append(list(map(int,input().split())))
for k in range(n):
    l=float("inf")
    for v in range(m):
        x=man(h[k][0],p[v][0],h[k][1],p[v][1])
        if x<l:
            l=x
            y=v+1
    print(y)

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

Solution (Python):
n, m = map(int, input().split())
a = [tuple(map(int, input().split())) for i in range(n)]
b = [0] + [tuple(map(int, input().split())) for i in range(m)]

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

for i in range(n):
    c = 1
    t = d(a[i], b[1])
    for j in range(2, m+1):
        if d(a[i], b[j]) < t:
            c = j
            t = d(a[i], b[j])
    print(c)

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

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

Solution (Python):
INF = 1000000007

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

ab = []

for i in range(N):
    ab.append([int(i) for i in input().split()])

cd = []

for i in range(M):
    cd.append([int(i) for i in input().split()])

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

        if tmp < dst:
            
            dst = tmp
            ans = j + 1

    print(ans)

Solution (Python):
def gcd(A, B, C, D):
	l, L = A-C, B-D
	if l<0:
		l = l*(-1)
	if L<0:
		L = L*(-1)
	return l+L
	
N, M = map(int, input().split())
x = []
y = []
n = 0
m = 0
ans = 1
for i in range(N):
	x1, y1 = map(int, input().split())
	x.append(x1)
	y.append(y1)
X = []
Y = []
for l in range(M):
	x2, y2 = map(int, input().split())
	X.append(x2)
	Y.append(y2)
for a in range(N):
	m = gcd(x[a], y[a], X[0], Y[0])
	for b in range(M):
		n = gcd(x[a], y[a], X[b], Y[b])
		if n < m:
			m = n
			ans = b+1
	print(ans)
	ans = 1

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):
  man=1000000000
  ans=0
  for j in range(m):
    if abs(A[i][0]-B[j][0])+abs(A[i][1]-B[j][1])<man:
      man=abs(A[i][0]-B[j][0])+abs(A[i][1]-B[j][1])
      ans=j+1
  print(ans)

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

Solution (Python):
n,m=map(int,input().split())
a,b,c,d=[],[],[],[]
for i in range(n):
    o = list(map(int, input().split()))
    a.append(o[0])
    b.append(o[1])
for i in range(m):
    o = list(map(int, input().split()))
    c.append(o[0])
    d.append(o[1])
s = []
for i in range(n):
    g = float('inf')
    h = 0
    for j in range(m):
        if g > abs(a[i]-c[j])+abs(b[i]-d[j]):
            g = abs(a[i]-c[j])+abs(b[i]-d[j])
            h = j+1
    s.append(h)
for i in s:
    print(i)

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

for ab in AB:
    dist = [abs(ab[0] - cd[0]) + abs(ab[1] - cd[1]) for cd in CD]
    print(dist.index(min(dist)) + 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)]

for ab in AB:
    ans = 10 ** 12
    id = 0
    for i, cd in enumerate(CD):
        tmp = abs(ab[0] - cd[0]) + abs(ab[1] - cd[1])
        if tmp < ans:
            ans = tmp
            id = i + 1
    print(id)

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

for student in students:
    dist = []
    for checkpoint in checkpoints:
        dist.append(abs(student[0] - checkpoint[0]) + abs(student[1] - checkpoint[1]))
    print(dist.index(min(dist)) + 1)

Solution (Python):
n,m = map(int,input().split())
AB = [[int(i) for i in input().split()] for j in range(n)]
CD = [[int(k) for k in input().split()] for l in range(m)]

ans = [0]*n
for ab in AB:
    a,b = ab[0],ab[1]
    distance = 1000000000
    for cd in CD:
        c,d = cd[0], cd[1]
        if distance > abs(a-c) + abs(b-d):
            distance = abs(a-c) + abs(b-d)
            ans[AB.index(ab)] = CD.index(cd)+1
        
for _ in ans:
    print(_)

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

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

check_points = []

for _ in range(M):
    l = list(map(int,input().split()))
    check_points.append(l)

minimum_points = 0

for person in students:
    minimum = 10**10
    for i in range(len(check_points)):
        d=abs(person[0]-check_points[i][0])+abs(person[1]-check_points[i][1])
        if minimum > d:
            minimum = d
            minimum_points = i
    print(minimum_points+1)

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

a_arr = []
b_arr = []
for _ in range(N):
    a, b = map(int, input().split())
    a_arr.append(a)
    b_arr.append(b)
    
c_arr = []
d_arr = []
for _ in range(M):
    c, d = map(int, input().split())
    c_arr.append(c)
    d_arr.append(d)

for n in range(N):
    ans = 0
    min_dis = 4 * 10**8 + 1
    for m in range(M):
        dis = abs(a_arr[n] - c_arr[m]) + abs(b_arr[n] - d_arr[m])
        if dis < min_dis:
            min_dis = dis
            ans = m + 1
    print(ans)

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

ans = []
for i in range(N):
    tmp = 10**9
    idx = 0
    for j in range(M):
        dist = abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1])
        if dist < tmp:
            tmp = dist
            idx = j
    ans.append(idx+1)

for a in ans:
    print(a)

Solution (Python):



from sys import stdin
import sys

def manhattan_dist(a, c):
    return  abs(a[0]-c[0]) + abs(a[1]-c[1])



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



a=[]
c=[]
for i in range (N):
    a.append( map(int, stdin.readline().split()) )

for i in range (M):
    c.append( map(int, stdin.readline().split()) )

prev_dist=sys.maxint
index=[]
for i in range (N):
    for j in range (M):
        if prev_dist > manhattan_dist( a[i], c[j] ):
            index = (manhattan_dist( a[i], c[j] ), j+1 )
            prev_dist = manhattan_dist( a[i], c[j] )
    print index[1] 
    prev_dist=sys.maxint

Solution (Python):
n, m = map(int, input().split())
posi = [tuple(map(int, input().split())) for _ in range(n)]
goal = [None]+[tuple(map(int, input().split())) for _ in range(m)]
for i in range(n):
    table = [0, float("inf")]
    for j in range(1, m+1):
        d = abs(posi[i][0]-goal[j][0])+abs(posi[i][1]-goal[j][1])
        if d < table[1]:
            table = [j, d]
    print(table[0])

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


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

mylist2=[[] for i in range(m)]
for i in range(m):
    mylist2[i]=[int(i) for i in input().split()]  

for i in range(n):
    dist= float("inf")
    ans=0
    for j in range(m):
        tmp=abs(mylist1[i][0]-mylist2[j][0])+abs(mylist1[i][1]-mylist2[j][1])

        if tmp < dist:
            ans=j
            dist=tmp
    print(ans+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)]

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

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

place = [0] * len(AB)
for i, ab in enumerate(AB):
    dist = 10 ** 9
    for j, cd in enumerate(CD):
        tmp = abs(ab[0] - cd[0]) + abs(ab[1] - cd[1])
        if tmp < dist:
            dist = tmp
            place[i] = j + 1
            
for i in place:
    print(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])
for i in range(M):
	c,d = map(int, input().split())
	B.append([c,d])


for i in range(N):
	z = A[i]
	ans = []
	for j in range(M):
		ch = B[j]
		d = abs(z[0]-ch[0]) + abs(z[1]-ch[1])
		ans.append([j,d])
	
	ans.sort(key=lambda x:x[1])
	
	print(ans[0][0]+1)

Solution (Python):


import sys


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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n, m = LI()
ab = [LI() for _ in range(n)]
cd = [LI() for _ in range(m)]

for a, b in ab:
    ans = -1
    dist = INF
    for i in range(m):
        c, d = cd[i]
        tmp = abs(c - a) + abs(d - b)
        if tmp < dist:
            dist = tmp
            ans = i + 1
    print(ans)

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

ST = [[int(x) for x in input().split()] for y in range(n)]
CH = [[int(x) for x in input().split()] for y in range(m)]

for a, b in ST:
    manhat = [abs(a - c) + abs(b - d) for c, d in CH]
    print(manhat.index(min(manhat)) + 1)

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

li=[list(map(int,input().split())) for i in range(n)]
lj=[list(map(int,input().split())) for i in range(m)]

for i in range(n):
    li_distance=[abs(lj[j][0]-li[i][0])+abs(lj[j][1]-li[i][1]) for j in range(m)]
    print(li_distance.index(min(li_distance))+1)

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

li=[list(map(int,input().split())) for i in range(n)]
lj=[list(map(int,input().split())) for i in range(m)]

for i in range(n):
    li_distance=[abs(lj[j][0]-li[i][0])+abs(lj[j][1]-li[i][1]) for j in range(m)]
    print(li_distance.index(min(li_distance))+1)

Solution (Python):
N, M = map(int,input().split())
students = []
checkpoints = []
for i in range(N):
    x,y = map(int,input().split())
    students.append([x,y])
for i in range(M):
    x,y = map(int,input().split())
    checkpoints.append([x,y])
ans = []
for i in range(N):
    ans_tmp = [1000000000,-1]
    for q in range(M):
        dist = abs(students[i][0]-checkpoints[q][0]) + abs(students[i][1]-checkpoints[q][1])
        if dist < ans_tmp[0]:
            ans_tmp[0] = dist
            ans_tmp[1] = q
    ans.append(ans_tmp[1]+1)
for k in ans:
    print(k)

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

def calc(a, b, CD):
    mini, mind = -1, 10**10
    for i, cd in enumerate(CD):
        c, d = cd
        d = abs(c - a) + abs(d - b)
        if d < mind:
            mini, mind = i, d
    return mini + 1

for a, b in AB:
    print(calc(a, b, CD))

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

for ai in a:
    n = [abs(ai[0] - bi[0]) + abs(ai[1] - bi[1]) for bi in b]
    print(n.index(min(n)) + 1)

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

ans = [0 for i in range(n)]
for i in range(n):
    distance = 1e16
    tmp_ans = 1
    for j in range(m):
        tmp_dis = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if distance > tmp_dis:
            distance = tmp_dis
            tmp_ans = j + 1
    print(tmp_ans)

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

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

for i in range(n):
    min = 200000001
    p = 1
    for j in range(m):
        z = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if z < min:
            min = z
            p = j + 1

    print(p)

Solution (Python):

N, M = [int(x) for x in input().split()]

st = []
for i in range(N):
    st.append([int(x) for x in input().split()])
cp = []
for i in range(M):
    cp.append([int(x) for x in input().split()])



for i in range(N):
    mindist = 10**9
    for j in range(M):
        d = abs(cp[j][0]-st[i][0]) + abs(cp[j][1]-st[i][1])
        if d<mindist: 
            mindist = d
            nth = j
    print(nth+1)

Solution (Python):
a,b=map(int,input().split())
p=[list(map(int,input().split()))for i in range(a)]
q=[list(map(int,input().split()))for i in range(b)]
for i in range(a):
    r=[]
    for j in range(b):
        r.append([abs(p[i][0]-q[j][0])+abs(p[i][1]-q[j][1]),j+1])
    else:
        r.sort()
        print(r[0][1])

Solution (Python):
n,m = (int(i) for i in input().split())
x =[]
checkpoint =[]
for i in range(n):
  tmp =list(int(i) for i in input().split())
  x.append(tmp)
for j in range(m):
  tmp = list(int(i) for i in input().split())
  checkpoint.append(tmp)

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

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

point = [0] * N

for i in range(N):
    tmp = 300000000
    for j in range(M):
        l = abs(c[j] - a[i]) + abs(d[j] - b[i])
        if tmp > l:
            point[i] = j + 1
            tmp = l
    print(point[i])

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

Ans = []
for i in range(N):
    d = 10**9
    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])
            ans = j
    Ans.append(ans)


for ans in Ans:
    print(ans+1)

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

for i in range(n):
    distance = 10**9
    ans = 0
    for j in range(m):
        temp_dictance = abs(students[i][0]-check_point[j][0]) + abs(students[i][1]-check_point[j][1])
        if temp_dictance < distance:
            distance = temp_dictance
            ans = j+1
    print(ans)

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

for i in range(N):
    x = persons[i][0]
    y = persons[i][1]
    distance = []
    for j in range(M):
        distance_j = abs(x-chechpoints[j][0])+abs(y-chechpoints[j][1])
        distance.append(distance_j)
    print(distance.index(min(distance))+1)

Solution (Python):
import sys
input = sys.stdin.readline
N,M = map(int,input().split())
persons = []
chechpoints = []
for i in range(N):
    a = list(map(int,input().split()))
    persons.append(a)
for j in range(M):
    a = list(map(int,input().split()))
    chechpoints.append(a)

for i in range(N):
    x = persons[i][0]
    y = persons[i][1]
    distance = []
    for j in range(M):
        distance_j = abs(x-chechpoints[j][0])+abs(y-chechpoints[j][1])
        distance.append(distance_j)
    print(distance.index(min(distance))+1)

Solution (Python):
while(True):
    try:
        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)]
    except EOFError:
        exit()
    for a, b in ab:
        dist = [abs(a - c) + abs(b - d) for c, d in cd]
        print(dist.index(min(dist)) + 1)

Solution (Python):
n,m=map(int,input().split())
ab=[[int(j) for j in input().split()] for i in range(n)]
cd=[[int(j) for j in input().split()] for i in range(m)]
for a,b in ab:
    l=[abs(a-c)+abs(b-d) for c,d in cd]
    print(l.index(min(l))+1)

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

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

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

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

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

Solution (Python):
int_n, int_m = map(int, input().split())

li_n = list()
li_m = list()

for i in range(int_n):
    li_n.append(list(map(int, input().split())))

for i in range(int_m):
    li_m.append(list(map(int, input().split())))


for n in li_n:
    l_dis = [abs(n[0] - m[0]) + abs(n[1] - m[1]) for m in li_m]

    minimum = min(l_dis)
    print(l_dis.index(minimum) + 1)

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

for x, y in student:
    tmp = 10 ** 10
    for i, C in enumerate(check):
        cx, cy = C[0], C[1]
        man = abs(x-cx)+abs(y-cy)
        if tmp > man:
            tmp = man
            ans = i
    print(ans + 1)

Solution (Python):
def abc057_b():
    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):
        tmp_index = 0
        d = 10 ** 9
        for j in range(m):
            tmp_d = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
            if tmp_d < d:
                tmp_index = j
                d = tmp_d
        print(tmp_index + 1)


abc057_b()