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



Sample input:
2 2
2 0
0 0
-1 0
1 0


Sample output:
2
1

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
listA = [list(map(int, list(input()))) for i in range(n)]
listB = [list(map(int, list(input()))) for j in range(m)]
listC=[]
for k in range(n):
  for l in range(m):
    listC.append(abs(listA[k][0]-listB[l][0])+abs(list[k][1]-listB[l][1]))
  listC.sort()
  print(listC[0])

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
o,p,q,r=[],[],[],[]
def kyori(a,b,c,d):return abs(a-b)+abs(c-d)
for i in range(n):
  a,b=map(int,input().split())
  o.append(a)
  p.append(b)
for i in range(m):
  a,b=map(int,input().split())
  q.append(a)
  r.append(b)
for i in range(n):
  mind=kyori(a[i],b[i],c[0],d[0])
  minn=1
  for j in range(m-1):
    a=kyori(a[i],b[i],c[j+1],d[j+1])
    if a<mind:
      mind=a
      minn=j+2
  print(minn)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
a_b=[list(map(int,input().split()) for _ in range(n)]
c_d=sorted([list(map(int,input().split()) for _ in range(m)])
for i in range(n):
  res=1
  d=abs(a_b[i][0]-c_d[0][0])+abs(a_b[i][1]-c_d[0][1])
  for j in range(m):
    t=abs(a_b[i][0]-c_d[j][0])+abs(a_b[i][1]-c_d[j][1])
    if t<d:
      d=t
      res=j+1
  print(res)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split(' '))
S = [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):
  l = [abs(S[i][0]-C[i][0])+abs(S[i][1]-C[i][1]) for i in range(M)]
  print(l.index(min(l))+1)

Submission status: Runtime Error

Solution code:
a,b = map(int, input().split())
x = []
m =19999999999999
for i in range(a):
    ta , tb = map(int, input().split()) 
    x.append([ta,tb])
for i in range(b):
    ta , tb = map(int, input().split()) 
    for x,y in x:
        m = min(m,abs(x-ta)+abs(y-tb))
    print(m)

Submission status: Runtime Error

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

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

for i in range(n):
    mini=10000000
    for j in range(m):
        dis=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if mini>dis:
            mini=dis
            point=j+1
    print(point)

Submission status: Runtime Error

Solution code:
n,m = map(int, input().split())
aa = [0] * m
bb = [0] * m
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())

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

Submission status: Runtime Error

Solution code:
n,m = map(int, input().split())
aa = [0] * m
bb = [0] * m
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())

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

Submission status: Runtime Error

Solution code:
n,m = map(int, input().split())
aa = [0] * m
bb = [0] * m
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())

distance = []
for i in range(n):
    d = []
    for j in range(m):
        d_ = abs(aa[i] - cc[j]) + abs(bb[i] - dd[j])
        d.append(d_)
        print('({}, {})  ({}, {}) :{}'.format(aa[i],bb[i],cc[j],dd[j], d_))
    distance.append(d)
for d in distance:
    print(d.index(min(d))+1)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
h=[]
p=[]
def man(a,c,b,d):
    s=abs(a-b)+abs(c-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
    print(l)

Submission status: Runtime Error

Solution code:
n,m=map(int,input())
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)

Submission status: Runtime Error

Solution code:
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(n)]

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

Submission status: Runtime Error

Solution code:
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(n)]

ans = [0]*n
for ab in AB:
    a,b = ab[0],ab[1]
    distance = 100000000
    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(_)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
for i in range(m):
    c,d = map(int,input().split())
    l = [0]*n
    for i in range(m):
        l[i] = abs(a[i][0]-c)+abs(a[i][1]-d)
    print(l.index(min(l))+1)

Submission status: Runtime Error

Solution code:
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))

Submission status: Runtime Error

Solution code:
def abc057_b():
    from math import inf
    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 = inf
        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()

Submission status: Runtime Error

