qyliang/CodeNanoFix huggingface dataset:
Buggy 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)]
for i in ab:
    l = []
    for j in cd:
        l.append(abs((j[0] - i[0]) + (j[1] - i[1])))
    print(l.index(min(l)) + 1)

Fixed code:
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 ab:
    ans = []
    for j in cd:
        ans.append(abs(i[0] - j[0]) + abs(i[1] - j[1]))
    print(ans.index(min(ans))+1)
Buggy code:
# -*- coding: utf-8 -*-


def solve(s_pp, p_pp):
    p_nums = []
    for x, y in s_pp:
        distance = []
        for xx, yy in p_pp:
            n = abs(x, xx) + abs(y, yy)
            distance.append(n)
        p_nums.append(min(distance))
    return p_nums


def main():
    students, points = [int(e) for e in input().split()]
    students_ps = []
    points_ps = []

    for _ in range(students):
        x, y = [int(e) for e in input().split()]
        students_ps.append([x, y])
    for _ in range(points):
        x, y = [int(e) for e in input().split()]
        points_ps.append([x, y])
    
    for answer in solve(students_ps, points_ps):
        print(answer)


main()


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


def solve(s_pp, p_pp):
    p_nums = []
    for x, y in s_pp:
        distance = []
        for xx, yy in p_pp:
            n = abs(x - xx) + abs(y - yy)
            distance.append(n)
        min_distance_idx = distance.index(min(distance))
        p_nums.append(min_distance_idx + 1)
    return p_nums


def main():
    students, points = [int(e) for e in input().split()]
    students_ps = []
    points_ps = []

    for _ in range(students):
        x, y = [int(e) for e in input().split()]
        students_ps.append([x, y])
    for _ in range(points):
        x, y = [int(e) for e in input().split()]
        points_ps.append([x, y])
    
    for answer in solve(students_ps, points_ps):
        print(answer)


main()
Buggy code:
N, M = map(int, input().split())
man = [[int(x) for x in input().split()] for _ in range(N)]
check = [[int(x) for x in input().split()] for _ in range(M)]

for a, b in man:
    tmp = 1000000000
    ans = 1
    for i, (c, d) in enumerate(check):
        if tmp > (abs(a-c) + abs(b-d)):
            tmp = min(tmp, abs(a-c) + abs(b-d))
    print(ans)

Fixed code:
N, M = map(int, input().split())
man = [[int(x) for x in input().split()] for _ in range(N)]
check = [[int(x) for x in input().split()] for _ in range(M)]

for a, b in man:
    tmp = 1000000000
    ans = 1
    for i, (c, d) in enumerate(check):
        if tmp > (abs(a-c) + abs(b-d)):
            tmp = min(tmp, abs(a-c) + abs(b-d))
            ans = i+1
    print(ans)
Buggy code:
n,m=map(int,input().split())
pos1=[list(map(int,input().split())) for _ in range(n)]
pos2=[list(map(int,input().split())) for _ in range(m)]
ans=[0]*n
for i in range(n):
  lim=10**9
  for j in range(m):
    tmp=abs(pos1[i][0]-pos2[i][0])+abs(pos1[i][1]-pos2[i][1])
    if tmp<lim:
      tmp=lim
      ans[i]=j
for i in range(n):
  print(ans[i])

Fixed code:
n,m=map(int,input().split())
pos1=[list(map(int,input().split())) for _ in range(n)]
pos2=[list(map(int,input().split())) for _ in range(m)]
ans=[0]*n
for i in range(n):
  lim=10**9
  for j in range(m):
    tmp=abs(pos1[i][0]-pos2[j][0])+abs(pos1[i][1]-pos2[j][1])
    if tmp<lim:
      lim=tmp
      ans[i]=j+1
for i in range(n):
  print(ans[i])
Buggy code:
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)]
def d(x,y):
    return abs(x[0]-y[0])+abs(x[1]+y[1])
