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):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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)]
inf = float('inf')
for a, b in ab:
    cnt = inf
    ans = 0
    for i in range(m):
        v = abs(a - cd[i][0]) + abs(b - cd[i][1])
        if cnt > v:
            cnt = v
            ans = i + 1
    print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
N, M = map(int, input().split())

A = [tuple(map(int, input().split())) for _ in [0]*N]
C = [tuple(map(int, input().split())) for _ in [0]*M]


for a, b in A:
    mind = 10**10
    mini = -1
    for i, (c, d) in enumerate(C):
        if mind > abs(c-a)+abs(d-b):
            mind = abs(c-a)+abs(d-b)
            mini = i
    print(mini+1)

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

for _ in range(n):
    ans=9e9
    ret=0
    a=ab[_][0]
    b=ab[_][1]
    for i,j in enumerate(cd):
        c=j[0]
        d=j[1]
        man=abs(a-c)+abs(b-d)
        if man<ans:
            ans=man
            ret=i+1
    print(ret)

Solution (Python):
import math

INF = 1001001001

def resolve():
  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 in s:
    ans = 0
    dist = INF
    for i in range(m):
      if abs(a[0] - c[i][0]) + abs(a[1] - c[i][1]) < dist:
        dist = abs(a[0] - c[i][0]) + abs(a[1] - c[i][1])
        ans = i+1
    print(ans)
  return

if __name__ == "__main__":
  resolve()

Solution (Python):
import numpy as np
N,M=map(int, input().split())
human=[]
for i in range(N):
  a,b=map(int, input().split())
  human.append((a,b))
C=[]
for i in range(M):
  c,d=map(int, input().split())
  C.append((c,d))
  
for h in human:
  a,b=h
  now=0
  mini=np.inf
  for i,ch in enumerate(C):
    c,d=ch
    L=abs(a-c)+abs(b-d)
    if mini>L:
      mini=L
      now=i+1
  print(now)

Solution (Python):

import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,m = map(int,input().split())
CD = [tuple(map(int,input().split())) for i in range(n)]
AB = [tuple(map(int,input().split())) for i in range(m)]
for c,d in CD:
  print(min(range(m),key = lambda x:abs(AB[x][0]-c) + abs(AB[x][1]-d))+1)

Solution (Python):
N,M = map(int,input().split())
ls1 = []
ls2 = []
for i in range(N):
  ls1.append(list(map(int,input().split())))
for i in range(M):
  ls2.append(list(map(int,input().split())))
for i in range(N):
  minimum = 10**18
  check = 0
  for j in range(M):
    K = abs(ls1[i][0]-ls2[j][0])+abs(ls1[i][1]-ls2[j][1])
    if K < minimum:
      minimum = K
      check = j
  print(check+1)

Solution (Python):
def resolve():
    n, m = map(int, input().split())
    s = [list(map(int, input().split())) for _ in range(n)]
    c = [list(map(int, input().split())) for _ in range(m)]

    for i in range(n):
        mdis = float("inf")
        goal = -1
        x, y = s[i][0], s[i][1]
        for j in range(m):
            cx, cy = c[j][0], c[j][1]
            dis = abs(x-cx)+abs(y-cy)
            if mdis > dis:
                mdis = dis
                goal = j+1
        print(goal)
resolve()

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

Solution (Python):
def main():
    n, m = map(int, input().split())
    student = []
    for _ in range(n):
        student.append([int(x) for x in input().split()])
    check_point = []
    for _ in range(m):
        check_point.append([int(x) for x in input().split()])
    answer = ["0" for _ in range(n)]
    for i in range(n):
        now_ans = 0
        now_dist = float("inf")
        for j in range(m):
            dist = abs(student[i][0] - check_point[j][0]) + abs(student[i][1] - check_point[j][1])
            if dist < now_dist:
                now_ans = j + 1
                now_dist = dist
        answer[i] = str(now_ans)
    print("\n".join(answer))


if __name__ == '__main__':
    main()

Solution (Python):
n,m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]
for x,y in a:
    c = float("inf")
    for j in range(m):
        if c > abs(x-b[j][0])+abs(y-b[j][1]):
            c = abs(x-b[j][0])+abs(y-b[j][1])
            ans = j+1
    print(ans)

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

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

for i in g:
    a,b=i[0],i[1]
    dis=10**10
    ind=1
    for j in range(m):
        x,y=c[j][0],c[j][1]
        now=abs(a-x)+abs(b-y)
        if now<dis:
            dis=now
            ind=j+1
    print(ind)

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

students = []
checkpoints = []

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

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

