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

S=[]
C=[]

for i in range(N):
  a,b=map(int,input().split())
  S.append([a,b])
for i in range(M):
  a,b=map(int,input().split())
  C.append([a,b])
  
for a,b in S:
  min=M
  man=10**10
  for i in range(M):
    cnt=abs(a-C[i][0])+abs(b-C[i][1])
    if man>cnt:
      man=cnt
      min=i
  print(min+1)

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

def searchpoint(student, lst):
	min = 1000000000
	ans = -1
	for i in range(0, len(lst)):
		tmp = distance(student, lst[i])
		if tmp < min:
			min = tmp
			ans = i + 1
	return ans

N, M = map(int, raw_input().split())
student = []
for i in range(0, N):
	student.append(map(int, raw_input().split()))
checkpoint = []
for i in range(0, M):
	checkpoint.append(map(int, raw_input().split()))
for i in range(0, N):
	print searchpoint(student[i], checkpoint)

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

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

for i in range(N):
    min_point = 0
    min_man = 0
    for j in range(M):
        man = abs(P[i][0]-C[j][0]) + abs(P[i][1]-C[j][1])
        if min_man > man or min_point==0:
            min_man = man
            min_point = j+1
    print(min_point)

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

ans = 50
distance = 'a'

for i in range(n):
    for j in range(m):
        e = abs(a[i]-c[j])+abs(b[i]-d[j])
        if distance == 'a':
            distance = e
            ans = j
        elif distance > e:
            distance = e
            ans = j
    print(ans+1)
    ans = 50
    distance = 'a'

Solution (Python):
N, M = map(int, input().split())
student_list = []
checkpoint_list = []
for _ in range(N):
    student_list.append(list(map(int, input().split())))
    
for _ in range(M):
    checkpoint_list.append(list(map(int, input().split())))
    
for i in student_list:
    compare_dict = {}
    for k, l in enumerate(checkpoint_list):
        
        manhattan_d = abs(i[0]-l[0])+abs(i[1]-l[1])
        
        if manhattan_d not in compare_dict.keys():
            compare_dict[manhattan_d] = k+1
        else:
            pass
    
    print(compare_dict[sorted(compare_dict.keys())[0]])

Solution (Python):
n,m=map(int,input().split())
a=[tuple(map(int,input().split()))for i in range(n)]
b=[tuple(map(int,input().split()))for j in range(m)]
total=10**17
num=0
ans=[]
for i in range(n):
    for j in range(m):
        dis=abs(a[i][0]-b[j][0])+abs(a[i][1]-b[j][1])
        if dis<total:
            total=dis
            num=j+1
    ans.append(num)
    total=10**17
for i in ans:
    print(i)

Solution (Python):
def inpl(): return list(map(int, input().split()))
N, M = inpl()
s = []
c = []
for i in range(N):
    s.append(inpl())
for i in range(M):
    c.append(inpl())
for s_i in s:
    ans = 0
    d = 10000000000
    for (j, c_j) in enumerate(c):
        temp = abs(s_i[0]-c_j[0])+abs(s_i[1]-c_j[1])
        if temp<d:
            d = temp
            ans = j+1
            
    print(ans)

Solution (Python):
N, M = map(int, input().split())
ab = [[int(a) for a in input().split()] for _ in range(N)]
cd = [[int(a) for a in input().split()] for _ in range(M)]
for i in range(N):
    min_distance = float('inf')
    check_point = 0
    for j in range(M):
        manhattan_distance = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if min_distance > manhattan_distance:
            min_distance = manhattan_distance
            check_point = j+1
    print(check_point)

Solution (Python):
if __name__ == '__main__':
    student_count, checkpoint_count = map(int, input().split())
    student_points = [list(map(int, input().split())) for i in range(1, student_count + 1)]
    check_points = [list(map(int, input().split())) for i in range(1, checkpoint_count + 1)]
 
    for student_point_x, student_point_y in student_points:
        point_number = 0
        shortest_distance = float('inf')
        manhattan_distance = 0
 
        for i in range(len(check_points)):
            diff_x = abs(student_point_x - check_points[i][0])
            diff_y = abs(student_point_y - check_points[i][1])
            manhattan_distance = diff_x + diff_y
 
            if manhattan_distance < shortest_distance:
                shortest_distance = manhattan_distance
                point_number = i + 1
 
        print(point_number)