for i in a:
    ans=10101001010
    ch=0
    for j in range(m):
        if d(i,c[j])<ans:
            ch=j
            ans=d(i,c[j])
    print(ch+1)

Fixed code:
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)]
def d(x,y):
    return abs(x[0]-y[0])+abs(x[1]-y[1])
for i in a:
    ans=10101001010
    ch=0
    for j in range(m):
        if d(i,c[j])<ans:
            ch=j
            ans=d(i,c[j])
    print(ch+1)
Buggy code:
N, M = map(int, input().split())

students = []
for i in range(N):
    students.append(input().split())

checkpoints = []
for i in range(M):
    checkpoints.append(input().split())

for x1, y1 in students:
    result = 999999999
    index = 1
    for x2, y2 in checkpoints:
        val = abs(int(x1) - int(x2)) + abs(int(y1) - int(y2))
        if result > val:
            ans = index
        result = val
        index += 1
    print(ans)

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

students = []
for i in range(N):
    students.append(input().split())

checkpoints = []
for i in range(M):
    checkpoints.append(input().split())

for x1, y1 in students:
    result = 99999999999
    index = 1
    for x2, y2 in checkpoints:
        val = abs(int(x1) - int(x2)) + abs(int(y1) - int(y2))
        if result > val:
            ans = index
            result = val
        index += 1
    print(ans)
Buggy 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)))

Fixed 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):
    dist = []

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

    print(dist.index(min(dist)) + 1)
Buggy code:
N,M = map(int,input().split())
gakusei = []
for i in range(N):
    a,b = map(int,input().split())
    gakusei.append((a,b))
check = []
for i in range(1,M+1):
    c,d = map(int,input().split())
    check.append((c,d))
for i in range(N):
    a,b = gakusei[i]
    z = 10**9
    m = 0
    for j in range(1,M+1):
        c,d = check[j-1]
        x = max(a-c,c-a) + max(b-d,d-b)
        if x < z:
            m = j
            z = x
    print(z)
        

Fixed code:
N,M = map(int,input().split())
gakusei = []
for i in range(N):
    a,b = map(int,input().split())
    gakusei.append((a,b))
check = []
for i in range(1,M+1):
    c,d = map(int,input().split())
    check.append((c,d))
for i in range(N):
    a,b = gakusei[i]
    z = 10**9
    m = 0
    for j in range(1,M+1):
        c,d = check[j-1]
        x = max(a-c,c-a) + max(b-d,d-b)
        if x < z:
            m = j
            z = x
    print(m)
Buggy code:
N,M = map(int,input().split())
a_list = []
b_list = []
c_list = []
d_list = []
lists = []
for i in range(N):
    a,b = map(int,input().split())
    a_list.append(a)
    b_list.append(b)
for i in range(M):
    c,d = map(int,input().split())
    c_list.append(c)
    d_list.append(d)
for i in range(N):
    min = abs(a_list[0] - c_list[0]) + abs(b_list[0] - d_list[0])
    for j in range(M):
        distance = abs(a_list[i] - c_list[j]) + abs(b_list[i] - d_list[j])
        if min > distance:
            min = distance
            index = j
    lists.append(index+1)
for i in range(len(lists)):
    print(lists[i])


Fixed code:
N,M = map(int,input().split())
a_list = []
b_list = []
c_list = []
d_list = []
lists = []
for i in range(N):
    a,b = map(int,input().split())
    a_list.append(a)
    b_list.append(b)
for i in range(M):
    c,d = map(int,input().split())
    c_list.append(c)
    d_list.append(d)
for i in range(N):
    min = 9999999999999999999999999
    for j in range(M):
        distance = abs(a_list[i] - c_list[j]) + abs(b_list[i] - d_list[j])
        if min > distance:
            min = distance
            ind = j
    lists.append(ind+1)
for i in range(len(lists)):
    print(lists[i])
Buggy 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)

Fixed 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(m):
  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)
Buggy 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)

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

s = []
for i in range(N):
    s.append(list(map(int, input().split())))