Solution code:
N, M = [int(i) for i in input().split().strip()]
A = [[int(i) for i in input().split().strip()] for j in range(N)]
C = [[int(i) for i in input().split().strip()] for j in range(M)]

ls1 = []
for i in range(N):
    ls2 = []
    for j in range(M):
        ls2.append(abs(A[i][0] - C[j][0]) + abs(A[i][1] - C[j][1]))
    a = min(ls2)
    ls1.append(ls2.index(a))
for i in ls1:
    print(i)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
A = []
B = []
ans = 0
temp = 0
for i in range(n):
  x,y = map(int,input().split())
  A.append(x)
  B.append(y)
  for j in range(m):
    q,r = map(int,input().split())
    if m == 0:
      temp = abs(A[i] - q) + abs(B[i] - r)
      ans = 0
    elif abs(A[i] - q) + abs(B[i] - r) < temp:
      temp = abs(A[i] - q) + abs(B[i] - r)
      ans = j
  print(ans)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
A = []
B = []
ans = 0
temp = 0
for i in range(n):
  x,y = map(int,input().split())
  A.append(x)
  B.append(y)
  for j in range(m):
    x,y = map(int,input().split())
    if m == 0:
      temp = abs(A[i] - x) + abs(B[i] - y)
      ans = 0
    elif abs(A[i] - x) + abs(B[i] - y) < temp:
      temp = abs(A[i] - x) + abs(B[i] - y)
      ans = j
  print(ans)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
A = [], B = []
ans = 0
temp = 0
for i in range(n):
  x,y = map(int,input().split())
  A.append(x)
  B.append(y)
  for j in range(m):
    x,y = map(int,input().split())
    if m == 0:
      temp = abs(A[i] - x) + abs(B[i] - y)
      ans = 0
    elif abs(A[i] - x) + abs(B[i] - y) < temp:
      temp = abs(A[i] - x) + abs(B[i] - y)
      ans = j
  print(ans)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
A = [], B = []
ans = 0
temp = 0
for i in range(n):
  x,y = map(int,input().split())
  A.append(x)
  B.append(y)
  for j in range(m):
    x,y = map(int,input().split())
    if m == 0:
      temp = abs(A[i] - x) + abs(B[i] - y)
      ans = 0
    if abs(A[i] - x) + abs(B[i] - y) < temp:
      temp = abs(A[i] - x) + abs(B[i] - y)
      ans = j
  print(ans)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
A = [], B = []
ans = 0
temp = 0
for i in range(n):
  x,y = map(int,input().split())
  A.append(x)
  B.append(y)
  for j in range(m):
    x,y = map(int,input().split())
    if m = 0:
      temp = abs(A[i] - x) + abs(B[i] - y)
      ans = 0
    if abs(A[i] - x) + abs(B[i] - y) < temp:
      temp = abs(A[i] - x) + abs(B[i] - y)
      ans = j
  print(ans)

Submission status: Runtime Error

Solution code:
n,m = map(int,input())
A = [], B = []
ans = 0
temp = 0
for i in range(n):
  x,y = map(int,input().split())
  A.append(x)
  B.append(y)
  for j in range(m):
    x,y = map(int,input().split())
    if m = 0:
      temp = abs(A[i] - x) + abs(B[i] - y)
      ans = 0
    if abs(A[i] - x) + abs(B[i] - y) < temp:
      temp = abs(A[i] - x) + abs(B[i] - y)
      ans = j
  print(ans)

Submission status: Runtime Error

Solution code:
n,m = map(int,input())
A = [], B = []
ans = 0
temp = 0
for i in range(n):
  x,y = map(int,input().split())
  A.append(x)
  B.append(y)
  for j in range(m):
    x,y = map(int,input().split())
    if m = 0:
      temp = (abs(A[i] - x) + abs(B[i] - y))
      ans = 0
    if (abs(A[i] - x) + abs(B[i] - y)) < temp:
      ans = j
  print(ans)

