#include<bits/stdc++.h>
using namespace std;
#define int unsigned long long
#define ll long long
#define up(i,x,y) for(int i=x,i##E=y;i<=i##E;i++)
#define pu(i,x,y) for(int i=x,i##E=y;i>=i##E;i--)
#define up_(x) up(i,1,x)
#define mc cerr<<"qwq\n"
#define edl puts("")
#define pii pair<int,int>
#define mkp make_pair
#define ep push_back
#define vi vector<int>
#define upn up(i,1,n)
#define upm up(j,1,m)
const int maxn=2.5e5+10;
int a[maxn],b[maxn],l,r;
ll q;
int mx1[3030][3030],qw[3030][3030],mx2[3030][3030];
signed main()
{
	freopen("match.in","r",stdin);
	freopen("match.out","w",stdout);
	int T,n;
//	cout<<sizeof(T);edl;
	scanf("%llu%llu",&T,&n);
	upn scanf("%llu",&a[i]);
	upn scanf("%llu",&b[i]);
	scanf("%lld",&q);
//	mc;
	if(T<=5)
	{
		up(i,1,n)
		{
			mx1[i][i]=a[i];
			mx2[i][i]=b[i];
			up(j,i+1,n)
			{
				mx1[i][j]=max(mx1[i][j-1],a[j]);
				mx2[i][j]=max(mx2[i][j-1],b[j]);
			}
		}
		up(i,1,n)
		{
			qw[i][i]=a[i]*b[i];
			up(j,i+1,n)
			{
				qw[i][j]=qw[i][j-1]+mx1[i][j]*mx2[i][j];
			}
		}
		while(q--)
		{
			int ans=0;scanf("%llu%llu",&l,&r);
			up(i,l,r)
			{
				ans+=qw[i][r];
			}
			cout<<ans;edl;
		}
		return 0;
	}
	while(q--)
	{
		scanf("%llu%llu",&l,&r);
		up(i,l,r)
		{
			
		}
	}
	return 0;
}
