#include using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) template bool chmax(T &a, const T &b) { if(a bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;} //------------------------------------------------------- int A,B,C,D; ll S; ll V[4][1000]; ll Z[4]; vector> X[3],Y[3]; ll hoge(ll v,int a,int b) { ll ret=0; FORR(x,X[a]) { ll y=v/x.first; if(y*x.first<=v) y++; pair s={y,-1LL<<60}; int num=lower_bound(ALL(Y[b]),s)-Y[b].begin(); ret+=num; } return ret; } vector hoge2(ll v,int a,int b) { ll ret=0; FORR(x,X[a]) if(v%x.first==0) { ll y=v/x.first; pair s={y,-1LL<<60}; int num=lower_bound(ALL(Y[b]),s)-Y[b].begin(); if(num>A>>B>>C>>D>>S; FOR(i,A) { cin>>V[0][i]; if(V[0][i]==0) Z[0]=i; } FOR(i,B) { cin>>V[1][i]; if(V[1][i]==0) Z[1]=i; } FOR(i,C) { cin>>V[2][i]; if(V[2][i]==0) Z[2]=i; } FOR(i,D) { cin>>V[3][i]; if(V[3][i]==0) Z[3]=i; } int a,b,c,d; FOR(a,A) FOR(b,B) { ll c=V[0][a]*V[1][b]; ll v=(V[0][a]+50000)*100000+V[1][b]+50000; if(c<0) X[0].push_back({-c,v}); if(c==0) X[1].push_back({c,v}); if(c>0) X[2].push_back({c,v}); } FOR(a,C) FOR(b,D) { ll c=V[2][a]*V[3][b]; ll v=(V[2][a]+50000)*100000+V[3][b]+50000; if(c<0) Y[0].push_back({-c,v}); if(c==0) Y[1].push_back({c,v}); if(c>0) Y[2].push_back({c,v}); } FOR(i,3) sort(ALL(X[i])),sort(ALL(Y[i])); ll mi=X[0].size()*Y[2].size()+X[2].size()*Y[0].size(); ll pl=X[0].size()*Y[0].size()+X[2].size()*Y[2].size(); ll zero=1LL*A*B*C*D-mi-pl; if(S<=mi) { S=mi+1-S; ll ret=1LL<<60; for(i=59;i>=0;i--) if(hoge(ret-(1LL<=S) ret-=1LL< A=hoge2(ret,0,2); if(A.empty()) A=hoge2(ret,2,0); cout<<-A[0]<=0;i--) if(hoge(ret-(1LL<=S) ret-=1LL< A=hoge2(ret,0,0); if(A.empty()) A=hoge2(ret,2,2); cout<