c = []
for j in range(M):
    c.append(list(map(int, input().split())))

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

a = [[0, 0] for i in range(n)]

c = [[0, 0] for i in range(m)]

for i in range(n):
    a[i][0], a[i][1] = map(int, input().split())

for i in range(n):
    c[i][0], c[i][1] = map(int, input().split())

index = 0

for i in range(n):
    k = 1<<20
    for j in range(m):
        di = abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1])
        if di < k:
            index = j + 1
            k = di
    print(index)


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

a = [[0, 0] for i in range(n)]

c = [[0, 0] for i in range(m)]

for i in range(n):
    a[i][0], a[i][1] = map(int, input().split())

for i in range(m):
    c[i][0], c[i][1] = map(int, input().split())

index = 0


for i in range(n):
    for j in range(m):
        if j == 0 :
            k = abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1]) +1

        di = abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1])
        if di < k:
            index = j + 1
            k = di
    print(index)
Buggy code:
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 i in range(n):
  mini = 0
  m_i = 0
  for j in range(m):
    dis = abs(s[i][0]-c[j][0])+abs(s[i][1]-c[j][1])
    print(mini, dis)
    if j==0:
      mini, m_i = dis, j+1
      continue
    elif mini > dis:
      mini, m_i = dis, j+1
  print(m_i)

Fixed code:
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 i in range(n):
  mini = 0
  m_i = 0
  for j in range(m):
    dis = abs(s[i][0]-c[j][0])+abs(s[i][1]-c[j][1])
    if j==0:
      mini, m_i = dis, j+1
      continue
    elif mini > dis:
      mini, m_i = dis, j+1
  print(m_i)
Buggy code:
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
cd = [list(map(int, input().split())) for _ in range(M)]

for i in range(N):
    d = []
    for j in range(M):
        d.append(abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - ab[j][1]))
    print(d.index(min(d)) + 1)

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

for i in range(N):
  d = []
  for j in range(M):
    d.append(abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]))
  print(d.index(min(d)) + 1)
Buggy code:
n,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
c=[list(map(int,input().split())) for _ in range(m)]
ans=[[] for _ in range(n)]
for i in range(n):
  for j in range(n):
    p,q=a[i]
    r,s=c[j]
    d=abs(p-r)+abs(q-s)
    ans[i].append((d,j+1))
  ans[i]=sorted(ans[i])
for i in ans:
  print(ans[0][1])

Fixed code:
n,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
c=[list(map(int,input().split())) for _ in range(m)]
ans=[[] for _ in range(n)]
for i in range(n):
  p,q=a[i]
  for j in range(m):
    r,s=c[j]
    d=abs(p-r)+abs(q-s)
    ans[i].append((d,j+1))
  ans[i]=sorted(ans[i])
for i in ans:
  print(i[0][1])
Buggy 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



Fixed 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])
for i in range(n):
    x=[1000000000]*m
    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
Buggy code:
n, m = map(int,input().split())
ab = list(list(map(int, input().split())) for _ in range(n))
cd = list(list(map(int, input().split())) for _ in range(m))

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

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

for i in range(n):
    num = []
    for j in range(m):
        num.append(abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]))
    else:
        mini = min(num)
        print(num.index(mini)+1)
        num = []
Buggy code:
n, m = list(map(int, input().split()))
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = list(map(int, input().split()))
c = [0] * m
d = [0] * m
for j in range(m):
    c[j], d[j] = list(map(int, input().split()))

for i in range(n):
    distance = []
    minDistance = 10 ** 8 + 1
    checkPoint = 1
    for j in range(m):
        if j == 0:
            checkPoint = 1
        else:
            distance.append(abs(a[i] - c[j]) + abs(b[i] - d[j]))
            if minDistance > distance[j]:
                minDistance = distance[j]
                checkPoint = j + 1
    print(checkPoint)

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

