#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; #define REP(i,n) for(int i=0;i<int(n);i++) int main(void){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int i,j,k; int N,K; cin >> N >> K; vector<P> a(N+1),c(2*N+1),e(N+1); vector<int> b(N+1),d(2*N+1),f(N+1); for(i=1;i<=6;i++){ if(i==1){ for(j=1;j<=N;j++){ int x; cin >> x; a[j].first=x; a[j].second=j; } } if(i==2){ for(j=1;j<=N;j++){ int x; cin >> x; b[j]=x; } } if(i==3){ for(j=1;j<=2*N;j++){ int x; cin >> x; c[j].first=x; c[j].second=j; } } if(i==4){ for(j=1;j<=2*N;j++){ int x; cin >> x; d[j]=x; } } if(i==5){ for(j=1;j<=N;j++){ int x; cin >> x; e[j].first=x; e[j].second=j; } } if(i==6){ for(j=1;j<=N;j++){ int x; cin >> x; f[j]=x; } } } sort(a.begin(),a.end()); sort(c.begin(),c.end()); sort(e.begin(),e.end()); int r=0; vector<P> aa=a,cc=c,ee=e; vector<int> u,v,w,x; for(i=1;i<=N;i++){ bool f=false; for(j=1;j<=N;j++){ if(aa[j].first==-1) continue; vector<int> t; for(k=1;k<=2*N;k++){ if(cc[k].first==-1) continue; if(ee[i].first<aa[j].first && aa[j].first<cc[k].first){ t.push_back(cc[k].second); cc[k].first=-1; if((int)t.size()==2){ r++; f=true; aa[j].first=-1; ee[i].first=-1; u.push_back(aa[j].second); x.push_back(ee[i].second); v.push_back(t[0]); w.push_back(t[1]); break; } } } if(f) break; } if(r==K) break; } for(int l=0;l<K;l++){ cout << u[l] << ' ' << v[l] << ' ' << w[l] << ' ' << x[l] << '\n'; } return 0; }