#pragma GCC target("avx2") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include using namespace std; const long long INF = 1000000000000000000; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int K, L, M, N; long long S; cin >> K >> L >> M >> N >> S; vector A(K); for (int i = 0; i < K; i++){ cin >> A[i]; } vector B(L); for (int i = 0; i < L; i++){ cin >> B[i]; } vector C(M); for (int i = 0; i < M; i++){ cin >> C[i]; } vector D(N); for (int i = 0; i < N; i++){ cin >> D[i]; } vector X(K * L); for (int i = 0; i < K; i++){ for (int j = 0; j < L; j++){ X[i * L + j] = A[i] * B[j]; } } vector Y(M * N); for (int i = 0; i < M; i++){ for (int j = 0; j < N; j++){ Y[i * N + j] = C[i] * D[j]; } } sort(Y.begin(), Y.end()); long long tv = -INF; long long fv = INF; while (fv - tv > 1){ long long mid = (tv + fv) / 2; long long cnt = 0; for (int i = 0; i < K * L; i++){ if (X[i] >= 0){ int tv2 = -1; int fv2 = N * M; while (fv2 - tv2 > 1){ int mid2 = (tv2 + fv2) / 2; if (X[i] * Y[mid2] < mid){ tv2 = mid2; } else { fv2 = mid2; } } cnt += fv2; } else { int tv2 = N * M; int fv2 = -1; while (tv2 - fv2 > 1){ int mid2 = (tv2 + fv2) / 2; if (X[i] * Y[mid2] < mid){ tv2 = mid2; } else { fv2 = mid2; } } cnt += N * M - tv2; } } if (cnt < S){ tv = mid; } else { fv = mid; } } cout << tv << endl; for (int i = 0; i < K * L; i++){ int id = -1; if (X[i] >= 0){ int tv2 = -1; int fv2 = N * M; while (fv2 - tv2 > 1){ int mid2 = (tv2 + fv2) / 2; if (X[i] * Y[mid2] <= tv){ tv2 = mid2; } else { fv2 = mid2; } } if (tv2 != -1){ if (X[i] * Y[tv2] == tv){ id = tv2; break; } } } else { int tv2 = N * M; int fv2 = -1; while (tv2 - fv2 > 1){ int mid2 = (tv2 + fv2) / 2; if (X[i] * Y[mid2] <= tv){ tv2 = mid2; } else { fv2 = mid2; } } if (tv2 != N * M){ if (X[i] * Y[tv2] == tv){ id = tv2; break; } } } if (id != -1){ bool ok1 = false; for (int j = 0; j < K; j++){ for (int k = 0; k < L; k++){ if (A[j] * B[k] == X[i]){ cout << A[j] << ' ' << B[k] << ' '; ok1 = true; break; } } if (ok1){ break; } } bool ok2 = false; for (int j = 0; j < M; j++){ for (int k = 0; k < N; k++){ if (C[j] * D[k] == Y[id]){ cout << C[j] << ' ' << D[k] << endl; ok2 = true; break; } } if (ok2){ break; } } break; } } }