Submission status: Runtime Error

Solution code:
# https://beta.atcoder.jp/contests/abc057/tasks/abc057_b


class Point(object):
    def __init__(self, x, y):
        self.x = int(x)
        self.y = int(y)

    @staticmethod
    def manhattan(p1, p2):
        return abs(p1.x - p2.x) + abs(p1.y - p2.y)

    def __str__(self):
        return f'(x, y) = ({self.x}, {self.y})'


def solve():
    # Max(n, m) = (50, 50) => 50 * 2
    n, m = map(int, input().split())
    students = []
    for _ in range(n):
        students.append(Point(*input().split()))

    checkpoints = []
    for _ in range(m):
        checkpoints.append(Point(*input().split()))

    for student in students:
        min_dist = 4 * (10 ** 8)
        min_index = 1
        for index, cp in enumerate(checkpoints):
            manhattan = Point.manhattan(student, cp)
            if min_dist > manhattan:
                min_dist = manhattan
                min_index = index + 1
        print(min_index)


if __name__ == '__main__':
    solve()

Submission status: Runtime Error

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

for s in students:
    min_distance = 2 * 10**8 + 1
    for i, c in enumerate(checkpoints):
        distance = abs(s[0] - c[0]) + abs(s[1]- c[1]) 
        if min_distance > distance:
            min_distance = distance
            point = i+1
    print(point)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
A = [(a, b) for a, b in map(int, input().split())]
C = [(c, d) for c, d in map(int, input().split())]
for i in range(n):
  res = 0
  ans = 1 << 20
  for j in range(m):
    tmp = abs(A[i][0] - C[j][0]) + abs(A[i][1] - C[j][1]) )
    if tmp < ans:
	  ans = tmp
      res = j
  print(j)

Submission status: Runtime Error

Solution code:
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())
    
D = [[0]*m]*n
for i in range(n):
    for j in range(m):
        D[i][j] = abs(a[i]-c[i])+abs(b[i]-d[i])

for i in range(n):
    print(D[i].index(min(D[i]))+1)

Submission status: Runtime Error

Solution code:
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())
    
D = [[0]*m]*n
for i in range(n):
    for j in range(m):
        D[i][j] = abs(a[i]-b[i])+abs(c[i]-d[i])

for i in range(n):
    print(D[i].index(min(D[i]))+1)

Submission status: Runtime Error

Solution code:
N, M =map(int, input().split())
a, b = [0]*N, [0]*N
c, d = [0]*N, [0]*N
ans = []
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):
    length = 10**9
    ind = 0
    for j in range(M):
        man =  abs(a[i] - c[j])+abs(b[i] - d[j])
        if length > man:
            length = man
            ind = j+1
    ans.append(ind)

for i in ans:
    print(i)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
S=[list(map(int,input().split())) for i in range(N)]
T=[list(map(int,input().split())) for i in range(M)]
for i in range(N):
    x1=S[i][0]
    y1=S[i][1]
    x2=T[0][0]
    y2=T[0][1]
    min=abs(x1-x2)+abs(y1-y2)
    x1=S[i][0]
    y1=S[i][1]
    for j in range(M-1,-1,-1):
        x2=T[j][0]
        y2=T[j][1]
        if min>=abs(x1-x2)+abs(y1-y2):
            min=abs(x1-x2)+abs(y1-y2)
            R[i]=j+1
for i in range(len(R)):
    print(R[i])

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
    mindis = 10 ** 9
    for j in range(m):
        dis = abs(s[i][0] - p[j][0]) + abs(s[i][1] - p[j][1])
        if mindis > dis:
            p = j+1
            mindis = dis
    print(p)

Submission status: Runtime Error

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

a = [0 for i in range(N)]
b = [0 for i in range(N)]
c = [0 for i in range(M)]
d = [0 for i in range(M)]

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

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

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

    print(dist.index(min(dist)))

Submission status: Runtime Error

