import numpy as np

N, M= list(map(int, raw_input().split()))
student = [list(map(int, raw_input().split())) for i in range(N)]
checkpoint = [list(map(int, raw_input().split())) for i in range(M)]

student = np.array(student)
checkpoint = np.array(checkpoint)

for i in range(M):
    print(np.abs(student - checkpoint[i]).sum(axis=1).argmin()+1)


