import sys input = sys.stdin.readline from operator import itemgetter from math import sqrt N,T=map(int,input().split()) P=[list(map(int,input().split())) for i in range(N)] YOKO=[0]*16 TATE=[0]*16 for a,b,c,d in P: TATE[min(a,c)]+=1 TATE[max(a,c)]-=1 YOKO[min(b,d)]+=1 YOKO[max(b,d)]-=1 for i in range(16): YOKO[i]+=YOKO[i-1] TATE[i]+=TATE[i-1] YOKOI=[(YOKO[i],i) for i in range(16)] TATEI=[(TATE[i],i) for i in range(16)] YOKOI.sort(key=itemgetter(0)) TATEI.sort(key=itemgetter(0)) ymax=YOKOI[-1][1] tmax=TATEI[-1][1] bridge=0 for days in range(T): u,v=map(int,input().split()) if days<25: print(2,flush=True) elif days<45: print(3,flush=True) elif int(10**7/sqrt(v))TATEI[-1][0]: print(1,tmax,YOKOI[-1][1],tmax,YOKOI[-1][1]+1,flush=True) YOKOI.pop() else: print(1,TATEI[-1][1],ymax,TATEI[-1][1]+1,ymax,flush=True) TATEI.pop() bridge+=1 elif v<100 and bridge<15: print(2,flush=True) else: print(3,flush=True)