http://ac.jobdu.com/problem.php?pid=1097
#include<stdio.h>
int aa[1000000],bb[1000000],cc[1000000];int main()
{
int i,j,a,b,c,d,n,na,nb;
while(scanf("%d",&n)!=EOF){
while(n--){
scanf("%d %d",&na,&nb);
for(i=0;i<na;i++) scanf("%d",&aa[i]);
for(i=0;i<nb;i++) scanf("%d",&bb[i]);
scanf("%d %d",&a,&b);
scanf("%d %d",&c,&d);
j=0;
for(i=a-1;i<=b-1;i++) cc[j++]=aa[i];
for(i=c-1;i<=d-1;i++) cc[j++]=bb[i];
if(j%2!=0) printf("%d\n",cc[j/2]);
else printf("%d\n",cc[j/2-1]);
}
}
system("pause");
return 0;
}