Solution (Python):
n, m = map(int, input().split())
a = [None] * n
for i in range(n):
    a[i] = tuple(map(int, input().split()))
b = [None] * m
for i in range(m):
    b[i] = tuple(map(int, input().split()))
for x, y in a:
    z = None
    k = None
    for i in range(m):
        c, d = b[i]
        d = abs(x - c) + abs(y - d)
        if z is None or d < z:
            z = d
            k = i
    print(k + 1)

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

def nearest(x, y, checkpoints):
    distances = list(map(lambda c: distance(x, y, c[0], c[1]), checkpoints))
    return 1 + distances.index(min(distances))


if __name__ == '__main__':
    n, m = map(int, input().split())
    students = [list(map(int, input().split())) for _ in range(n)]
    checkpoints = [list(map(int, input().split())) for _ in range(m)]
    for x, y in students:
        print(nearest(x, y, checkpoints))

Solution (Python):





if __name__ == '__main__':
    student_count, checkpoint_count = map(int, input().split())
    student_points = [list(map(int, input().split())) for i in range(1, student_count + 1)]
    check_points = [list(map(int, input().split())) for i in range(1, checkpoint_count + 1)]

    for student_point_x, student_point_y in student_points:
        point_number = 0
        shortest_distance = float('inf')
        manhattan_distance = 0

        for i in range(len(check_points)):
            diff_x = abs(student_point_x - check_points[i][0])
            diff_y = abs(student_point_y - check_points[i][1])
            manhattan_distance = diff_x + diff_y

            if manhattan_distance < shortest_distance:
                shortest_distance = manhattan_distance
                point_number = i + 1

        print(point_number)

Solution (Python):
n, m = map(int,input().split())
abl = [[int(i) for i in input().split()] for i in range(n)]
cdl = [[int(i) for i in input().split()] for i in range(m)]
ans = []
for i in range(n):
    tmp = abs(abl[i][0]-cdl[0][0])+abs(abl[i][1]-cdl[0][1])
    c_i = 1
    for j in range(1,m):
        if tmp > abs(abl[i][0]-cdl[j][0])+abs(abl[i][1]-cdl[j][1]):
            tmp = abs(abl[i][0]-cdl[j][0])+abs(abl[i][1]-cdl[j][1])
            c_i = j+1
    ans.append(c_i)
for i in range(n):
    print(ans[i])

Solution (Python):
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for x in [0]*n]
cd = [list(map(int,input().split())) for x in [0]*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 = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(n)]
y = [[int(i) for i in input().split()] for i in range(m)]
for i in x:
	num,answer = abs(i[0]-y[0][0])+abs(i[1]-y[0][1]),1
	for j in range(m):
		if num > abs(i[0]-y[j][0])+abs(i[1]-y[j][1]):
			answer = j+1
			num = abs(i[0]-y[j][0])+abs(i[1]-y[j][1])
	print(answer)

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

stu_list = []
cp_list = []

for i in range(N):
    stu_list.append(list(map(int, input().split())))

for j in range(M):
    cp_list.append(list(map(int, input().split())))

for i in range(len(stu_list)):
    min_cp = 0
    min_d = 10**9
    for j in range(len(cp_list)):
        d = abs(stu_list[i][0] - cp_list[j][0]) + abs(stu_list[i][1] - cp_list[j][1])

        if min_d > d:
            min_cp = j + 1
            min_d = d

    print(min_cp)

Solution (Python):
import pprint
import itertools

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

AB = []
for i in range(N):
    AB.append(tuple([int(s) for s in input().split()]))

CD = []
for j in range(M):
    CD.append(tuple([int(s) for s in input().split()]))

for i in range(N):
    mi = 0
    di = abs(CD[0][0] - AB[i][0]) + abs(CD[0][1] - AB[i][1])
    for j in range(1, M):
        md = abs(CD[j][0] - AB[i][0]) + abs(CD[j][1] - AB[i][1])
        if md < di:
            mi, di = j, md
    print(mi + 1)

Solution (Python):
N, M = map(int, input().split())
students = list()
points = list()
for i in range(0, N):
    coord = list(map(int, input().split()))
    students.append(coord)
for i in range(0, M):
    coord = list(map(int, input().split()))
    points.append(coord)
