#include using namespace std; const int INF = 1e9; using ll = long long; using inv = vector; using stv = vector; using pint = pair; #define FOR(i,l,r) for(int i=(l); i<(r); i++) #define rep(i,r) for(int i=0; i<(r); i++) #define repl(i,r) for(long long i=0; i<(r); i++) #define FORl(i,l,r) for(long long i=(l); i<(r); i++) #define INFL ((1LL<<62)-(1LL<<31)) #define pb(x) push_back(x) #define CIN(x) cin >> x template size_t HashCombine(const size_t seed,const T &v){ return seed^(std::hash()(v)+0x9e3779b9+(seed<<6)+(seed>>2)); } template struct std::hash>{ size_t operator()(const std::vector &keyval) const noexcept { size_t s=0; for (auto&& v: keyval) s=HashCombine(s,v); return s; } }; int main(){ int N,T; cin >> N >> T; vector S(N); vector G(N); rep(i,N){ int a,b,c,d; cin >> a >> b >> c >> d; S[i] = make_pair(a,b); G[i] = make_pair(c,d); } int pi = 0; unordered_map, bool> R; int CD = 100; rep(day,T){ ll u,v; cin >> u >> v; if(u == -1LL && v == -1LL) return 0; double cost = (double)1e7/(double)sqrt(v); if(day <= CD-1) cout << 2 << endl; else if((double)u <= cost){ cout << 3 << endl; }else{ bool ok = false; while(!ok){ vector A{S[pi].first,S[pi].second,S[pi].first,S[pi].second}; if(S[pi].first < G[pi].first){ A[2]++; if(R[A]){ S[pi].first++; continue; } else{ cout << 1 << " " << S[pi].first << " " << S[pi].second << " " << S[pi].first+1 << " " << S[pi].second << endl; S[pi].first++; R[A] = true; ok = true; } }else if(S[pi].first > G[pi].first){ A[2]--; if(R[A]){ S[pi].first--; continue; } else{ cout << 1 << " " << S[pi].first << " " << S[pi].second << " " << S[pi].first-1 << " " << S[pi].second << endl; S[pi].first--; R[A] = true; ok = true; } }else if(S[pi].second < G[pi].second){ A[3]++; if(R[A]){ S[pi].second++; continue; } else{ cout << 1 << " " << S[pi].first << " " << S[pi].second << " " << S[pi].first << " " << S[pi].second +1 << endl; S[pi].second++; R[A] = true; ok = true; } }else if(S[pi].second > G[pi].second){ A[3]--; if(R[A]){ S[pi].second--; continue; } else{ cout << 1 << " " << S[pi].first << " " << S[pi].second << " " << S[pi].first << " " << S[pi].second -1 << endl; S[pi].second--; R[A] = true; ok = true; } } } if(S[pi].first == G[pi].first && S[pi].second == G[pi].second){ pi++; } } } return 0; }