Solution code:
#-*-coding:utf-8-*-

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

    ab_list = []
    cd_list = []
    for _ in range(n):
        ab_list.append(list(map(int, input().split())))
    for _ in range(m):
        cd_list.append(list(map(int, input().split())))
    

    for i in ab_list:
        min_distance = 2 * 10 ** 8
        for j in range(m):
            distance = abs(i[0] - cd_list[j][0]) + abs(i[1] - cd_list[j][1])
            if distance < min_distance:
                min_distance = distance
                min_coord = j + 1
        print(min_coord)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
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)]

min_distance_point = [None for i in range(m)]
for i, ab_i in enumerate(ab):
    a_i, b_i = ab_i
    min_distance_num = 10000
    min_distance = 100000000000
    for j, cd_i in enumerate(cd):
        c_i, d_i = cd_i
        distance = abs(a_i - c_i) + abs(b_i - d_i)
        if distance < min_distance:
            min_distance = distance
            min_distance_num = j+1
    min_distance_point[i] = min_distance_num
[print(x) for x in min_distance_point]

Submission status: Runtime Error

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

N_ab = []
M_cd = []

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

Submission status: Runtime Error

Solution code:
poop=input().split()
kpop=int(poop[0])
jpop=int(poop[1])
lop=[]
jop=[]
for i in range(kpop):
    lop.append(input().split())
for i in range(jpop):
    jop.append(input().split())
for i in range(kpop):
    k=999999999999999
    z=0
    for j in range(jpop):
        if k>abs(int(kpop[i][1])-int(jpop[j][1]))+abs(int(kpop[i][2])-int(jpop[j][2])):
            z=j
            k=abs(int(kpop[i][1])-int(jpop[j][1]))+abs(int(kpop[i][2])-int(jpop[j][2]))
    print(z)

Submission status: Runtime Error

Solution code:
N, M = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(N)]
cd = [list(map(int, input().split())) for i in range(N)]
for ab_i in ab:
    min_j = -1
    min_manh = float('inf')
    for j, cd_j in enumerate(cd):
        if min_manh > abs(ab_i[0]-cd_j[0])+abs(ab_i[1]-cd_j[1]):
            min_manh = abs(ab_i[0]-cd_j[0])+abs(ab_i[1]-cd_j[1])
            min_j = j+1
    print(min_j)

Submission status: Runtime Error

Solution code:
// header {{{
#include <bits/stdc++.h>
using namespace std;

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n, m;cin >> n >> m;
    vector<int> a(n), b(n), c(n), d(n);
    inc(i, 0, n) cin >> a[i] >> b[i];
    inc(i, 0, m) cin >> c[i] >> d[i];

    inc(i, 0, n){
        int min = INT_MAX;
        int ans = 0;
        inc(j, 0, m){
            if(abs(a[i]-c[j])+abs(b[i]-d[j]) < min){
                ans = j;
                min = abs(a[i]-c[j])+abs(b[i]-d[j]);
            }
        }
        cout << ans+1 << endl;
    }
    return 0;
}

Submission status: Runtime Error

Solution code:
N,M = (int(i) for i in input().split())

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

points = []
for i in range(M):
    c,d = (int(k) for k in input().split())
    points.append([a,b])
    
distance = []
kyori = []


for i in range(N):
    for j in range(1):
        kyori.append(abs(student[i][0]-points[j][0]) + abs(student[i][1]-points[j][1]))
    distance.append(min(kyori[j]))

for i in range(N):
    for j in range(1,M):
        kyori[j] = abs(student[i][0]-points[j][0]) + abs(student[i][1]-points[j][1])
    distance.append(min(kyori[j]))

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

Submission status: Runtime Error

Solution code:
#-*- coding:utf-8 -*-
a = list(map(int,input().split()))
num = 0
for i in range(a[0] + a[1]):
    num += 1
    list_{}.format(num) = []
    list_{}.format(num).append(list(map(int,input().split())))
    print(list_{}.format(num))

