Harryxun/stf_run huggingface dataset:
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(n):
  c, d = map(int, input().split()) 
  cd.append([c,d])

distance = []
for a, b in ab:
  for c, d in cd:
    distance.append(abs(a-c)+abs(b-d))
  print(distance.index(min(distance))+1)
  distance.clear()

### 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 a, b in ab:
  distance = [abs(a-c) + abs(b-d) for c,d in cd]
  print(distance.index(min(distance))+1)
N = int(input())
S = list(input())
Q = int(input())
K = list(map(int,input().split()))
DP = [[0,0,0]]
C = []
for i in range(N):
    q = DP[i].copy()
    if S[i] == "D":
        q[0] += 1
    elif S[i] == "M":
        q[1] += 1
        q[2] += q[0]
    elif S[i] == "C":
        C.append(i+1)
    DP.append(q)

for k in K:
    ans = 0
    for c in C:
        if c < k:
            ans += DP[c][2]
        else:
            ans += DP[c][2] - DP[c-k][2] - DP[c-k][0]*(DP[c][1] - DP[c-k][1])
    print(ans)

### FIXED CODE ###

N = int(input())
S = list(input())
Q = int(input())
K = list(map(int,input().split()))
DP = [[0,0,0]]
C = []
for i in range(N):
    q = DP[i][:]
    if S[i] == "D":
        q[0] += 1
    elif S[i] == "M":
        q[1] += 1
        q[2] += q[0]
    elif S[i] == "C":
        C.append(i+1)
    DP.append(q)

for k in K:
    ans = 0
    for c in C:
        if c < k:
            ans += DP[c][2]
        else:
            ans += DP[c][2] - DP[c-k][2] - DP[c-k][0]*(DP[c][1] - DP[c-k][1])
    print(ans)
A = input()

S = 0
for i in range(0,10):
  S += A[i]
  
if int(A) % S == 0:
  print("Yes")
else:
  print("No")  


### FIXED CODE ###

A = input()

S = 0
for i in A:
  S = S + int(i)
  
if (int(A) % S) == 0:
  print("Yes")
else:
  print("No")
def decoder(str_int):
    s_=''
    for a in str_int:
        s_ = s_+(alpbet[a])
    return s_

def encoder(s):
    return [alpbet.index(a) for a in s]

s = raw_input()
K = input()

alpbet = 'abcdefghijklmnopqrstuvwxyz'
encoder = lambda s: [alpbet.index(a) for a in s]
inc_count = K
str_int = encoder(s)
for i in range(len(str_int)):
    if i != len(str_int)-1:
        if str_int[i] > 0:
            cost = 26 - str_int[i]
            if inc_count > cost:
                inc_count -= cost
                str_int[i] = 0
    else:
        str_int[i] = (str_int[i] + inc_count) % 26
        
print decoder(str_int)

### FIXED CODE ###

s = raw_input()
s = s[:4]+" "+s[4:]
print s
n = int(input())
m = str(n)
if m[-1] == m[-2] == m[-3] == "0":
    print(0)
else:
    print(1000 - int(m[-3]+m[-2]+m[-1]))

### FIXED CODE ###

n = int(input())
for i in range(100):
    if i * 1000 >= n:
        print(i * 1000 - n)
        break
N, M = map(int, input().split())
A = [int(a) for a in input().split()]
q = []
for a in A:
    heapq.heappush(q, -a)
    
