#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
struct SEG
{
	ull sum[1000010], tg[1000010];
	#define lc(u) (u << 1)
	#define rc(u) (u << 1 | 1)
	inline void Build(int u, int l, int r)
	{
		sum[u] = tg[u] = 0;
		if(l == r)
			return;
		int mid = (l + r) >> 1;
		Build(lc(u), l, mid), Build(rc(u), mid + 1, r);
	}
	inline void pushup(int u)
	{
		sum[u] = sum[lc(u)] + sum[rc(u)];
	}
	inline void pushdown(int u, int l, int r)
	{
		if(!tg[u])
			return;
		int mid = (l + r) >> 1;
		sum[lc(u)] = tg[u] * (mid - l + 1);
		tg[lc(u)] = tg[u];
		sum[rc(u)] = tg[u] * (r - mid);
		tg[rc(u)] = tg[u];
	}
	inline void Modify(int u, int l, int r, int L, int R, ull x)
	{
		if(r < L || R < l)
			return;
		if(L <= l && r <= R)
		{
			tg[u] = x, sum[u] = x * (r - l + 1);
			return;
		}
		pushdown(u, l, r);
		int mid = (l + r) >> 1;
		Modify(lc(u), l, mid, L, R, x), Modify(rc(u), mid + 1, r, L, R, x);
		pushup(u);
	}
	inline ull Query(int u, int l, int r, int L, int R)
	{
		if(r < L || R < l)
			return 0;
		if(L <= l && r <= R)
			return sum[u];
		pushdown(u, l, r);
		int mid = (l + r) >> 1;
		ull ans = Query(lc(u), l, mid, L, R) + Query(rc(u), mid + 1, r, L, R);
		pushup(u);
		return ans;
	}
}A, B;
int a[250010], b[250010];
int main()
{
	freopen("D.in", "r", stdin);
	freopen("D.out", "w", stdout);
	int _id, n;
	scanf("%d %d", &_id, &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, tot = 0;
		stack< pair<int, int> > as, bs; // val, pos
		A.Build(1, 1, n), B.Build(1, 1, n);
		as.push({n + 1, r + 1}), bs.push({n + 1, r + 1});
		for(int i = r; i >= l; i--)
		{
			while(a[i] > as.top().first)
			{
				int pos = as.top().second, val = as.top().first;
				as.pop();
				int nxt = as.top().second, dt = a[i] - val;
				tot += dt * B.Query(1, 1, n, pos, nxt - 1);
				A.Modify(1, 1, n, pos, nxt - 1, a[i]);
			}
			as.push({a[i], i});
			A.Modify(1, 1, n, i, i, a[i]);
			while(b[i] > bs.top().first)
			{
				int pos = bs.top().second, val = bs.top().first;
				bs.pop();
				int nxt = bs.top().second, dt = b[i] - val;
				tot += dt * A.Query(1, 1, n, pos, nxt - 1);
				B.Modify(1, 1, n, pos, nxt - 1, b[i]);
			}
			bs.push({b[i], i});
			B.Modify(1, 1, n, i, i, b[i]);
			tot += a[i] * b[i];
			ans += tot;
		}
		printf("%llu\n", ans);
	}
	return 0;
}