for i in range(n):
    distance = []
    minDistance = 10 ** 16
    checkPoint = 1
    for j in range(m):
        distance.append(abs(a[i] - c[j]) + abs(b[i] - d[j]))
        if minDistance > distance[j]:
            minDistance = distance[j]
            checkPoint = j + 1
    print(checkPoint)
Buggy code:
def Distance(t_a,t_b):
    return abs(t_a[0]-t_b[0]) + abs(t_a[1]-t_b[1])

n,m = map(int,input().split(' '));
students = []
for p in range(n):
    students.append(tuple(map(int,input().split(' '))))
check = []
for q in range(m):
    check.append(tuple(map(int,input().split(' '))))
ans = ''
for s in students:
    dmin = Distance(s, check[0])
    dindex = 0
    i = 1
    while i < m:
        d0 = Distance(s, check[i])
        if d0 < dmin:
            dmin = d0
            dindex = i
        i += 1
    ans += str(dindex) + '\n'
print(ans)
        

Fixed code:
def Distance(t_a,t_b):
    return abs(t_a[0]-t_b[0]) + abs(t_a[1]-t_b[1])

n,m = map(int,input().split(' '));
students = []
for p in range(n):
    students.append(tuple(map(int,input().split(' '))))
check = []
for q in range(m):
    check.append(tuple(map(int,input().split(' '))))
ans = ''
for s in students:
    dmin = Distance(s, check[0])
    dindex = 0
    i = 1
    while i < m:
        d0 = Distance(s, check[i])
        if d0 < dmin:
            dmin = d0
            dindex = i
        i += 1
    ans += str(dindex+1) + '\n'
print(ans)
Buggy code:
a,b = map(int,input().split())
S = [list(map(int,input().split())) for i in range(a)]
CP = [list(map(int,input().split())) for i in range(b)]
for s in S:
  count = 0
  ab = 10**8
  p = 10**8
  for cp in CP:
    total = abs(s[0]-cp[0]) + abs(s[1]-cp[1])
    count +=1
    print(cp)
    if ab > total:
      ab = total
      p = count
      
  print(p)

Fixed code:
a,b = map(int,input().split())
S = [list(map(int,input().split())) for i in range(a)]
CP = [list(map(int,input().split())) for i in range(b)]
for s in S:
  count = 0
  ab = 10**9
  p = 10**9
  for i,cp in zip(range(b),CP):
    total = abs(s[0]-cp[0]) + abs(s[1]-cp[1])
    count +=1
    if ab > total:
      ab = total
      p = i+1
      
  print(p)
Buggy code:
def gcd(A, B, C, D):
	l, L = A-C, B-D
	if l<0:
		l = l*(-1)
	if L<0:
		L = L*(-1)
	return l+L
	
N, M = map(int, input().split())
x = []
y = []
n = 0
m = 0
ans = 1
for i in range(N):
	x1, y1 = map(int, input().split())
	x.append(x1)
	y.append(y1)
X = []
Y = []
for l in range(M):
	x2, y2 = map(int, input().split())
	X.append(x2)
	Y.append(y2)
for a in range(N):
	m = gcd(x[a], y[a], X[0], Y[0])
	for b in range(M):
		n = gcd(x[a], y[a], X[b], Y[b])
		if n < m:
			ans = b+1
	print(ans)
	ans = 1

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


def manhatten(tupleA,tupleB):
	return abs(tupleA[0]-tupleB[0]) + abs(tupleA[1]-tupleB[1])

header = input().split()
N,M = int(header[0]),int(header[1])
students = []
checkpoints = []

for i in range(N):
	student = input().split()
	student = [int(x) for x in student]
	students.append(tuple(student))

for i in range(M):
	checkpoint =input().split()
	checkpoint = [int(x) for x in checkpoint]
	checkpoints.append(tuple(checkpoint))

for student in students:
	distance = []
	for checkpoint in checkpoints:
		d = manhatten(student,checkpoint)
		distance.append(d)
	print(distance)
	print(distance.index(min(distance))+ 1)