for student in students:
    min_dis = 4000000000
    ans = 0
    m = 0
    for point in points:
        m += 1
        temp = abs(student[0] - point[0]) + abs(student[1] - point[1])
        if min_dis > temp:
            min_dis = temp
            ans = m
    print(ans)

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n,m = na()
s = [na() for _ in range(n)]
c = [na() for _ in range(m)]

l = []
for i in s:
    for j in c:
        l.append(abs(i[0]-j[0]) + abs(i[1]-j[1]))
    a = l.index(min(l))
    print(a+1)
    l = []

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

n_lis = [list(map(int, input().split())) for i in range(n)]
m_lis = [list(map(int, input().split())) for i in range(m)]
import sys

for i in n_lis:
    min_num = sys.maxsize
    ans_index = 0
    for index, j in enumerate(m_lis):
        num = abs(i[0] - j[0]) + abs(i[1] - j[1])
        if min_num > num:
            min_num = num
            ans_index = index + 1
    print(ans_index)

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 j in range(M)]
d=[0 for j in range(M)]
for i in range(N):
  a[i],b[i]=map(int,input().split())
for j in range(M):
  c[j],d[j]=map(int,input().split())
for i in range(N):
  k=0
  for j in range(M):
    if abs(a[i]-c[k])+abs(b[i]-d[k])>abs(a[i]-c[j])+abs(b[i]-d[j]):
      k=j
  print(k+1)

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

students = [tuple(map(int, input().split())) for i in range(n)]
checkpoints = [tuple(map(int, input().split())) for j in range(m)]

def distance(u, v):
    return abs(u[0] - v[0]) + abs(u[1] - v[1])


for s in students:
    j = -1
    v = 2*10**9
    for i, cp in enumerate(checkpoints):
        d = distance(s, cp)
        if d < v:
            j = i
            v = d
    print(j+1)

Solution (Python):
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for x in [0]*n]
cd = [list(map(int,input().split())) for x in [0]*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())
student = [tuple(map(int,input().split())) for i in range(n)]
check = [tuple(map(int,input().split())) for i in range(m)]
for a,b in student:
	d = [abs(a-c)+abs(b-d) for c,d in check]
	print(d.index(min(d))+1)

Solution (Python):
n,m=map(int,input().split())
s=[list(map(int,input().split())) for i in range(n)]
p=[list(map(int,input().split())) for i in range(m)]
man=0
inde=1
for i in range(n):
    arr=[abs(s[i][0]-p[0][0])+abs(s[i][1]-p[0][1])]
    for j in range(1,m):
        man=abs(s[i][0]-p[j][0])+abs(s[i][1]-p[j][1])
        if man<min(arr):
            arr.append(man)
            inde=j+1
    print(inde)
    inde=1

Solution (Python):
import sys
N,M=map(int,input().split())
ai=[0for i in range(N)]
bi=[0for i in range(N)]
ci=[0for i in range(M)]
di=[0for i in range(M)]
disti=[10**9 for i in range(N)]
checki=[0 for i in range(N)]

for i in range(N):
    ai[i],bi[i]=map(int,input().split())
for i in range(M):
    ci[i],di[i]=map(int,input().split())
    
for i in range(N):
    for j in range(M):
        dist=abs(ai[i]-ci[j])+abs(bi[i]-di[j])
        if(disti[i]>dist):
            disti[i]=dist
            checki[i]=j+1
            
for i in checki:
    print(i)

Solution (Python):

"""
https://beta.atcoder.jp/contests/abc057/tasks/abc057_b

"""
import sys
from sys import stdin
input = stdin.readline


def calc_dist(s, c):
    return abs(s[0] - c[0]) + abs(s[1] - c[1])


def solve(students, checkpoints):
    ans = []

    for s in students[1:]:
        dist = [float('inf')]
        for c in checkpoints[1:]:
            d = calc_dist(s, c)
            dist.append(d)
        min_dist = min(dist)
        cp_num = dist.index(min_dist )
        ans.append(cp_num)
    return ans


def main(args):
    students = [[0, 0]]
    N, M = map(int, input().split())
    for _ in range(N):
        a, b = map(int, input().split())
        students.append([a, b])
    checkpoints = [[0, 0]]
    for _ in range(M):
        c, d = map(int, input().split())
        checkpoints.append([c, d])
    ans = solve(students, checkpoints)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])

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

