#pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include // #include // #include // #include // using namespace __gnu_pbds; // #include // namespace multiprecisioninteger = boost::multiprecision; // using cint=multiprecisioninteger::cpp_int; using namespace std; using ll=long long; #define double long double using datas=pair; using ddatas=pair; using tdata=pair; using vec=vector; using mat=vector; using pvec=vector; using pmat=vector; // using llset=tree,rb_tree_tag,tree_order_statistics_node_update>; #define For(i,a,b) for(i=a;i<(ll)b;++i) #define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i) #define rep(i,N) For(i,0,N) #define rep1(i,N) For(i,1,N) #define brep(i,N) bFor(i,N,0) #define brep1(i,N) bFor(i,N,1) #define all(v) (v).begin(),(v).end() #define allr(v) (v).rbegin(),(v).rend() #define vsort(v) sort(all(v)) #define vrsort(v) sort(allr(v)) #define uniq(v) vsort(v);(v).erase(unique(all(v)),(v).end()) #define endl "\n" #define eb emplace_back #define print(x) cout< ostream& operator<<(ostream& os,const pair& p){return os<<"("< ostream& operator<<(ostream& os,const vector& v){ os<<"{";bool f=false; for(auto& x:v){if(f)os<<",";os< ostream& operator<<(ostream& os,const set& v){ os<<"{";bool f=false; for(auto& x:v){if(f)os<<",";os< inline bool chmax(T& a,T b){bool x=a inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} #ifdef DEBUG void debugg(){cout<void debugg(const T& x,const Args&... args){cout<<" "<>A>>B>>C>>D>>N; vec pa,ma,pb,mb; map> mpa,mpb; rep(i,A)cin>>f[i]; rep(i,B){ int x; cin>>x; rep(j,A){ mpa[x*f[j]]=pair(f[j],x); if(x*f[j]>0)pa.emplace_back(x*f[j]); else if(x*f[j]<0)ma.emplace_back(-x*f[j]); else ++za; } } rep(i,C)cin>>f[i]; rep(i,D){ int x; cin>>x; rep(j,C){ mpb[x*f[j]]=pair(f[j],x); if(x*f[j]>0)pb.emplace_back(x*f[j]); else if(x*f[j]<0)mb.emplace_back(-x*f[j]); } } A=A*B; B=C*D; vsort(pa);vsort(pb);vsort(ma);vsort(mb); debug(pa,pb,ma,mb); ll msize=(ll)pa.size()*mb.size()+(ll)pb.size()*ma.size(); if(msize>=N){ ll ok=0,ng=inf; while(ng-ok>1){ ll mid=(ok+ng)/2,cnt=0; for(auto x:pa)cnt+=mb.end()-lower_bound(all(mb),(mid+x-1)/x); for(auto x:pb)cnt+=ma.end()-lower_bound(all(ma),(mid+x-1)/x); if(cnt=N){ print(0); if(za){ auto& x=mpb.begin()->second; print(mpa[0].first<<" "<second; print(x.first<<" "<1){ ll mid=(ok+ng)/2,cnt=0; for(auto x:pa)cnt+=upper_bound(all(pb),mid/x)-pb.begin(); for(auto x:ma)cnt+=upper_bound(all(mb),mid/x)-mb.begin(); if(cnt