/*Greedy解法*/ #include #include #include #include using namespace std; using ll = long long; void input(vector& X) { for (int i = 0; i < X.size(); i++) { cin >> X.at(i); } } pair h(ll x, vector G, vector H) { if (x == 0) { if (find(G.begin(), G.end(), 0) != G.end()) { return make_pair(0, H[0]); } else { return make_pair(G[0], 0); } } set F(H.begin(), H.end()); for (auto g : G) { if (g == 0) continue; if (x % g == 0 && F.count(x / g)) { return make_pair(g, x / g); } } return make_pair(-1, -1); } int main() { ll K, L, M, N, S, T; cin >> K >> L >> M >> N >> S; vector A(K), B(L), C(M), D(N); vector U(0), V(0), E(0); input(A); input(B); input(C); input(D); for (auto a : A) { for (auto b : B) { U.push_back(a * b); } } for (auto c : C) { for (auto d : D) { V.push_back(c * d); } } for (auto u : U) { for (auto v : V) { E.push_back(u * v); } } sort(E.begin(), E.end()); T = E[S - 1]; ll alpha, beta, a, b, c, d; pair P; P = h(T, U, V); alpha = P.first; beta = P.second; P = h(alpha, A, B); a = P.first; b = P.second; P = h(beta, C, D); c = P.first; d = P.second; cout << T << endl; cout << a << " " << b << " " << c << " " << d << endl; return 0; }