//Teio Mcqueen Tie Tie
#include<bits/stdc++.h>
#define ull unsigned long long
using namespace std;
inline int read()
{
	char c=getchar();
	int x=0;
	while(!isdigit(c)) c=getchar();
	while(isdigit(c)) x=x*10+(c&15),c=getchar();
	return x;
}
int a[250003],b[250003],ls[250003],rs[250003],stk[250003],top;
int f[60][250003],to[60][250003];
ull pre[60][250003],val[60][250003],g[250003];
void dfs(int l,int r,int x,int dep=0)
{
	f[dep][x]=pre[dep][x]=b[x];
	for(int i=x-1,cur=b[x]; i>=l; --i)
		cur=max(cur,b[i]),f[dep][i]=cur,
		pre[dep][i]=pre[dep][i+1]+f[dep][i];
	for(int i=x+1,cur=b[x]; i<=r; ++i)
		cur=max(cur,b[i]),f[dep][i]=cur,
		pre[dep][i]=pre[dep][i-1]+f[dep][i];
	int i=x,j=x;
	to[dep][x]=x,val[dep][x]=b[x];
	ull cur=b[x];
	while(i>l&&j<r)
	{
		if(f[dep][i-1]<=f[dep][j+1])
			cur+=1ull*f[dep][--i]*(j-x+1),
			to[dep][i]=j,val[dep][i]=cur;
		else
			cur+=1ull*f[dep][++j]*(x-i+1),
			to[dep][j]=i,val[dep][j]=cur;
	}
	while(i>l)
		cur+=1ull*f[dep][--i]*(j-x+1),
		to[dep][i]=j,val[dep][i]=cur;
	while(j<r)
		cur+=1ull*f[dep][++j]*(x-i+1),
		to[dep][j]=i,val[dep][j]=cur;
	g[x]=1ull*a[x]*cur;
	if(ls[x]) dfs(l,x-1,ls[x],dep+1),g[x]+=g[ls[x]];
	if(rs[x]) dfs(x+1,r,rs[x],dep+1),g[x]+=g[rs[x]];
	return ;
}
ull query(int nl,int nr,int l,int r,int x,int dep=0)
{
	ull ans=0;
	if(l==nl&&nr==r) return g[x];
	if(l<x) ans+=query(nl,x-1,l,min(r,x-1),ls[x],dep+1);
	if(r>x) ans+=query(x+1,nr,max(l,x+1),r,rs[x],dep+1);
	if(l>x||r<x) return ans;
	if(f[dep][l]<=f[dep][r])
		ans+=1ull*a[x]*val[dep][l]+
		1ull*a[x]*(pre[dep][r]-pre[dep][to[dep][l]])*(x-l+1);
	else
		ans+=1ull*a[x]*val[dep][r]+
		1ull*a[x]*(pre[dep][l]-pre[dep][to[dep][r]])*(r-x+1);
	return ans;
}
signed main()
{
#ifndef local
	freopen("match.in","r",stdin),
	freopen("match.out","w",stdout);
#endif
	int sub=read(),n=read();
	for(int i=1; i<=n; ++i) a[i]=read();
	for(int i=1; i<=n; ++i) b[i]=read();
	for(int i=1; i<=n; ++i)
	{
		while(top&&a[i]>=a[stk[top]])
			ls[i]=stk[top--];
		if(top) rs[stk[top]]=i;
		stk[++top]=i;
	}
	dfs(1,n,stk[1]);
	for(int T=read(); T--;)
	{
		int l=read(),r=read();
		printf("%llu\n",query(1,n,l,r,stk[1]));
	}
	return 0;
}