#include<bits/stdc++.h>

using namespace std;

int T,n;
int Q;
long long a[250100],b[250100];

int main()
{
	freopen("match.in","r",stdin);
	freopen("match.out","w",stdout);
	
	scanf("%d%d",&T,&n);
	
	for (int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for (int i=1;i<=n;i++)
	{
		scanf("%lld",&b[i]);
	}
	
	int l,r;
	long long maxa,Ans=0,maxb;
	scanf("%d",&Q);
	for (int i=1;i<=Q;i++)
	{
		scanf("%d%d",&l,&r);
		
		for (int p=l;p<=r;p++)
		{
			for (int q=p;q<=r;q++)
			{
				maxa=a[p];
				maxb=b[p];
				for (int j=p+1;j<=q;j++)
				{
					maxa=max(maxa,a[j]);
					maxb=max(maxb,b[j]);
				}
				
				Ans+=maxa*maxb;
			}
		}
	}
	
	printf("%lld",Ans);
	
	return 0;
}