#include<iostream>
#include<cstdio>

#define int unsigned long long
using namespace std;

const int maxn = 1e6 + 5;

int t,n,a[maxn],b[maxn],p[maxn],q[maxn];
long long o;


signed main() {
	freopen("match.in","r",stdin);
	freopen("match.out","w",stdout);
	scanf("%lld %llu",&o,&n);
	
	for (int i=1; i<=n; i++)
		scanf("%llu",&a[i]);
	for (int i=1; i<=n; i++)
		scanf("%llu",&b[i]);
	scanf("%llu",&t);
		
	for (int i=1; i<n; i++) {
		for (int j=i + 1; j<=n; j++)
			if (a[j] > a[i]) {
				p[i] = j;
				break;
			}
		for (int j=i + 1; j<=n; j++)
			if (b[j] > b[i]) {
				q[i] = j;
				break;
			}
	}
	for (int i=1; i<=n; i++) {
		if (p[i] == 0)
			p[i] = n + 1;
		if (q[i] == 0)
			q[i] = n + 1;
	}
	

	while (t--) {
		int l,r;
		scanf("%llu %llu",&l,&r);
		int ans = 0;
		for (int i=l; i<=r; i++) {
			int tmp1 = i,tmp2 = i,last = i;
			while (tmp1 <= r && tmp2 <= r) {
				int tmp3 = p[tmp1],tmp4 = q[tmp2];
				int en;
				if (tmp3 < tmp4)
					en = tmp3; else
					en = tmp4;
				if (en > r)
					en = r + 1;
				ans = (ans + (en - last) * a[tmp1] * b[tmp2]);
				last = en;
				if (tmp3 < tmp4)
					tmp1 = tmp3; else
					tmp2 = tmp4;
					
			}
		}
		printf("%llu\n",ans);	
	}
	
	return 0;
}