Submission status: Runtime Error

Solution code:
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 = 99999
    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
    print(check_point+1)

Submission status: Runtime Error

Solution code:
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 = 99999
    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)

Submission status: Runtime Error

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


for y in range(M):
    min_p = 999
    point = 1
    for x in range(M):
        distance = abs(int(ab[y][0]) - int(cd[x][0])) + abs(int(ab[y][1]) - int(cd[x][1]))
        if min_p == distance:
            continue
        elif min_p > distance:
            min_p = distance
            point += 1
    print(point)

Submission status: Runtime Error

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


for y in range(M):
    min_p = 999
    for x in range(M):
        distance = abs(int(ab[y][0]) - int(cd[x][0])) + abs(int(ab[y][1]) - int(cd[x][1]))
        if min_p == distance:
            continue
        elif min_p > distance:
            min_p = distance
            point = x + 1
    print(point)

Submission status: Runtime Error

Solution code:
import math;
N,M=map(int,input().split(" "));
ab=[];
for i in range(0,N):
 ab.append(input().split(" "));
cd=[];
for i in range(0,M):
 cd.append(input().split(" "));
for j in range(0, N):
 dist=9999999999999
 nearm=0;
for j in range(0, M):
 dist2 = math.fabs(int(ab[i][0]) - int(cd[j][0])) + math.fabs(int(ab[i][1]) - int(cd[j][1]));
 if dist2 < dist:
  dist = dist2;
  nearm=j;
  print(nearm+1);

Submission status: Runtime Error

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

def abs(n):
    return n if n>0 else -n


for i in range(1, n+1):
    ab = list(map(int, input().split(" ")))
for j in range(1, m+1):
    cd = list(map(int, input().split(" ")))

for i in range(0, n):
    delta = 999999999999
    ans=0
    for j in range(0, m):
        newdelta = abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1])
        if delta>newdelta:
            delta=newdelta
            ans=j+1
    print(ans)

Submission status: Runtime Error

Solution code:
n,m = list(map(int, input().split()))
a=[]
b=[]
c=[]
d=[]
y=0
for i in range(n):
    tmp=list(map(int, input().split()))
    a.append(tmp[0])
    b.append(tmp[1])
for i in range(m):
    tmp=list(map(int, input().split()))
    c.append(tmp[0])
    d.append(tmp[1])
x=[1000000000]*n
for i in range(n):
    for j in range(m):
        x[j]=abs(c[j]-a[i])+abs(d[j]-b[i])
        if x[y] > x[j]:
            y = j
    print(y+1)
    y=0

Submission status: Runtime Error

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

a = []
b = []

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

c = []
d = []

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

for i in range(n):
    tmp = abs(a[n] - c[0]) + abs(b[n] - d[0])
    s = 1
    for j in range(m):
        tmp3 = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if tmp3 < tmp:
            tmp = tmp3
            s = j + 1
    print(s)

Submission status: Runtime Error

Solution code:
N,M = list(map(int, input().split()))
a = [0]*N
b = [0]*N
c = [0]*M
d = [0]*M
for k in range(N):
     a[k],b[k] = list(map(int, input().split()))
for l in range(M):
     c[l],d[l] = list(map(int, input().split()))

for i in range(N):
    s=10**8+1
    for j in range(M):
        if  s>abs(a[i]-c[j])+abs(b[i]-d[j]):
             s=abs(a[i]-c[j])+abs(b[i]-d[j])
             e=j+1
    print(e)

Submission status: Runtime Error

Solution code:
N,M = list(map(int, input().split()))
a = [0]*N
b = [0]*N
c = [0]*M
d = [0]*M
for k in range(N):
     a[k],b[k] = list(map(int, input().split()))
for l in range(M):
     c[l],d[l] = list(map(int, input().split()))

for i in range(N):
    s=10**8
    for j in range(M):
        if  s>abs(a[i]-c[j])+abs(b[i]-d[j]):
             s=abs(a[i]-c[j])+abs(b[i]-d[j])
             e=j+1
    print(e)