for x, y in Student:
    ans = [-1, float('inf')]
    for j, (x2, y2) in enumerate(Checkpoint):
        dist = abs(x2 - x) + abs(y2 - y)
        if dist < ans[1]:
            ans = [j, dist]
    print(ans[0] + 1)

Solution (Python):
N,M=map(int, input().split())
 
A=[]
B=[]
for i in range(N):
    a,b=map(int, input().split())
    A.append(a)
    B.append(b)
 
C=[]
D=[]
for i in range(M):
    c,d=map(int, input().split())
    C.append(c)
    D.append(d)
 
T=[]
S=[]
for i in range(N):
    for j in range(M):
        T.append(abs(A[i]-C[j])+abs(B[i]-D[j]))
    S.append(T.index(min(T))+1)
    T=[]
 
for i in range(N):
    print(S[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)

T=[]
S=[]
for i in range(N):
    for j in range(M):
        T.append(abs(A[i]-C[j])+abs(B[i]-D[j]))
    S.append(T.index(min(T))+1)
    T=[]

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

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

for x1, y1 in crd:
   ans = 0
   min_m = float("inf")
   for i, (x2, y2) in enumerate(chk, 1):
      m = abs(x1 - x2) + abs(y1 - y2)
      if min_m > m:
         ans = i
         min_m = m
 
   print(ans)

Solution (Python):
n, m = [int(x) for x in input().split()]
s = []
c = []
for _ in range(n):
    a, b = [int(x) for x in input().split()]
    s.append((a, b))
for _ in range(m):
    a, b = [int(x) for x in input().split()]
    c.append((a, b))
for sx, sy in s:
    v = []
    for i, (cx, cy) in enumerate(c):
        v.append((i, abs(cx - sx) + abs(cy - sy)))
    print(sorted(v, key=lambda x: x[1])[0][0] + 1)

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

Solution (Python):
def main():
    N, M = map(int, input().split())
    pos = [
        list(map(int, input().split()))
        for i in range(N)
    ]
    checkpoints = [
        list(map(int, input().split()))
        for i in range(M)
    ]

    for x1, y1 in pos:
        ans = 0
        min_m = float("inf")
        for i, (x2, y2) in enumerate(checkpoints, 1):
            m = abs(x1 - x2) + abs(y1 - y2)
            if min_m > m:
                ans = i
                min_m = m

        print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for x in [0]*n]
cd = [list(map(int,input().split())) for x in [0]*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):
def main():
    N, M = map(int, input().split())
    
    A = []
    B = []
    for _ in range(N):
        hoge = list(map(int, input().split()))
        A.append(hoge[0])
        B.append(hoge[1])

    C = []
    D = []
    for _ in range(M):
        hoge = list(map(int, input().split()))
        C.append(hoge[0])
        D.append(hoge[1])

    for x in range(N):
        fuga = 10 ** 9
        c = 0
        for y in range(M):
            hoge = abs(A[x] - C[y]) + abs(B[x] - D[y])
            if hoge < fuga:
                fuga = hoge
                c = y + 1
        print(c)



if __name__ == "__main__":
    main()

Solution (Python):
INF = 10 ** 10

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

for i in range(n):
    mn = INF
    mi = -1
    for j in range(m):
        x = abs(a[i]-c[j]) + abs(b[i]-d[j])
        if x < mn:
            mn = x
            mi = j
    print(mi+1)

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

Seito = [tuple(map(int,input().split())) for i in range(N)]

Check = [tuple(map(int,input().split())) for i in range(M)]

for a,b in Seito:
	dist = [abs(a-c)+abs(b-d) for c,d in Check]
	print(dist.index(min(dist))+1)

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

for a, b in Ss:
    dist = [abs(a - c) + abs(b - d) for c, d in CPs]
    print(dist.index(min(dist)) + 1)

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

ans=[]
l= float("inf")
for a,b in A:
	l= float("inf")
	for i,c in enumerate(C):
		if l>abs(a-c[0])+abs(b-c[1]):
			l=abs(a-c[0])+abs(b-c[1])
			x=i+1
	else:
		ans.append(x)

for i in ans:
	print i

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

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

for i in students:
  dis = []
  for j in check:
    dis.append(abs(i[0] - j[0]) + abs(i[1] - j[1]))
  
  print(dis.index(min(dis)) + 1)

Solution (Python):
num = [int(x) for x in input().split()]

