#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; template struct modint { private: unsigned int value; static constexpr int mod() {return m;} public: constexpr modint(const long long x = 0) noexcept { long long y = x; if(y < 0 || y >= mod()) { y %= mod(); if(y < 0) y += mod(); } value = (unsigned int)y; } static constexpr int get_mod() noexcept {return m;} static constexpr int primitive_root() noexcept { assert(m == 998244353); return 3; } constexpr unsigned int val() noexcept {return value;} constexpr modint &operator+=(const modint &other) noexcept { value += other.value; if(value >= mod()) value -= mod(); return *this; } constexpr modint &operator-=(const modint &other) noexcept { unsigned int x = value; if(x < other.value) x += mod(); x -= other.value; value = x; return *this; } constexpr modint &operator*=(const modint &other) noexcept { unsigned long long x = value; x *= other.value; value = (unsigned int) (x % mod()); return *this; } constexpr modint &operator/=(const modint &other) noexcept { return *this *= other.inverse(); } constexpr modint inverse() const noexcept { assert(value); long long a = value,b = mod(),x = 1,y = 0; while(b) { long long q = a/b; a -= q*b; swap(a,b); x -= q*y; swap(x,y); } return modint(x); } constexpr modint power(long long N) const noexcept { assert(N >= 0); modint p = *this,ret = 1; while(N) { if(N & 1) ret *= p; p *= p; N >>= 1; } return ret; } constexpr modint operator+() {return *this;} constexpr modint operator-() {return modint() - *this;} constexpr modint &operator++(int) noexcept {return *this += 1;} constexpr modint &operator--(int) noexcept {return *this -= 1;} friend modint operator+(const modint& lhs, const modint& rhs) {return modint(lhs) += rhs;} friend modint operator-(const modint& lhs, const modint& rhs) {return modint(lhs) -= rhs;} friend modint operator*(const modint& lhs, const modint& rhs) {return modint(lhs) *= rhs;} friend modint operator/(const modint& lhs, const modint& rhs) {return modint(lhs) /= rhs;} friend ostream &operator<<(ostream &os,const modint &x) {return os << x.value;} }; /* using mint = modint<998244353>; */ using mint = modint<1000000007>; void Main() { int K,L,M,N; long long S; cin >> K >> L >> M >> N >> S; vector A(K),B(L),C(M),D(N); for(int i = 0;i < K;i++) { cin >> A[i]; } for(int i = 0;i < L;i++) { cin >> B[i]; } for(int i = 0;i < M;i++) { cin >> C[i]; } for(int i = 0;i < N;i++) { cin >> D[i]; } vector P,Q; for(int i = 0;i < K;i++) { for(int j = 0;j < L;j++) { int prod = A[i] * B[j]; P.push_back(prod); } } for(int i = 0;i < M;i++) { for(int j = 0;j < N;j++) { int prod = C[i] * D[j]; Q.push_back(prod); } } sort(P.begin(),P.end()); sort(Q.begin(),Q.end()); long long ng = -(long long)1e18,ok = (long long)1e18; while(ok - ng > 1) { long long mid = (ok + ng) / 2; long long cnt = 0; for(int i = 0;i < (int)P.size();i++) { int x = P[i]; if(x < 0) { //Q * x <= mid //Q * (-y) <= mid //Q >= - mid / y; int y = -x; long long cil = mid < 0 ? (-mid + y - 1) / y : -(mid / y); auto it = lower_bound(Q.begin(),Q.end(),cil); cnt += Q.end() - it; } else if(x == 0) { if(mid >= 0) { cnt += (int)Q.size(); } } else { long long flr = mid >= 0 ? mid / x : -((-mid + x - 1) / x); auto it = upper_bound(Q.begin(),Q.end(),flr); cnt += it - Q.begin(); } } if(cnt >= S) { ok = mid; } else { ng = mid; } } long long ans = ok; cout << ans << "\n"; map> mp; for(int i = 0;i < M;i++) { for(int j = 0;j < N;j++) { mp[C[i] * D[j]] = make_pair(C[i],D[j]); } } if(ans == 0) { if(mp.find(0) != mp.end()) { cout << A[0] << " " << B[0] << " " << mp[0].first << " " << mp[0].second << "\n"; } else { for(int i = 0;i < K;i++) { for(int j = 0;j < L;j++) { int prod = A[i] * B[j]; if(prod == 0) { cout << A[i] << " " << B[j] << " " << C[0] << " " << D[0] << "\n"; return; } } } assert(0); } } else { for(int i = 0;i < K;i++) { for(int j = 0;j < L;j++) { int prod = A[i] * B[j]; if(prod == 0) { continue; } if(ans % prod) { continue; } long long q = ans / prod; if(mp.find(q) != mp.end()) { cout << A[i] << " " << B[j] << " " << mp[q].first << " " << mp[q].second << "\n"; return; } } } assert(0); } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int tt = 1; /* cin >> tt; */ while(tt--) Main(); }