Fixed code:
import os
import sys


def manhatten(tupleA,tupleB):
	return abs(tupleA[0]-tupleB[0]) + abs(tupleA[1]-tupleB[1])

header = input().split()
N,M = int(header[0]),int(header[1])
students = []
checkpoints = []

for i in range(N):
	student = input().split()
	student = [int(x) for x in student]
	students.append(tuple(student))

for i in range(M):
	checkpoint =input().split()
	checkpoint = [int(x) for x in checkpoint]
	checkpoints.append(tuple(checkpoint))

for student in students:
	distance = []
	for checkpoint in checkpoints:
		d = manhatten(student,checkpoint)
		distance.append(d)
	print(distance.index(min(distance))+ 1)
Buggy code:
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)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)

Fixed code:
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)
Buggy code:
n,m=map(int,input().split())
hoge_x=[]
hoge_y=[]
huga_x=[]
huga_y=[]
for i in range(n):
  a,b=map(int,input().split())
  hoge_x.append(a)
  hoge_y.append(a)
  
for j in range(m):
  a,b=map(int,input().split())
  huga_x.append(a)
  huga_y.append(b)

for i in range(n):
  ans_kyori=-1
  ans_index=-1
  for j in range(m):
    kyori=abs(hoge_x[i]-huga_x[j])+abs(hoge_y[i]-huga_y[j])
    if(kyori<ans_kyori or ans_kyori==-1):
      ans_kyori=kyori
      ans_index=j+1
  print(ans_index)

Fixed code:
n,m=map(int,input().split())
hoge_x=[]
hoge_y=[]
huga_x=[]
huga_y=[]
for i in range(n):
  a,b=map(int,input().split())
  hoge_x.append(a)
  hoge_y.append(b)
  
for j in range(m):
  a,b=map(int,input().split())
  huga_x.append(a)
  huga_y.append(b)

for i in range(n):
  ans_kyori=-1
  ans_index=-1
  for j in range(m):
    kyori=abs(hoge_x[i]-huga_x[j])+abs(hoge_y[i]-huga_y[j])
    if(kyori<ans_kyori or ans_kyori==-1):
      ans_kyori=kyori
      ans_index=j+1
  print(ans_index)
Buggy 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)

Fixed code:
n,m=map(int,input().split())
a,b,c,d=[],[],[],[]
for i in range(n):
    o = list(map(int, input().split()))
    a.append(o[0])
    b.append(o[1])
for i in range(m):
    o = list(map(int, input().split()))
    c.append(o[0])
    d.append(o[1])
s = []
for i in range(n):
    g = float('inf')
    h = 0
    for j in range(m):
        if g > abs(a[i]-c[j])+abs(b[i]-d[j]):
            g = abs(a[i]-c[j])+abs(b[i]-d[j])
            h = j+1
    s.append(h)
for i in s:
    print(i)
Buggy code:
N, M = map(int, input().split())
student = [tuple(map(int, input().split())) for _ in range(N)]
checkpoint = [tuple(map(int, input().split())) for _ in range(M)]

closest = {}
for s in student:
    min_dist = 'INF'
    ans = 1
    for c in checkpoint:
        dist = abs(s[0]-c[0]) + abs(s[1]-c[1])
        if min_dist == 'INF' or dist < min_dist:
            min_dist = dist
            closest[s] = ans
        ans += 1

print(closest[s] for s in student)
            

Fixed code:
N, M = map(int, input().split())
student = [tuple(map(int, input().split())) for _ in range(N)]
checkpoint = [tuple(map(int, input().split())) for _ in range(M)]

closest = {}
for s in student:
    min_dist = 'INF'
    ans = 1
    for c in checkpoint:
        dist = abs(s[0]-c[0]) + abs(s[1]-c[1])
        if min_dist == 'INF' or dist < min_dist:
            min_dist = dist
            closest[s] = ans
        ans += 1

for s in student:
    print(closest[s])