from random import randint inf=998244353 def calc(a,b): return ((star[a][0]-star[b][0])**2+(star[a][1]-star[b][1])**2)*star[a][2]*star[b][2] def sell(strict): pos=0 go={0} ans=[0] ansdis=0 while len(go)imp: l=i r=j imp=pre if l==-1: break for i in range((r-l+1)//2): ans[l+i],ans[r-i]=ans[r-i],ans[l+i] return ansdis,ans N,M=map(int,input().split()) star=[tuple(map(int,input().split()+["5"])) for i in range(N)]+[[randint(0,1000),randint(0,1000),1] for i in range(M)] dist=[[[calc(i,j),[j]] for i in range(N+M)]for j in range(N+M)] for i in range(N+M): for j in range(N+M): for k in range(N+M): if dist[j][i][0]+dist[i][k][0]=N: print(2,i-N+1) else: print(1,i+1)