#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MAXN 250025
int T,n,Q;
ull a[MAXN],b[MAXN],ans;
int main()
{
	freopen("match.in","r",stdin);
	freopen("match.out","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>T>>n;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;++i)
	{
		cin>>b[i];
	}
	cin>>Q;
	for(int i=1,l,r;i<=1;++i)
	{
		ull ans=0;
		cin>>l>>r;
		for(int p=l;p<=r;++p)
		{
			ull maxa=a[p],maxb=b[p];
			for(int q=p;q<=r;++q)
			{
				maxa=max(maxa,a[q]);
				maxb=max(maxb,b[q]);
				ans+=maxa*maxb;
			}
		}
		cout<<ans;
	}
}
/*
0 2
2 1
1 2
1
1 2
*/
