#include #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; typedef long long ll; int main() { ll K, N; cin >> K >> N; vector A(K * 2, -1e18), B(K); rep(i, K) cin >> A[i]; rep(i, K) cin >> B[i]; for (int i = K; i < K * 2; i++) { rep(j, K) { A[i] = max(A[i], min(A[i - K + j], B[j])); } } if (N < K * 2) cout << A[N] << "\n"; else cout << A[K + N % K] << "\n"; }