// Complexity O(log(n)*log(m))
#include<bits/stdc++.h>
using namespace std;
#define f(i,x,y) for(int i = (x);i < (y);++i)
#define F(i,x,y) for(int i = (x);i > (y);--i)
int max(int a,int b){return (a > b?a:b);}
int min(int a,int b){return (a < b?a:b);}
int mod(int a){return (a > 0?a:((-1)*(a)));}
int indLess(int *arr,int sz,int val)// Assuming arr is sorted
{
if(arr[0] >= val)return (-1+1);
else
{
int s = 0,e = sz-1;
while((e-s)>1)
{
int m = (s+e)/2;
if(arr[m] < val){s = m;}
else if(arr[m] > val){e = m-1;}
else{;}
}
if(arr[e] < val)return e+1;
else return s+1;
}
}
int check(int *arr1,int *arr2,int sz1,int sz2,int k)
{
int val0 = indLess(arr1,sz1,arr2[0])+0+1;
if(val0 > k)return -1;
else
{
int s = 0,e = sz2-1;
while((e-s)> 1)
{
int m = (e+s)/2;
int valm = indLess(arr1,sz1,arr2[m])+m+1;
if(valm == k){return (m);}
else if(valm > k){e = m-1;}
else {s = m;}
}
int vale = indLess(arr1,sz1,arr2[e])+e+1;
if(vale <= k){return e;}
else {return s;}
}
}
int func(int *arr1,int *arr2,int sz1,int sz2,int k)
{
int *m;int ms;
int *M;int Ms;
if(arr1[sz1-1] >= arr2[sz2-1]){m = arr2,M = arr1;ms = sz2;Ms = sz1;}
else {m = arr1,M = arr2;ms = sz1;Ms = sz2;}
if(m[ms-1] <= M[0])
{
if(k <= ms)return m[k-1];
else return M[k-ms-1];
}
else//m[k-1] > M[0]
{
int p = check(m,M,ms,Ms,k);//return index
int a = indLess(m,ms,M[p]);// return num
int b = (k-(a+p+1));
if(b == 0)return M[p];
else return (m[a+b-1]);
}
}
int main()
{
int n,m,k;
cin >> n >> m >> k;
int arr1[n];
int arr2[m];
f(i,0,n)
cin >> arr1[i];
f(i,0,m)
cin >> arr2[i];
cout << func(arr1,arr2,n,m,k) << endl;
return 0;
}
Ly8gQ29tcGxleGl0eSAgICBPKGxvZyhuKSpsb2cobSkpCgoKI2luY2x1ZGU8Yml0cy9z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AgaWYodmFsbSA9PSBrKXtyZXR1cm4gKG0pO30KICAgICAgZWxzZSBpZih2YWxtID4gayl7ZSA9IG0tMTt9CiAgICAgIGVsc2Uge3MgPSBtO30KICAgIH0KICAgIGludCB2YWxlID0gaW5kTGVzcyhhcnIxLHN6MSxhcnIyW2VdKStlKzE7CiAgICBpZih2YWxlIDw9IGspe3JldHVybiBlO30KICAgIGVsc2Uge3JldHVybiBzO30KICB9Cn0KCgppbnQgZnVuYyhpbnQgKmFycjEsaW50ICphcnIyLGludCBzejEsaW50IHN6MixpbnQgaykKewogIGludCAqbTtpbnQgbXM7CiAgaW50ICpNO2ludCBNczsKICBpZihhcnIxW3N6MS0xXSA+PSBhcnIyW3N6Mi0xXSl7bSA9IGFycjIsTSA9IGFycjE7bXMgPSBzejI7TXMgPSBzejE7fQogIGVsc2Uge20gPSBhcnIxLE0gPSBhcnIyO21zID0gc3oxO01zID0gc3oyO30KICBpZihtW21zLTFdIDw9IE1bMF0pCiAgewogICAgaWYoayA8PSBtcylyZXR1cm4gbVtrLTFdOwogICAgZWxzZSByZXR1cm4gTVtrLW1zLTFdOwogIH0KICBlbHNlLy9tW2stMV0gPiBNWzBdCiAgewogICAgaW50IHAgPSBjaGVjayhtLE0sbXMsTXMsayk7Ly9yZXR1cm4gaW5kZXgKICAgIGludCBhID0gaW5kTGVzcyhtLG1zLE1bcF0pOy8vIHJldHVybiBudW0KICAgIGludCBiID0gKGstKGErcCsxKSk7CiAgICBpZihiID09IDApcmV0dXJuIE1bcF07CiAgICBlbHNlIHJldHVybiAobVthK2ItMV0pOwogIH0KfQoKCgoKaW50IG1haW4oKQp7CiAgaW50IG4sbSxrOwogIGNpbiA+PiBuID4+IG0gPj4gazsKICBpbnQgYXJyMVtuXTsKICBpbnQgYXJyMlttXTsKICBmKGksMCxuKQogICAgY2luID4+IGFycjFbaV07CiAgICBmKGksMCxtKQogICAgY2luID4+IGFycjJbaV07CiAgY291dCA8PCBmdW5jKGFycjEsYXJyMixuLG0saykgPDwgZW5kbDsKICByZXR1cm4gMDsKfQo=