//Let's join Kaede Takagaki Fan Club !! #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include #include #include using namespace std; //#define int long long typedef long long ll; typedef pair P; typedef pair P1; typedef pair P2; #define pu push #define pb push_back #define eb emplace_back #define mp make_pair #define eps 1e-7 #define INF 1000000000 #define a first #define b second #define fi first #define sc second #define rng(i,a,b) for(int i=int(a);i bool chmax(t&a,u b){if(a bool chmin(t&a,u b){if(b using vc=vector; template ostream& operator<<(ostream& os,const pair& p){ return os<<"{"< ostream& operator<<(ostream& os,const vc& v){ os<<"{"; for(auto e:v)os< void g(T &a){ cin >> a; } template void o(const T &a,bool space=false){ cout << a << (space?' ':'\n'); } //ios::sync_with_stdio(false); const ll mod = 1000000007;//998244353 //mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count()); template void add(T&a,T b){ a+=b; if(a >= mod) a-=mod; } ll modpow(ll x,ll n){ ll res=1; while(n>0){ if(n&1) res=res*x%mod; x=x*x%mod; n>>=1; } return res; } ll divv(ll a, ll b) { // floored division if (b < 0) a *= -1, b *= -1; if (a >= 0) return a / b; return -((-a + b - 1) / b); } int n[4]; vca[4]; ll cnt; vc>v[2]; void solve(){ rep(i, 4) cin >> n[i]; cin >> cnt; rep(i, 4){ a[i].resize(n[i]); rep(j, n[i]) cin >> a[i][j]; } rep(i, 2){ for(auto at:a[i*2]){ for(auto at2:a[i*2+1]){ v[i].pb(mp(1LL*at*at2, mp(at, at2))); } } SORT(v[i]); } ll lb = -1e18, ub = 1e18; //(lb, ub] while(ub-lb > 1){ ll mid = (lb+ub)/2, C = 0; for(auto att:v[0]){ ll at = att.a; ll lv, uv; if(at == 0){ if(mid < 0) continue; lv = -1e18, uv = 1e18; } else if(at > 0){ lv = -1e18; uv = divv(mid, at); } else{ uv = 1e18; lv = divv(mid, at); if(mid%at != 0) lv ++; } ll X = v[1].size(), Y = 0; if(uv != 1e18) X = POSU(v[1], mp(uv+1, mp(-INF, -INF))); if(lv != -1e18) Y = POSL(v[1], mp(lv, mp(-INF, -INF))); C += X - Y; } if(C >= cnt) ub = mid; else lb = mid; } for(auto att:v[0]){ ll at = att.a; if(at == 0){ if(ub) continue; cout << ub << endl; cout << att.b.a << " " << att.b.b << " "; cout << v[1][0].b.a << " " << v[1][0].b.b << endl; return; } if(ub%at != 0) continue; int x = POSL(v[1], mp(ub/at, mp(-INF, -INF))); if(x < v[1].size() && v[1][x].a == ub/at){ cout<> t; while(t--) solve(); }