#include #include #include using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000000000000001 vector get(vector a,vector b){ long long m = -Inf; rep(i,a.size()){ m = max(m,min(a[i],b[i])); } a.push_back(m); a.erase(a.begin()); return a; } int main(){ long long K,N; cin>>K>>N; vector A(K),B(K); rep(i,K)cin>>A[i]; rep(i,K)cin>>B[i]; if(N1LL){ long long mid = (ok+ng)/2; vector a(K),b(K); rep(i,K){ if(A[i]>=mid){ a[i] = 1; } else{ a[i] = 0; } if(B[i]>=mid){ b[i] = 1; } else{ b[i] = 0; } } long long n = N; vector> temp(1,a); bool f = false; while(true){ if(n==0){ f=true; if(temp.back().back())ok = mid; else ng = mid; break; } n--; auto t = get(temp.back(),b); rep(i,temp.size()){ if(temp[i]==t){ temp.erase(temp.begin(),temp.begin()+i); goto L; } } } L:; if(!f){ if(temp[n%temp.size()].back())ok = mid; else ng = mid; } } cout<