#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
const int N=5e5+5;
int n;
int a[N],b[N];
int sta[N],stb[N];
int topa,topb;
ull suma[N],sumb[N];
int main() {
	freopen("match.in","r",stdin);
	freopen("match.out","w",stdout);
	int koishi;
	scanf("%d%d",&koishi,&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) scanf("%d",&b[i]);
	int q;
	scanf("%d",&q);
	while(q--) {
		int l,r;
		scanf("%d%d",&l,&r);
		ull ans=0;
		topa=topb=0;
		suma[l-1]=sumb[l-1]=0;
		sta[0]=l-1;
		stb[0]=l-1;
		for(int i=l;i<=r;i++) {
			suma[l-1]=sumb[l-1]=0;
			
			while(topa&&a[sta[topa]]<a[i]) topa--;
			topa++;
			sta[topa]=i;
			while(topb&&a[stb[topb]]<b[i]) topb--;
			topb++;
			stb[topb]=i;
			
			suma[i]=suma[sta[topa-1]]+a[i]*(i-sta[topa-1]);
			sumb[i]=sumb[stb[topb-1]]+b[i]*(i-stb[topb-1]);
			
			
			ull num=0,num2=0;
			if(topa==1||(topb!=1&&sta[topa-1]<stb[topb-1])) {
				int p=sta[topa-1];
				num+=a[i]*b[i]*(i-stb[topb-1]);
				int t=lower_bound(stb+1,stb+topb+1,p)-stb;
//				cerr<<t<<endl;
				num2=sumb[stb[topb-1]]-sumb[stb[t]]+b[stb[t]]*(stb[t]-p+1);
				num2=num2*a[i];
				ans+=num;
				if(t==1) continue;
				ans+=num2;
//				cerr<<ans<<endl;
			}
			else {
				int p=stb[topb-1];
				num+=a[i]*b[i]*(i-sta[topa-1]);
				int t=lower_bound(sta+1,sta+topa+1,p)-sta;
				num2=suma[sta[topa-1]]-suma[sta[t]]+a[sta[t]]*(sta[t]-p+1);
				num2=num2*b[i];
				ans+=num;
				if(t==1) continue;
				ans+=num2;
			}
		}
		printf("%u\n",ans);
	}
	return 0;
}