for i, j in students:
    min_dist = 10**10
    point = -1
    for x in range(m):
        dist = abs(checkpoints[x][0] - i) + abs(checkpoints[x][1] - j)
        if dist < min_dist:
            min_dist = dist
            point = x + 1
    print(point)

Solution (Python):
[n,m] = [int(i) for i in input().split()]
ls_st = []
ls_ch = []
for j in range(n):
    ls_st.append([int(i) for i in input().split()])
for j in range(m):
    ls_ch.append([int(i) for i in input().split()])
ans = []
for i in range(n):
    dist = 10**20;
    place = -1
    for j in range(m):
        if dist > (abs(ls_st[i][0] - ls_ch[j][0])+abs(ls_st[i][1] - ls_ch[j][1])):
            dist = (abs(ls_st[i][0] - ls_ch[j][0])+abs(ls_st[i][1] - ls_ch[j][1]))
            place = j+1
    ans.append(place)
for i in range(n):
    print(ans[i])

Solution (Python):
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, m = na()
ab = nan(n)
cd = nan(m)

ans = [0] * n
for i in range(n):
    a, b = ab[i]
    cur = inf
    p = -1
    for j in range(m):
        c, d = cd[j]
        dist = abs(a - c) + abs(b - d)
        if dist < cur:
            cur = dist
            p = j + 1
    ans[i] = p

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

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

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

Solution (Python):
import sys
from collections import deque
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()
ab = [IL() for i in range(N)]
cd = [IL() for i in range(M)]

for a,b in ab:
  ans = ""
  num = MAX_INT
  for i in range(M):
    tmp = abs(a-cd[i][0]) + abs(b-cd[i][1])
    if tmp < num:
      ans = i+1
      num = tmp
  print(ans)

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

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

print(*(c for _,c in (min((abs(x0-x1)+abs(y0-y1),i+1)  for i,(x0,y0) in enumerate(checks)) for x1,y1 in students)), sep='\n')

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

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

for a,b in abl:
    ans = float("inf")
    log = -1
    for idx, (c,d) in enumerate(cdl):
        tmp = abs(a-c) + abs(b-d)
        if ans > tmp:
            ans = tmp
            log = idx+1
    print(log)

Solution (Python):
def dist(a, b, c, d):
    return abs(a-c) + abs(b-d)

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):
    res = 10**10
    for j in range(M):
        if dist(ab[i][0], ab[i][1], cd[j][0], cd[j][1]) < res:
            res = dist(ab[i][0], ab[i][1], cd[j][0], cd[j][1])
            ans = j+1
    print(ans)

Solution (Python):







from itertools import product,permutations,combinations,combinations_with_replacement






mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def readInt():
    return list(map(int,input().split()))

def main():
    n,m = readInt()
    a = []
    b = []
    for i in range(n):
        x,y = readInt()
        a.append(x)
        b.append(y)
    c = []
    d = []
    for j in range(m):
        x,y = readInt()
        c.append(x)
        d.append(y)
    for i in range(n):
        length = INF
        ans = 0
        for j in range(m):
            if length>abs(a[i]-c[j])+abs(b[i]-d[j]):
                length = abs(a[i]-c[j]) + abs(b[i]-d[j])
                ans = j
        print(ans+1)
    return

if __name__=='__main__':
    main()

Solution (Python):
import sys
def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    S = [[int(a) for a in input().split()] for _ in range(N)]
    C = [[int(c) for c in input().split()] for _ in range(M)]
    for a, b in S:
        minDist = 10 ** 20
        minPoint = 0
        for i in range(M):
            if abs(a - C[i][0]) + abs(b - C[i][1]) < minDist:
                minDist = abs(a - C[i][0]) + abs(b - C[i][1])
                minPoint = i + 1
        print(minPoint)

    return 0

if __name__ == "__main__":
    solve()

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

Solution (Python):
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
a = []
for _ in range(N):
  x, y = map(int, input().split())
  a.append((x, y))
b = []
for _ in range(M):
  x, y = map(int, input().split())
  b.append((x, y))

for x, y in a:
  res = 0
  for i in range(M):
    if abs(x - b[i][0]) + abs(y - b[i][1]) < abs(x - b[res][0]) + abs(y - b[res][1]):
      res = i
  print(res + 1)

Solution (Python):
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, M = (int(i) for i in input().split())
    AB = [[int(i) for i in input().split()] for j in range(N)]
    CD = [[int(i) for i in input().split()] for j in range(M)]
    for a, b in AB:
        mi = 10**20
        ans = -1
        for i, p in enumerate(CD):
            d = abs(p[0] - a) + abs(p[1] - b)
            if d < mi:
                mi = d
                ans = i+1
        print(ans)