for _ in range(M):
    tmp = -heapq.heappop(q)
    heapq.heappush(q, -(tmp//2))
print(-sum(q))

### FIXED CODE ###

import heapq

N, M = map(int, input().split())
A = [int(a) for a in input().split()]
q = []
for a in A:
    heapq.heappush(q, -a)
    
for _ in range(M):
    tmp = -heapq.heappop(q)
    heapq.heappush(q, -(tmp//2))
print(-sum(q))
import copy
class Dice(object):
  def __init__(self, List):
    self.face = List

  def n_spin(self, a_List):
    List = copy.copy(a_List)
    temp = List[0]
    List[0] = List[1]
    List[1] = List[5]
    List[5] = List[4]
    List[4] = temp

  def s_spin(self, a_List):
    List = copy.copy(a_List)
    temp = List[0]
    List[0] = List[4]
    List[4] = List[5]
    List[5] = List[1]
    List[1] = temp

  def e_spin(self, a_List):
    List = copy.copy(a_List)
    temp = List[0]
    List[0] = List[3]
    List[3] = List[5]
    List[5] = List[2]
    List[2] = temp

  def w_spin(self, a_List):
    List = copy.copy(a_List)
    temp = List[0]
    List[0] = List[2]
    List[2] = List[5]
    List[5] = List[3]
    List[3] = temp


dice = Dice(map(int, raw_input().split()))
emer = copy.copy(dice.face)
face_storage = []
q = input()
for a in range(q):
  question = map(int, raw_input().split())
  for a in range(24):
    face_storage.append(dice.n_spin(face_storage[a]))
    face_storage.append(dice.s_spin(face_storage[a]))
    face_storage.append(dice.w_spin(face_storage[a]))
    face_storage.append(dice.e_spin(face_storage[a]))
  for c in face_storage:
    if c[0] == question[0] and c[1] == question[1]:
      print c[2]
      break

### FIXED CODE ###

import copy
class Dice(object):
  def __init__(self, List):
    self.face = List

  def n_spin(self, a_List):
    List = copy.copy(a_List)
    temp = List[0]
    List[0] = List[1]
    List[1] = List[5]
    List[5] = List[4]
    List[4] = temp
    return List

  def s_spin(self, a_List):
    List = copy.copy(a_List)
    temp = List[0]
    List[0] = List[4]
    List[4] = List[5]
    List[5] = List[1]
    List[1] = temp
    return List

  def e_spin(self, a_List):
    List = copy.copy(a_List)
    temp = List[0]
    List[0] = List[3]
    List[3] = List[5]
    List[5] = List[2]
    List[2] = temp
    return List

  def w_spin(self, a_List):
    List = copy.copy(a_List)
    temp = List[0]
    List[0] = List[2]
    List[2] = List[5]
    List[5] = List[3]
    List[3] = temp
    return List

dice = Dice(map(int, raw_input().split()))
emer = copy.copy(dice.face)
face_storage = []
face_storage.append(emer)
q = input()
for a in range(q):
  question = map(int, raw_input().split())
  for a in range(24):
    face_storage.append(dice.n_spin(face_storage[a]))
    face_storage.append(dice.s_spin(face_storage[a]))
    face_storage.append(dice.w_spin(face_storage[a]))
    face_storage.append(dice.e_spin(face_storage[a]))
  for c in face_storage:
    if c[0] == question[0] and c[1] == question[1]:
      print c[2]
      break
import math
N = int(input())
print((math.factorial(N))/(10^9+7))


### FIXED CODE ###

import math
N = int(input())
print((math.factorial(N))%(10**9+7))
A,B,K = map(int,input().split())
list1 = list(range(A,B+1))
for i in list1:
	if A+K <= i <= B-K:
		pass
	else:
		print(i)

### FIXED CODE ###

A,B,K = map(int,input().split())
list_A = list(range(A,min(B,A+K)))
list_B = list(range(max(A,B-K+1),B+1))
list_C = list_A + list_B
set_C = set(list_C)
list_D = sorted(list(set_C))
for i in list_D:
	print(i)
a, b = (int(i) for i in input().split())  
echo(a, b)

### FIXED CODE ###

x,y = map(int ,input().split())
print(int(x+y/2))
import math

# nの約数を全て求める
lim = 10 ** 9 + 7

n = int(input())
fact = math.factorial(n)
check = [0] * (fact + 1)
for i in range(1, fact + 1):
    if (fact % i == 0):
        check[i] = 1

ans = sum(check)
ans %= lim
print(ans)


### FIXED CODE ###

#import math
#from decimal import Decimal
import numpy as np
# nの約数を全て求める
# n!が大きすぎ＞　解説をみると。。
# ex; 24 = 2^3 * 3
#       (1,2,3,4,6,8,12,24) > 8個

# approach, 1~Nごとに、素因数分解をして、カウントする。
# 最後に掛け合わせる。
lim = 10 ** 9 + 7
n = int(input())
# https://note.nkmk.me/python-prime-factorization/

num = [0] * (n + 1)
#num[1] = 1

for i in range(2, n + 1):
    temp = i
    # even number
    while (temp % 2 == 0):
        if (num[2] == 0):
            num[2] = 1
        num[2] += 1
        # print('2A')
        temp //= 2

    f = 3
    # odd number
    while (f * f <= temp):
        if (temp % f == 0):
            if (num[f] == 0):
                num[f] = 1
            num[f] += 1
            #print('B', f)
            temp //= f
        else:
            f += 2
    # prime number
    if (temp != 1):
        if (num[temp] == 0):
            num[temp] += 1
        num[temp] += 1
        #print('C', temp)

numA = np.array(num)
numAA = np.argwhere(numA != 0)
numAAA = numAA.tolist()
# print(numA)

ans = 1
for i in numAAA:
    tar = i[0]
    ans *= num[tar]

#ans = sum(num)
ans %= lim

print(ans)
'''
Created on 2020/09/10

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N,M=map(int,pin().split())
  if N==3:
    ans=[1,0,0]
    for _ in [0]*M:
      s,c=map(int,pin().split())
      if s==1 and c==0:
        print(-1)
        return 
      if s!=1 and ans[s-1]!=0 and ans[s-1]!=c:
        print(-1)
        return 
      ans[s-1]=c
    a=""
    for i in ans:
      a+=str(i) 
    print(a)
    return 
  elif N==2:
    ans=[1,0]
    for _ in [0]*M:
      s,c=map(int,pin().split())
      if s==1 and c==0:
        print(-1)
        return 
      if s!=1 and ans[s-1]!=0 and ans[s-1]!=c:
        print(-1)
        return 
      ans[s-1]=c
    a=""
    for i in ans:
      a+=str(i)
    print(a)
    return
  else:
    s,c=map(int,pin().split())
    ans=c 
    for j in range(M-1):
      s,c=map(int,pin().split())
      if c!=ans:
        print(-1)
        return 
    print(ans)
    return 
  
main()

### FIXED CODE ###

'''
Created on 2020/08/31

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  N,M=map(int,pin().split())
  ans=[0]*N
  for _ in [0]*M:
    s,c=map(int,pin().split())
    if s==1 and c==0 and N!=1:
      print(-1)
      return 
    if ans[s-1]!=0 and ans[s-1]!=c:
      print(-1)
      return
    ans[s-1]=c
  if N==3:
    if ans[0]==0:
      if ans[1]==0:
        print(f"{1}{0}{ans[2]}")
      else:
        print(f"{1}{ans[1]}{ans[2]}")
      return
    else:
      print(f"{ans[0]}{ans[1]}{ans[2]}")
      return
  elif N==2:
    if ans[0]==0:
      print(f"{1}{ans[1]}")
    else:
      print(f"{ans[0]}{ans[1]}")
    return
  else:
    print(ans[0])
    return
  return
main()
import math
a,b,x = list(map(int, input().split()))

x = x / a

if x > a*b / 2:
  print(90 - math.degrees(math.atan(a*a/2/(a*b - x))))
else:
  print(90 - math.degrees(math.atan(2*x/b/b)))
  
  

### FIXED CODE ###

import math
a,b,x = list(map(int, input().split()))

x = x / a

if a*b == x:
  print(0)
elif x > a*b / 2:
  print(90 - math.degrees(math.atan(a*a/2/(a*b - x))))
else:
  print(90 - math.degrees(math.atan(2*x/b/b)))
N = int(input())
A = sorted([int(input()) for i in range(N)])

if N % 2 == 0:
    print(2 * (sum(A[N // 2:]) - sum(A[:N // 2])) - (A[N // 2] - A[N // -1]))
else:
    print(2 * (sum(A[N // 2 + 1:]) - sum(A[:N // 2])) - min(A[N // 2] - A[N // 2 - 1], A[N // 2 + 1] - A[N // 2]))


### FIXED CODE ###

S = input()

if len(S) == 2:
    print(S)
else:
    print(S[::-1])
N,M = input().split()

if N%M ==0:
    print(0)
else:
    print(1)

### FIXED CODE ###

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

if N%M == 0:
    print(0)
else:
    print(1)
s = list(input())
t = list(input())
s = 0
for i in range(3):
  s[i] = t[i]
  s += 1
print(s)
  


### FIXED CODE ###

s = list(input())
t = list(input())
u = 0
for i in range(3):
  if s[i] == t[i]:
    u += 1
print(u)
import heapq, math, sys

N, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
maxA = A[0]
pre = -1
while len(A) != pre:
    if len(A) == 0:
        print(math.ceil(maxA))
        sys.exit()
    pre = len(A)
    meanA = math.ceil(sum(A)/(len(A)+K))
    for i, a in enumerate(A):
        if a <= meanA:
            A = A[:i]
            break


cuts = [0]*(i+1)
meanA = math.ceil(sum(A)/(len(A)+K))
for i, a in enumerate(A):
    cut_at_least = (a//meanA - 1)
    cuts[i] = cut_at_least
    K -= cut_at_least
hq = [(-a/(cut+1), i) for i, (a, cut) in enumerate(zip(A, cuts))]
heapq.heapify(hq)
lenhq = len(hq)
for k in range(K):
    l, i = heapq.heappop(hq)
    cuts[i] += 1
    if k <= lenhq:
        heapq.heappush(hq, (-A[i]/(cuts[i]+1), i))
l, i = heapq.heappop(hq)
print(math.ceil(-l))


### FIXED CODE ###

import heapq, math, sys

N, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
maxA = A[0]
pre = -1
while len(A) != pre:
    if len(A) == 0:
        print(math.ceil(maxA))
        sys.exit()
    pre = len(A)
    meanA = math.ceil(sum(A)/(len(A)+K))
    for i, a in enumerate(A):
        if a <= meanA:
            A = A[:i]
            break


cuts = [0]*(i+1)
meanA = (sum(A)/(len(A)+K))
for i, a in enumerate(A):
    cut_at_least = (math.floor(a/meanA) - 1)
    cuts[i] = cut_at_least
    K -= cut_at_least
hq = [(-a/(cut+1), i) for i, (a, cut) in enumerate(zip(A, cuts))]
heapq.heapify(hq)
lenhq = len(hq)
for k in range(K):
    l, i = heapq.heappop(hq)
    cuts[i] += 1
    if k <= N:
        heapq.heappush(hq, (-A[i]/(cuts[i]+1), i))
l, i = heapq.heappop(hq)
print(math.ceil(-l))
s = int(input())
t = int(input())

from collections import Counter
SC = Counter(s)
TC = Counter(s)

SCV = SC.values()
TCV = TC.values()

SCV.sort()
TCV.sort()

if SCV == TCV:
  print('Yes')
else:
  print('No')


### FIXED CODE ###

s=list(input())
t=list(input())
S=sorted(map(s.count,set(s)))
T=sorted(map(t.count,set(t)))
print("Yes" if S==T else "No")
import math

a, b, c, d = map(int, input().split())
c_flag = 0
d_flag = 0
cd_flag = 0


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


c_multiple_last = b // c
d_multiple_last = b // d
cd_multiple_last = b // lcm(c, d)

for i in range(a, b+1):
    if i % c == 0 and c_flag == 0:
        c_multiple_first = i // c
        c_flag = 1
    if i % d == 0 and d_flag == 0:
        d_multiple_first = i // d
        d_flag = 1
    if i % lcm(c, d) == 0 and cd_flag == 0:
        cd_multiple_first = i // lcm(c, d)
        cd_flag = 1
    if c_flag == 1 and d_flag == 1 and cd_flag == 1:
        break

c_count = c_multiple_last - c_multiple_first + 1
d_count = d_multiple_last - d_multiple_first + 1
cd_count = cd_multiple_last - cd_multiple_first + 1

a_to_b_count = b - a + 1
ans = a_to_b_count - (c_count + d_count - cd_count)
print(ans)


### FIXED CODE ###

import fractions


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


a, b, c, d = map(int, input().split())

c_multiple_last = b // c
d_multiple_last = b // d
cd_multiple_last = b // lcm(c, d)

c_multiple_first = (a-1) // c
d_multiple_first = (a-1) // d
cd_multiple_first = (a-1) // lcm(c, d)

c_count = c_multiple_last - c_multiple_first
d_count = d_multiple_last - d_multiple_first
cd_count = cd_multiple_last - cd_multiple_first

a_to_b_count = b - a + 1
ans = a_to_b_count - (c_count + d_count - cd_count)
print(ans)
n = int(intput())

a = list(map(int,input().split()))

sa = sorted(a)

if n % 2 == 0:
  k = 0
else:
  k = 1

flag = True

for i,s in enumerate(sa):
  if (i/2)*2+k != s:
    flag = false

if flag:
  print(2**n/2)
else:
  print(0)


### FIXED CODE ###

n = int(input()) 
a = list(map(int,input().split())) 
sa = sorted(a) 

if n % 2 == 0:
  k = 1
  l = 0
else:
  k = 0
  l = 1 

a=1000000007
flag = True 
for i,s in enumerate(sa):
  if ((i+l)//2)*2+k != s:
    flag = False
if flag:
  print(2**(n//2) % a)
else:
  print(0)
a,b,k=map(int,input().split())

aa = a - k
if aa < 0:
    bb = 0 if b+aa <0 else  b+aa
    aa=0

print (aa,bb)

### FIXED CODE ###

a,b,k=map(int,input().split())

a = a - k

if a < 0:
    b = 0 if b+a <0 else  b+a
    a=0
print (a,b)
H, W, K = map(int, input().split())
c = [input() for i in range(H)]
max_num = count_num(c)

ans = 0
for h in range(2**H):
  for w in range(2**W):
    cnt = 0
    for i in range(H):
      for j in range(W):
        if (h >> i) & 1:
          continue
        if (w >> j) & 1:
          continue
        if x[i][j] == '#'
          cnt +=1
    if cnt == K:
      ans +=1
print(ans) 

### FIXED CODE ###

H, W, K = map(int, input().split())
c = [input() for i in range(H)]

ans = 0
for h in range(2**H):
  for w in range(2**W):
    cnt = 0
    for i in range(H):
      for j in range(W):
        if (h >> i) & 1:
          continue
        if (w >> j) & 1:
          continue
        if c[i][j] == '#':
          cnt +=1
    if cnt == K:
      ans +=1
print(ans)
n = int(input())
s = input()
l = []
for i in range(len(s)):
  if s[i] == "R":
    l.append(i)
if l[0] < len(l):
  ans = 0
  for i in l:
    if i >len(l)-1:
      ans += 1
  print(ans)
else:
  print(len(l))

### FIXED CODE ###

n = int(input())
s = input()
l = []
for i in range(len(s)):
  if s[i] == "R":
    l.append(i)
if l ==[]:
  print(0)
elif l[0] < len(l):
  ans = 0
  for i in l:
    if i >len(l)-1:
      ans += 1
  print(ans)
else:
  print(len(l))
a=int(input())
b,c,d=a/3
print(a*b*c)

### FIXED CODE ###

a=int(input())
print((a/3)**3)
def main():
    N = int(input())
    p = list(map(int, input().split()))
    p.sort()
    pp = list(set(p))

    cnt = 0
    for i in range(len(pp)):
        cnt += 1
        scnt = 0
        for j in range(len(p)):
            if pp[i] <= pp[j]:
                scnt += 1
        if cnt == scnt:
            break
    print(cnt)


if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    N = int(input())
    p = list(map(int, input().split()))
    ans = []

    sc = 1 #score count
    for _ in range(N):
        cnt = 0
        for i in range(len(p)):
            if p[i] >= sc:
                cnt += 1
        if cnt >= sc:
            ans.append(sc)
        sc += 1

    ans.sort(reverse = True)
    print(ans[0])


if __name__ == "__main__":
    main()
a,b,c=map(int,input().split())
for i in range(1,b+1):
  if (i*a)%b==c:
    print('YES')
  break
print('NO')
a,b,c=map(int,input().split())
for i in range(b):
  if (i*a)%b==c:
    print('YES')
    break
print('NO')

### FIXED CODE ###

a,b,c=map(int,input().split())
ans='NO'
for i in range(1,b+1):
  if (i*a)%b==c:
    ans='YES'
    break
print(ans)
N = int(input())
A = list(map(int, input().split()))

A = sorted(A)
ans = 0
for i in range(N):
    for j in range(i-1, -1, -1):
        if A[i] % A[j] == 0:
            break
    else:
        if i == 0 and A[i] == A[i+1]:
            continue
        ans += 1
print(ans)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
m = max(A)+10
dp = [0] * m

for x in A:
    dp[x] += 1

ans = 0
for i in range(1, m):
    if dp[i]:
        if dp[i] == 1:
            ans += 1
        for j in range(i, m, i):
            dp[j] = 0
print(ans)
d1=list(map(int,input().split()))
d2=list(map(int,input().split()))

class dice(object):
	def __init__(self, d):
		self.d = d

	def roll(self,com):
		a1,a2,a3,a4,a5,a6=self.d
		if com=="E":
			self.d = [a4,a2,a1,a6,a5,a3]
		elif com=="W":
			self.d = [a3,a2,a6,a1,a5,a4]
		elif com=="S":
			self.d = [a5,a1,a3,a4,a6,a2]
		elif com=="N":
			self.d = [a2,a6,a3,a4,a1,a5]

dice1=dice(d1)
dice2=dice(d2)

if sorted(d1)!=sorted(d2):
	print("No")
else:
	c=["E","W","S","N"]
	import random
	for i in l:
		n=0
		while n<10**5:
			if dice1.d==dice2.d:
				break 
			else:
				dice1.roll(c[random.randint(1,2)])
			n+=1
		if n>10**5:
			print("No")
		else:
			print("Yes")

### FIXED CODE ###

d1=list(map(int,input().split()))
d2=list(map(int,input().split()))

class dice(object):
	def __init__(self, d):
		self.d = d

	def roll(self,com):
		a1,a2,a3,a4,a5,a6=self.d
		if com=="E":
			self.d = [a4,a2,a1,a6,a5,a3]
		elif com=="W":
			self.d = [a3,a2,a6,a1,a5,a4]
		elif com=="S":
			self.d = [a5,a1,a3,a4,a6,a2]
		elif com=="N":
			self.d = [a2,a6,a3,a4,a1,a5]

dice1=dice(d1)
dice2=dice(d2)

if sorted(d1)!=sorted(d2):
	print("No")
else:
	c=["E","W","S","N"]
	import random
	n=0
	while n<10**5:
		if dice1.d==dice2.d:
			break 
		else:
			dice1.roll(c[random.randint(1,2)])
		n+=1
	if n==10**5:
		print("No")
	else:
		print("Yes")
from math import gcd

A, B, C, D = map(int, input().split())


print((B-A+1) - (B//C + B//D - B//(C*D//gcd(C,D))) + ((A-1)//C + (A-1)//D - (A-1)//(C*D//gcd(C,D))))

### FIXED CODE ###

from fractions import gcd

A, B, C, D = map(int, input().split())

a = (B-A+1)
b = -(B//C + B//D - B//(C*D//gcd(C,D)))
c = ((A-1)//C + (A-1)//D - (A-1)//(C*D//gcd(C,D)))

print(a+b+c)
S = input()
n = len(S)
for m in range (3, n):
    if S[m-1] == C:
        Count_C = Count_C + 1
        S[m-1].lower()
if S[1] == A:
    Count_A = 1
    S[1].lower()
if(Count_C == 1 and Count_A == 1 and S.islower()):
    print('AC')
else:
    print('WA')



### FIXED CODE ###

R = int(input())
if R < 1200:
    print('ABC')
elif R < 2800:
    print('ARC')
else:
    print('AGC')
# An efficient Python3 program to compute  
# sum of bitwise OR of all pair

# Returns sum of bitwise OR
# of all pairs
def sumXOR( arr,  n):

    sum = 0
    for i in range(0, 32):

        #  Count of zeros and ones
        zc = 0
        oc = 0

        # Individual sum at each bit position
        idsum = 0
        for j in range(0, n):
            if (arr[j] % 2 == 0):
                zc = zc + 1

            else:
                oc = oc + 1
            arr[j] = int(arr[j] / 2)


        # calculating individual bit sum
        idsum = oc * zc * (1 << i)

        # final sum
        sum = sum + idsum;

    return sum%(1e9+7)



# driver function
sum = 0
n = int(input())
arr = []
for _ in range(n):
    arr.append(int(input())
sum = sumXOR(arr, n);
print (sum)


### FIXED CODE ###

import numpy as np

MAX_DIGIT = 60
MOD = 10**9 + 7

N = int(input())
A = np.array([int(a) for a in input().split()])

answer = 0
for d in range(MAX_DIGIT + 1):
    A, r = (A>>1), A % 2
    s = int(r.sum())
    base = (1<<d) % MOD #this may be key
    answer += (base * s * (N - s)) % MOD

answer %= MOD
print(answer)
n,k=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
ans=int(0)
for i in ramge(n-k,n):
	ans+=A[i]
print(ans)


### FIXED CODE ###

n,k=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
ans=int(0)
for i in range(n-k,n):
	ans+=A[i]
print(ans)
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created:  2016-09-28
#

# Usage
#
"""
import sys

def input_single_line():
    """Receive Inputs."""
    return input()

def input_two_line():
    """Receive Two Lined Inputs.
    Like this.

    N
    1 2 3 4 5
    """
    sys.stdin.readline()
    target = sys.stdin.readline()
    target = target.rstrip("\n")
    target = target.split(" ")

    return target


def search_lovers(target_list: list) -> None:
    """Search Simple."""
    lovers = []
    for i in target_list:
        pos = int(i)
        if target_list[pos-1] == pos-1:
            lovers.append(pos-1)

    print(len(lovers))


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

    target = input_two_line()

    search_lovers(target)



### FIXED CODE ###

# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created:  2016-09-28
#

# Usage
#
"""
from __future__ import division
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import absolute_import

def input_process():
    """Receive Inputs."""
    return input()


def insert_space(target_str: str) -> str:
    """
    >>> insert_space("codefestival")
    code festival
    """
    return target_str[0:4] + " " + target_str[4:]

if __name__ == "__main__":
    target = input()

    print(insert_space(target))
N,M = [int(c) for c in input().split()]
ab = [list(map(int,input().split())) for c in range(N)]
cd = [list(map(int,input().split())) for c in range(M)]
for i in range(N):
    mi = 2*10**8+1
    for j in range(M):
        tmp = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if mi > tmp:
            mi = tmp
            ans = j+1
    print(ans)


### FIXED CODE ###

N,M = [int(c) for c in input().split()]
ab = [list(map(int,input().split())) for c in range(N)]
cd = [list(map(int,input().split())) for c in range(M)]
for i in range(N):
    mi = 2*10**9
    for j in range(M):
        tmp = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if mi > tmp:
            mi = tmp
            ans = j+1
    print(ans)