student = []
for i in range(0, num[0]):
    student.append([int(x) for x in input().split()])
checkpoint = []
for j in range(0, num[1]):
    checkpoint.append([int(x) for x in input().split()])


res = []
cnt = 0
for k in student:
    dis = float("inf")
    for l in checkpoint:
        if dis > abs(k[0]-l[0]) + abs(k[1]-l[1]):
            dis = abs(k[0]-l[0]) + abs(k[1]-l[1])
            cnt = checkpoint.index(l)
    res.append(cnt+1)


for m in res:
    print(m)

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

def length(x, y, x2, y2):
    return abs(x - x2) + abs(y - y2)

for i in range(n):
    num = -1
    min_ = float("inf")
    for j in range(m):
       tmp = length(an[i][0], an[i][1], cm[j][0], cm[j][1])
       if(tmp < min_):
           min_ = tmp
           num = j + 1
    print(num)

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

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

for a, b in students:
    tmp = [abs(a-x) + abs(b-y) for x, y in checkpts]
    print(tmp.index(min(tmp))+1)

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


def dist(p, q):
    return abs(p[0] - q[0]) + abs(p[1] - q[1])


for i in range(N):
    ans = 1e9
    anss = -1
    for j in range(M):
        if ans > dist(X[i], Y[j]):
            ans = dist(X[i], Y[j])
            anss = j + 1
    print(anss)

Solution (Python):




"""








"""
import math


def calc_distance(student_post, checkpoint_post):
    return int(math.fabs(student_post[0] - checkpoint_post[0]) + math.fabs(student_post[1] - checkpoint_post[1]))


if __name__ == '__main__':
    import doctest
    doctest.testmod()

    first = input()
    first = first.split(" ")
    data = [int(line) for line in first]

    student_num = data[0]
    checkpoint_num = data[1]

    student_pos_data = [[int(i) for i in input().split(" ")] for i in range(student_num)]
    checkpoint_data = [[int(i) for i in input().split(" ")] for i in range(checkpoint_num)]

    for each_student in student_pos_data:
        dis_list = [calc_distance(each_student, i) for i in checkpoint_data]
        print(dis_list.index(min(dis_list)) + 1)

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

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

st_cp=[]

for a, b in students:
  min_d=10000000000
  cp = 0
  for m, (c, d) in enumerate(checkpoints):
    dist = abs(a-c) + abs(b-d)
    if dist < min_d:
      min_d = dist
      cp = m+1
  st_cp.append(cp)

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

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

for i in range(n):
    ans = 1
    dis = abs(ab[i][0] - cd[0][0]) + abs(ab[i][1] - cd[0][1])
    for j in range(m):
        if dis > abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]):
            dis = 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())
pos = []
mini = [float('inf') for _ in range(N)]
ret = [-1 for _ in range(N)]
for _ in range(N):
    pos.append((tuple(map(int, input().split()))))

for j in range(M):
    c, d = map(int, input().split())
    for i, s in enumerate(pos):
        diff = abs(c - s[0]) + abs(d - s[1])
        if mini[i] > diff:
            ret[i] = j + 1
            mini[i] = diff

for r in ret:
    print(r)

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_)
for i in range(N):
    road_old  = float("inf")
    for n in range(M):
        road = abs(a[i] - c[n]) + abs(b[i] - d[n])
        if road < road_old:
            ans = n + 1
            road_old = road
    print(ans)

Solution (Python):
def solve():
    N, M = map(int, input().split())
    students = []
    points = []
    
    for _ in range(N):
        a, b = map(int, input().split())
        students.append([a, b])
        
    for _ in range(M):
        c, d = map(int, input().split())
        points.append([c, d])
    
    for [a, b] in students:
        md = []
        for [c, d] in points:
            md.append(abs(a-c) + abs(b-d))
        md_min = min(md)
        md_min_idx = md.index(md_min)
        print(md_min_idx + 1)

if __name__ == '__main__':
    solve()

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


def main():
    n, m = map(int, input().split())
    s_list = [list(map(int, input().split())) for _ in range(n)]
    c_list = [list(map(int, input().split())) for _ in range(m)]

    for s in s_list:
        minv = 1000000000
        for i, c in enumerate(c_list):
            tmp = man_dis(s, c)
            if tmp < minv:
                minv = tmp
                idx = i
        print(idx+1)
    

if __name__ == "__main__":
    main()