if __name__ == '__main__':
    main()

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

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

Solution (Python):
n,m=map(int,input().split())
a,b,c,d=[],[],[],[]
for _ in range(n):
    a_,b_=map(int,input().split())
    a.append(a_)
    b.append(b_)
for _ in range(m):
    c_,d_=map(int,input().split())
    c.append(c_)
    d.append(d_)

def mh(x,y,w,z):
    return abs(x-w)+abs(y-z)

for i in range(n):
    min_mh=mh(a[i],b[i],c[0],d[0])
    ansi=1
    for j in range(1,m):
        if min_mh > mh(a[i],b[i],c[j],d[j]):
            min_mh=mh(a[i],b[i],c[j],d[j])
            ansi=j+1
    print(ansi)

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


for person in ab:
    x, y = person
    m = 10 ** 9
    togo = 0
    for i, checkpoint in enumerate(cd):
        cx, cy = checkpoint
        dist = abs(x - cx) + abs(y - cy)
        if dist < m:
            m = dist
            togo = i
            
    print(togo + 1)

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

for a, b in S:
    ans = 0
    dmin = float('inf')
    for i, (c, d) in enumerate(C):
        d = abs(a - c) + abs(b - d)
        if d < dmin:
            ans = i + 1
            dmin = 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)]
ans = []
for i in range(n):
  p = 10 ** 9
  q = 1
  a, b = ab[i]
  for j in range(m):
    c, d = cd[j]
    tmp = abs(a-c) + abs(b-d)
    if tmp < p:
      p = tmp
      q = j + 1
  ans.append(q)
for p in ans:
  print(p)

Solution (Python):
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 (a, b) in students:
    best = 1e9
    ans = -1
    for i, (c, d) in enumerate(checkpoints):
        res = abs(a - c) + abs(b - d)
        if (best > res):
            best = res
            ans = i + 1
    print(ans)

Solution (Python):
N, M = map(int, input().split())
stu = []
check = []
for i in range(N):
    s = list(map(int, input().split()))
    stu.append(s)
for i in range(M):
    c = list(map(int, input().split()))
    check.append(c)
ans = [0 for i in range(N)]
for i in range(N):
    min = 10**20
    for j in range(M):
        dis = abs(stu[i][0]-check[j][0])+abs(stu[i][1]-check[j][1])
        if min > dis:
            min = dis
            ans[i] = j+1
for i in ans:
    print(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)

for i in range(N):
    m = 10**17
    for j in range(M):
        distance = abs(A[i]-C[j]) + abs(B[i]-D[j])
        if distance < m:
            m = distance
            ans = j+1

    print(ans)

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

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

person = []
point= []

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

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

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

Solution (Python):
N,M = map(int,input().split())
 
def dist(ab,cd):
  return abs(ab[0]-cd[0]) + abs(ab[1]-cd[1])
 
AB = [[int(x) for x in input().split()] for _ in range(N)]
CD = [[int(x) for x in input().split()] for _ in range(M)]
 
answer = []
for ab in AB:
  min_dist = 10**15
  target = 0
  for j,cd in enumerate(CD,1):
    x = dist(ab,cd)
    if min_dist > x:
      min_dist = x
      target = j
  answer.append(target)
 
print(*answer, sep='\n')

Solution (Python):

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

person = []
point= []

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

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

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

Solution (Python):
def main():
    N, M = map(int, input().split())
    students = [input().split() for _ in range(N)]
    checkpoints = [input().split() for _ in range(M) ]
    nearest = [None]*N

    for i, s in enumerate(students) :
        min_d = 10**9

        for j, p in enumerate(checkpoints, 1) :
            a, b = map(int, s)
            c, d = map(int, p)
            d = abs(a - c) + abs(b - d)

            if min_d > d:
                min_d = d
                nearest[i] = j

    for i in range(N):
        print(nearest[i])   
main()

Solution (Python):
def main():
    N, M = map(int, input().split())
    students = [input().split() for _ in range(N)]
    checkpoints = [input().split() for _ in range(M) ]
    nearest = [None]*N

    for i, s in enumerate(students) :
        min_d = 10**9
        index = 0

        for j, p in enumerate(checkpoints, 1) :
            a, b = map(int, s)
            c, d = map(int, p)
            d = abs(a - c) + abs(b - d)

            if min_d > d:
                min_d = d
                index = j

        nearest[i] = index

    for i in range(N):
        print(nearest[i])   
main()

