#include <iostream>
#include <algorithm>
#include <cmath>
#define maxn 1000010
using namespace std;
int n1[maxn],n2[maxn];

int main() {
    int l1,l2;
    cin>>l1>>l2;
    for(int i=0;i<l1;i++)cin>>n1[i];
    for(int i=0;i<l2;i++)cin>>n2[i];
    int a,b,c,d;
    cin>>a>>b;
    a--;b--;
    cin>>c>>d;
    c--;d--;
    for(int i=0;i<=b-a;i++)
    {
        n1[i] = n1[i+a];
    }
    int now = b-a+1;
    for(int i=c;i<=d;i++)
    {
        n1[now++] = n2[i];
    }
    now--;
    cout<<n1[now/2]<<endl;



    
}
// 64 位输出请用 printf("%lld")