Submission status: Runtime Error

Solution code:
n, m = map(int, raw_input().split())
P = [map(int, raw_input().split()) for i in xrange(n)]
C = [map(int, raw_input().split()) for i in xrange(n)]
for a, b in P:
    idx = -1; mi = ()
    for i, (c, d) in enumerate(C):
        di = abs(a-c) + abs(b-d)
        if di < mi:
            mi = di
            idx = i
    print idx+1

Submission status: Runtime Error

Solution code:
a = list(map(int,input().split(" ")))
b = list()
c = list()
ans = list()

for i in range(a[0]):
    b.append(list(map(int,input().split(" "))))

for i in range(a[1]):
    c.append(list(map(int,input().split(" "))))

for i in range(a[0]):
    d = 0
    e = 99999999
    for ii in range(a[1]):
        if e > abs(b[i][0] - c[ii][0]) + abs(b[i][1] - c[ii][1]):
            e = abs(b[i][0] - c[ii][0]) + abs(b[i][1] - c[ii][1]):
            d = ii
    ans.append(d)
    
for i in range(a[0]):
    print(ans[i])

Submission status: Runtime Error

Solution code:
A = list(map(int,input().split(" ")))
H = list()
C = list()
result = list()
for i in range(A[0]):
    H.append(list(map(int,input().split(" "))))
for i in range(A[1]):
    C.append(list(map(int,input().split(" "))))

for i in range(A[0]):
    res = 0
    tmp = 99999999
    for ii in range(A[1]):
        if tmp > abs(H[i][0] - C[ii][0]) + abs(H[i][1] - C[ii][1]):
            res = ii
    result.append(res)

for i in range(A[1]):
    print(result[i])

Submission status: Runtime Error

Solution code:
A = list(map(int,input().split(" ")))
H = list()
C = list()
result = list()
for i in range(A[0]):
    H.append(list(map(int,input().split(" "))))
for i in range(A[1]):
    C.append(list(map(int,input().split(" "))))
    
for i in range(A[0]):
    res = 0
    tmp = 99999999
    for ii in range(A[1]):
        if tmp > abs(H[i*2-1] - C[i*2-1]) + abs(H[i*2] - C[i*2]):
            res = ii
    result.append(res)

for i in range(A[1]):
    print(result[i])

Submission status: Runtime Error

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

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

for i in range(N):
    argMin, distMin = None, float('inf')
    for j in range(M):
        dist = abs(nodes[i][0] - checks[j][0]) + abs(nodes[i][1] - checks[j][1])
        if dist < distMin: argMin, distMin = j, dist
    print(j)

Submission status: Runtime Error

Solution code:
N,M = list(map(int, input().split()))
 
s = [list(map(int,input().split())) for i in range(n)]
c = [list(map(int,input().split())) for j in range(n)]
 
for t1 in s:
    l = list(map(lambda x: abs(t1[0] - x[0]) + abs(t1[1] - x[1]), c))
    print(l.index(min(l)) + 1)

Submission status: Runtime Error

Solution code:
N, M = list(map(int, input().split()))
students = list()
checkpoints = list()

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

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

ans = [0] * N

for i in range(N):
	mindif = 4 * 10**8 + 1
	for j in range(M):
		dif = abs(students[i][0] - checkpoints[j][0]) + abs(students[i][1] - checkpoints[j][1])
		if dif < mindif:
			mindif = dif
			ans[i] = j

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

N, M = map(int, raw_input().split())
ab = [map(int, raw_input().split()) for i in xrange(N)]
cd = [map(int, raw_input().split()) for i in xrange(N)]

for i, (a, b) in enumerate(ab):
    mn = 1e10
    p = -1
    for j, (c, d) in enumerate(cd, 1):
        tmp = abs(a - c) + abs(c - d)
        if tmp < mn:
            mn = tmp
            p = j
    print p