Solution (Python):
def main():
    N, M = map(int, input().split())
    students = [input().split() for _ in range(N)]
    checkpoints = [input().split() for _ in range(M) ]
    nearest = [None]*N

    for i, s in enumerate(students) :
        min_d = 10**9

        for j, p in enumerate(checkpoints, 1) :
            a, b = map(int, s)
            c, d = map(int, p)
            d = abs(a - c) + abs(b - d)

            if min_d > d:
                min_d = d
                nearest[i] = j

    for i in range(N):
        print(nearest[i]) 
main()

Solution (Python):
def main():
    N, M = map(int, input().split())
    students = [input().split() for _ in range(N)]
    checkpoints = [input().split() for _ in range(M) ]
    nearest = [None]*N

    for i, s in enumerate(students) :
        min_d = 10**9
        index = 0

        for j, p in enumerate(checkpoints, 1) :
            a, b = map(int, s)
            c, d = map(int, p)
            d = abs(a - c) + abs(b - d)

            if min_d > d:
                min_d = d
                index = j

        nearest[i] = index

    for i in range(N):
        print(nearest[i])   
main()

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

Solution (Python):
N,M = map(int,input().split())
a = [list(map(int,input().split())) for i in range(N)]
c = [list(map(int,input().split())) for i in range(M)]
for i in range(N):
    ans = 0
    now = 10**10
    for j in reversed(range(M)):
        if abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1])<=now:
            ans = j+1
            now = abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1])
    print(ans)

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

def mah(p1, p2):
    return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])

sci = []

for i in range(N):
    mindis = 0
    minind = 0
    for j in range(M):
        m = mah(sp[i], cp[j])
        if j == 0 or mindis > m:
            mindis = m
            minind = j
    sci.append(minind+1)

print('\n'.join(map(str, sci)))

Solution (Python):
(n, _), *d = [list(map(int, s.split())) for s in open(0)]
for i, j in d[:n]:
    l = [abs(x - i) + abs(y - j) for x, y in d[n:]]
    print(l.index(min(l)) + 1)

Solution (Python):
n, m = map(int, input().split())
st = [list(map(int, input().split())) for i in range(n)]
cp = [list(map(int, input().split())) for i in range(m)]
for s in st:
  ans = -1
  dmin = 10**9
  for i, c in enumerate(cp):
    dist = abs(c[0] - s[0]) + abs(c[1] - s[1])
    if dist < dmin:
      dmin = dist
      ans = i + 1
  print(ans)

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

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

for i in range(N):
  min_dist = float("inf")
  ans = -1
  for j in range(M):
    dist = abs(a[i] - c[j]) + abs(b[i] - d[j])
    if dist < min_dist:
      min_dist = dist
      ans = j + 1
    elif dist == min_dist:
      ans = min(ans, j + 1)
  print(ans)

Solution (Python):
N,M = map(int,input().split())
ab = []
for i in range(N):
    a,b = list(map(int,input().split()))
    a -= 1
    b -= 1
    ab.append([a,b])
cd = []
for i in range(M):
    c,d = list(map(int,input().split()))
    c -= 1
    d -= 1
    cd.append([c,d])
ans = []
for a,b in ab:
    dis = float('inf')
    for i in range(M):
        if dis > abs(cd[i][0]-a)+abs(cd[i][1]-b):
            dis = abs(cd[i][0]-a)+abs(cd[i][1]-b)
            ind = i
    ans.append(ind)
for i in ans:
    print(i+1)

Solution (Python):

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

for i in range(n):
    distances = [abs(studentPoints[i][0] - checkPoints[k][0]) + abs(studentPoints[i][1] - checkPoints[k][1]) for k in range(m)]
    print(distances.index(min(distances)) + 1)

Solution (Python):

studentPoints = []
checkPoints = []
n, m = map(int, input().split())
for _ in range(n):
    studentPoints.append([int(s) for s in input().split()])
for _ in range(m):
    checkPoints.append([int(s) for s in input().split()])

for i in range(n):
    distances = [abs(studentPoints[i][0] - checkPoints[k][0]) + abs(studentPoints[i][1] - checkPoints[k][1]) for k in range(m)]
    print(distances.index(min(distances)) + 1)

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

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

ans_distance = [float('inf')] * N
ans = [float('inf')] * N
for i in range(N):
    for j in range(M):
        
        if ans_distance[i] > distance(ab[i][0], cd[j][0], ab[i][1], cd[j][1]):
            ans_distance[i] = distance(ab[i][0], cd[j][0], ab[i][1], cd[j][1])
            ans[i] = j+1

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

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

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

Solution (Python):

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

