#ifdef _WIN32 # define LL "%I64d" #else # define LL "%Ld" #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define null NULL #define mp make_pair #define pb(a) push_back(a) #define sz(a) ((int)(a).size()) #define all(a) a.begin() , a.end() #define fi first #define se second #define relaxMin(a , b) (a) = min((a),(b)) #define relaxMax(a , b) (a) = max((a),(b)) #define SQR(a) ((a)*(a)) typedef vector vi; typedef pair pii; typedef long long ll; ifstream fin("wizard.in"); ofstream fout("wizard.out"); typedef long double ldbl; const ldbl EPS = 1E-7; typedef pair shape; const ldbl kk3 = sqrt(3); const ldbl kk3dk3p2 = sqrt(3) / (sqrt(3) + 2); const ldbl k2k2d1pk3 = 2 * sqrt(2) / (1 + sqrt(3)); const ldbl kk3d2 = sqrt(3) / 2; const ldbl kk2 = sqrt(2); bool Fits(const shape& w, const shape& in){ if(in.fi == 0){ // tri if(w.fi == 0) return (w.se <= in.se); if(w.fi == 1) return (w.se <= in.se * kk3dk3p2 + EPS); if(w.fi == 2) return (w.se <= in.se / kk3 + EPS); } if(in.fi == 1){ // kv //cout << in.se << endl; //cout << k2k2d1pk3 * in.se << endl; if(w.fi == 0) return (w.se <= in.se * k2k2d1pk3 + EPS); if(w.fi == 1) return (w.se <= in.se); if(w.fi == 2) return (w.se <= in.se); } if(in.fi == 2){ // kr if(w.fi == 0) return (w.se <= in.se * kk3d2 + EPS); if(w.fi == 1) return (w.se <= in.se / kk2 + EPS); if(w.fi == 2) return (w.se <= in.se); } } shape g[1010], h[1010]; int a, b, c; int p, q, r; ldbl D; bool CanGo(const shape& w, const shape& in){ if(in.se - w.se > D + EPS) return false; return Fits(w, in); } // Dinic #define SZ 2010 #define INF 1000000000 struct edge{ int f,t,cap,fl; edge(int _f=0,int _t=0,int _cap=0){ f=_f; t=_t; cap=_cap; fl=0; } int rc(){return cap-fl;} }; int N , F , T; vector E; vi fo[SZ]; void add_edge(int f,int t,int cap){ E.pb(edge(f,t,cap)); E.pb(edge(t,f,0)); fo[f].pb(sz(E)-2); fo[t].pb(sz(E)-1); } int lev[SZ] , Q[SZ] , QL , QR; bool bfs(){ memset(lev , -1 , N*sizeof(int)); QL = QR = 0; lev[F] = 1; Q[QR++] = F; while(QL e.fl){ int pushed = dfs(e.t , min(htp , e.rc())); if(pushed){ e.fl += pushed; E[ fo[vr][pos[vr]] ^ 1 ].fl -= pushed; return pushed; } } } return 0; } int max_flow(){ int FLOW = 0 , how; while(bfs()){ memset(pos , 0 , N*sizeof(int)); while(how = dfs(F))FLOW += how; } return FLOW; } void Read(ldbl& w){ fin >> w; //double t; //scanf("%lf", &t); //w = t; } int main(){ //freopen("wizard.in", "r", stdin); //freopen("wizard.out", "w", stdout); //ios_base::sync_with_stdio(false); //scanf("%d%d%d", &a, &b, &c); fin >> a >> b >> c; for(int i = 0;i < a;++i) Read(g[i].se), g[i].fi = 0; for(int i = 0;i < b;++i) Read(g[i + a].se), g[i + a].fi = 1; for(int i = 0;i < c;++i) Read(g[i + a + b].se), g[i + a + b].fi = 2; //scanf("%d%d%d", &p, &q, &r); fin >> p >> q >> r; for(int i = 0;i < p;++i) Read(h[i].se), h[i].fi = 0; for(int i = 0;i < q;++i) Read(h[i + p].se), h[i + p].fi = 1; for(int i = 0;i < r;++i) Read(h[i + p + q].se), h[i + p + q].fi = 2; Read(D); //cout << D << endl; int n = a + b + c, m = p + q + r; N = n + m + 2, F = N - 2, T = N - 1; //cout << g[4 - 1].fi << ' ' << h[6 - 1].fi << endl; //cout << CanGo(g[4 - 1], h[6 - 1]) << endl; //system("pause"); for(int i = 0;i < n;++i) add_edge(F, i, 1); for(int i = 0;i < m;++i) add_edge(i + n, T, 1); for(int i = 0;i < n;++i) for(int j = 0;j < m;++j) if(CanGo(g[i], h[j])) add_edge(i, j + n, 1); max_flow(); vector out; for(int i = 0;i < sz(E);++i) if(E[i].fl > 0 && E[i].f != F && E[i].t != T) out.pb(mp(E[i].f + 1, E[i].t - n + 1)); //printf("%d\n", sz(out)); fout << sz(out) << '\n'; for(int i = 0;i < sz(out);++i) fout << out[i].fi << ' ' << out[i].se << '\n'; //printf("%d %d\n", out[i].fi, out[i].se); fout.flush(); fout.close(); fin.close(); return 0; }