#include <iostream>
#include <algorithm>
using namespace std;

int arr1[1000001];
int arr2[1000001];
int newArr[1000001];

int main() {
    int arr1Len, arr2Len;
    scanf("%d%d", &arr1Len, &arr2Len);
    for(int i = 0; i < arr1Len; i++){
        scanf("%d", &arr1[i]);
    }
    for(int i = 0; i < arr2Len; i++){
        scanf("%d", &arr2[i]);
    }

    int a, b, c, d;
    scanf("%d%d", &a, &b);
    scanf("%d%d", &c, &d);
    int index = 0;
    for(int i = a - 1; i <= b - 1; i++,index++){
        newArr[index] = arr1[i];
    }
    for(int i = c - 1; i <= d - 1; i++,index++){
        newArr[index] = arr2[i];
    }
    //此时index为新数组的长度
    if(index % 2 == 0){ //偶数
        printf("%d\n", newArr[index / 2 - 1]);
    }else{ //奇数
        printf("%d\n", newArr[index / 2]);
    }
  
}
// 64 位输出请用 printf("%lld")