for i in range(N):
    mn = []
    x1 = nlst[i][0]
    y1 = nlst[i][1]
    for j in range(M):
        x2 = mlst[j][0]
        y2 = mlst[j][1]

        dis = abs(x1-x2) + abs(y1-y2)
        mn.append(dis)
    minn = min(mn)
    print(mn.index(minn)+1)

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

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

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



for i in range(len(ab)):
  x = [10000000000000000, 1000]
  for j in range(len(cd)):
    if x[0] > abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]):
      x[0] = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
      x[1] = j

  print(x[1] + 1)

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


ans=[]
for i in st:
    for k in cheak:
        res=abs(i[0]-k[0])+abs(i[1]-k[1])
        ans.append(res)
    x=min(ans)
    print(ans.index(x)+1)
    ans.clear()

Solution (Python):
n, m = map(int,input().split())
people = []
points = []
for i in range(n):
  person = list(map(int,input().split()))
  people.append(person)
for i in range(m):
  point = list(map(int,input().split()))
  points.append(point)

for person in people:
  mini = 1000000000
  minIndex = 0
  for i in range(m):
    distance = abs(person[0]-points[i][0]) + abs(person[1]-points[i][1])
    
    if mini > distance:
      mini = distance
      minIndex = i
  print(minIndex+1)

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

G,C = [],[]

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

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

ans_L = []
for i in range(n):
    ans = float("inf")
    a,b = G[i]
    idx = 0
    for j in range(m):
        c,d = C[j]
        ten = abs(a-c) + abs(b-d)
        if ans != min(ans,ten):
            ans = ten
            idx = j+1

    ans_L.append(idx)

for i in ans_L:
    print(i)

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

for i in range(N):
  a = int(SP[i][0])
  b = int(SP[i][1])
  k = 0
  md = abs(int(CP[0][0])-a)+abs(int(CP[0][1])-b)
  for j in range(M):
    x = abs(int(CP[j][0])-a)+abs(int(CP[j][1])-b)
    if x < md:
      md = x
      k = j
  print(k+1)

Solution (Python):
INF=1000000007
N,M=map(int,input().split())
A=[]
B=[]
for i in range(N):
  a,b=list(map(int,input().split()))
  A.append([a,b])
for i in range(M):
  c,d=list(map(int,input().split()))
  B.append([c,d])
for i in A:
  m=INF
  p=0
  for j in range(M):
    d=abs(i[0]-B[j][0])+abs(i[1]-B[j][1])
    if m>d:
      m=d
      p=j+1
  print(p)

Solution (Python):

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

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

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

for i in range(n): 
    for j in range(m): 
        dist = abs(students[i][0]-points[j][0]) + abs(students[i][1]-points[j][1])
        if j < 1:
            min_dist = dist
            min_id = j + 1
        else:
            if min_dist > dist:
                min_dist = dist
                min_id = j + 1
    print(int(min_id))

Solution (Python):
N, M = map(int, input().split())
students = []
checkpoints = []
INF = 10**19

for _ in range(N):
    ai, bi = map(int, input().split())
    students.append((ai, bi))

for _ in range(M):
    ci, di = map(int, input().split())
    checkpoints.append((ci, di))

for item in students:
    tmp = INF
    ans = INF, INF
    for i in range(M):
        manhattan = abs(item[0] - checkpoints[i][0]) + abs(item[1] - checkpoints[i][1])
        if tmp > manhattan:
            tmp = manhattan
            ans = i+1
    print(ans)

Solution (Python):
def dis(j,i):
    return abs(c[j]-a[i])+abs(d[j]-b[i])

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

close = 0
for i in range(n):
    for j in range(m-1):
        if dis(j+1,i) < dis(close, i):
            close = j+1
    print(close+1)
    close = 0

Solution (Python):
n, m = map(int, input().split())
np = list()
for _ in range(n):
    np.append(list(map(int, input().split())))
mp = list()
for _ in range(m):
    mp.append(list(map(int, input().split())))

for N in np:
    tmp = list()
    for M in mp:
        tmp.append([abs(N[0]-M[0])+abs(N[1]-M[1]), mp.index(M)+1])

    tmp.sort()
    print(tmp[0][1])

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

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

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

for i in range(N):
    saitei = float("inf")
    ans = 0
    for j in range(M):
        if abs(A[i][0]-B[j][0]) + abs(A[i][1]-B[j][1]) < saitei:
            saitei = abs(A[i][0]-B[j][0]) + abs(A[i][1]-B[j][1])
            ans = j+1   
    print(ans)

Solution (Python):
import numpy as np
from scipy.spatial.distance import minkowski

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

for i in range(n):
    c = np.array([minkowski(a[i], j , 1) for j in b], dtype=np.int64)
    ans = np.argmin(c) + 1
    print(ans)