Solution (Python):
n,m=[int(x) for x in input().split()]
student=[]
checkpoint=[]
for i in [0]*n:
    student.append([int(x) for x in input().split()])
for i in [0]*m:
    checkpoint.append([int(x) for x in input().split()])
from math import fabs
for a,b in student:
    l=float("inf")
    for i,(c,d) in enumerate(checkpoint):
        kyori=fabs(a-c)+fabs(b-d)
        if l>kyori:
            ans=i+1
            l=kyori
    print(ans)

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


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

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

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

    for s in student:
        d = {}
        for i, c in enumerate(checkpoint):
            d[i] = manhattan_distance(s, c)
        print(sorted(d.items(), key=lambda x: x[1])[0][0]+1)
    


if __name__ == "__main__":
    main()

Solution (Python):

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

Solution (Python):
N,M=map(int,input().split())
man,pt=[],[]
def getter(freq,obj):
    for _ in range(freq):
        a,b=map(int,input().split())
        obj.append([a,b])
def solve():
    for tm in man:
        judg=[]
        for tp in pt:
            judg.append(abs(tm[0]-tp[0])+abs(tm[1]-tp[1]))
        print(judg.index(min(judg))+1)
def main():
    getter(N,man)
    getter(M,pt)
    solve()
if __name__ =='__main__':
    main()

Solution (Python):



import sys
import re
import math
import collections
import itertools
import functools

DEBUG = True
DEBUG = False

def dbg(*args):
    if DEBUG:
        print("DBG: ", file=sys.stderr, end="")
        print(*args, file=sys.stderr)

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

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

    for i, a in enumerate(A):
        argmin = 0
        dmin = dist(a, B[0])
        for j, b in enumerate(B):
            d = dist(a, b)
            if d < dmin:
                argmin = j
                dmin   = d
        print(argmin+1)

if __name__ == "__main__": main()

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

for i in range(n):
    a = input()
    nli.append(a)

for i in range(m):
    b = input()
    mli.append(b)

for i in range(n):
    mans = []
    for j in range(m):
        xns = mli[j]
        a, b = map(int, xns.split())
        yns = nli[i]
        c, d = map(int, yns.split())
        ans = abs(a-c) + abs(b-d)
        mans.append(ans)
    e = min(mans)
    print(mans.index(e)+1)

Solution (Python):
def distance(p1, p2):
  (x1, y1) = p1
  (x2, y2) = p2
  return abs(x1 - x2) + abs(y1 - y2)

N, M = map(int, input().split())
stu = [0]*N
point = [0]*M

for i in range(N):
  a, b = map(int, input().split())
  stu[i] = (a, b)
for i in range(M):
  a, b = map(int, input().split())
  point[i] = (a, b)

ans = [-1]*N  
for j, now in enumerate(stu):
  ans[j] = -1
  score = 1e18
  for i in range(M):
    pos = point[i]
    if distance(now, pos) < score:
      score = distance(now, pos)
      ans[j] = i+1

for e in ans:
  print(e)

Solution (Python):
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))

n, m = rli()
student = [[] for i in range(n)]
ans = [[-1,1145148101919] for i in range(n)]
for i in range(n):
    student[i] = rli()
for i in range(m):
    x, y = rli()
    for j in range(n):
        if(abs(x-student[j][0]) + abs(y-student[j][1]) < ans[j][1]):
            ans[j] = [i, abs(x-student[j][0]) + abs(y-student[j][1])]
for i in range(n):
    print(ans[i][0] + 1)

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

ab = []
cd = []

for _ in range(N):
    a, b = list(map(int, input().split(" ")))
    ab.append([a, b])
    
for _ in range(M):
    c, d = list(map(int, input().split(" ")))
    cd.append([c, d])

for i in range(N):
    best = 1e9
    best_idx = 0
    for j in range(M):
        manhattan = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if manhattan < best:
            best = manhattan
            best_idx = j
            
    print(best_idx+1)

Solution (Python):
from collections import defaultdict


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

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

    for s in students:
        ans = ""
        best = float("inf")
        for i, c in enumerate(checkpoints, start=1):
            if abs(s[0] - c[0]) + abs(s[1] - c[1]) < best:
                best = abs(s[0] - c[0]) + abs(s[1] - c[1])
                ans = i
        print(ans)

if __name__ == '__main__':
    main()