#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define gg exit(0);
const int N=500010;
int n,m;
int a[N],b[N];
long long sa[N],sb[N];
struct pack{
long long x,y;
int qn;
};
struct fenwick{
long long tot=0;
vector<long long> val;
vector<pair<long long,long long>> pf;
vector<pack> bit;
void add(long long i,long long j){
val.pb(i-j);
pf.pb({i,j});
tot+=j;
}
void upd(long long i,long long x,long long y){
i=lower_bound(all(val),i)-val.begin()+1;
for(;i;i-=i&-i){
bit[i].x+=x;
bit[i].y+=y;
bit[i].qn+=1;
}
}
pack que(long long i){
i=lower_bound(all(val),i)-val.begin()+1;
long long x=0,y=0; int qn=0;
for(;i<=val.size();i+=i&-i){
x+=bit[i].x;
y+=bit[i].y;
qn+=bit[i].qn;
}
return {x,y,qn};
}
void build(){
sort(all(val)); val.erase(unique(all(val)),val.end());
bit.resize(val.size()+1);
forv(i,pf) upd(i.fi-i.se,i.fi,i.se);
}
}T[N*4];
void dfs1(int s,int l,int r){
if(l<r){
int m=(l+r)/2;
dfs1(2*s,l,m); dfs1(2*s+1,m+1,r);
}
forinc(i,l,r) T[s].add(sa[i]-sa[l-1],sb[i]-sb[l-1]);
T[s].build();
}
long long pa,pb,ret;
void dfs2(int s,int l,int r,int u,int v){
if(l>v||u>r) return;
if(u<=l&&r<=v){
long long diff=pa-pb;
pack i=T[s].que(-diff);
ret+=i.x + pa * i.qn;
ret+=T[s].tot-i.y + pb * (r-l+1-i.qn);
pa+=sa[r]-sa[l-1];
pb+=sb[r]-sb[l-1];
return;
}
int m=(l+r)/2;
dfs2(2*s,l,m,u,v); dfs2(2*s+1,m+1,r,u,v);
}
main(){
#define task "TASK"
//freopen(task".inp","r",stdin);
//freopen(task".out","w",stdout);
n=in,m=in;
forinc(i,1,n) sa[i]=sa[i-1]+(a[i]=in);
forinc(i,1,n) sb[i]=sb[i-1]+(b[i]=in);
dfs1(1,1,n);
forinc(i,1,m){
int l=in,r=in; pa=pb=ret=0;
dfs2(1,1,n,l,r);
cout<<ret<<"\n";
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgaW4gKHtpbnQgeD0wO2ludCBjPWdldGNoYXIoKSxuPTA7Zm9yKDshaXNkaWdpdChjKTtjPWdldGNoYXIoKSkgbj0oYz09Jy0nKTtmb3IoO2lzZGlnaXQoYyk7Yz1nZXRjaGFyKCkpIHg9eCoxMCtjLScwJztuPy14Ong7fSkKbXQxOTkzNyBybmcoY2hyb25vOjpzdGVhZHlfY2xvY2s6Om5vdygpLnRpbWVfc2luY2VfZXBvY2goKS5jb3VudCgpKTsKaW50IHJuZChpbnQgbCxpbnQgcil7cmV0dXJuIGwrcm5nKCklKHItbCsxKTt9CiNkZWZpbmUgZmFzdHkgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKSxjaW4udGllKDApOwojZGVmaW5lIGZvcmluYyhhLGIsYykgZm9yKGludCBhPWIsX2M9YzthPD1fYzsrK2EpCiNkZWZpbmUgZm9yZGVjKGEsYixjKSBmb3IoaW50IGE9YixfYz1jO2E+PV9jOy0tYSkKI2RlZmluZSBmb3J2KGEsYikgZm9yKGF1dG8mYTpi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2ldLnkrPXk7CiAgICAgICAgICAgIGJpdFtpXS5xbis9MTsKICAgICAgICB9CiAgICB9CiAgICBwYWNrIHF1ZShsb25nIGxvbmcgaSl7CiAgICAgICAgaT1sb3dlcl9ib3VuZChhbGwodmFsKSxpKS12YWwuYmVnaW4oKSsxOwogICAgICAgIGxvbmcgbG9uZyB4PTAseT0wOyBpbnQgcW49MDsKICAgICAgICBmb3IoO2k8PXZhbC5zaXplKCk7aSs9aSYtaSl7CiAgICAgICAgICAgIHgrPWJpdFtpXS54OwogICAgICAgICAgICB5Kz1iaXRbaV0ueTsKICAgICAgICAgICAgcW4rPWJpdFtpXS5xbjsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHt4LHkscW59OwogICAgfQogICAgdm9pZCBidWlsZCgpewogICAgICAgIHNvcnQoYWxsKHZhbCkpOyB2YWwuZXJhc2UodW5pcXVlKGFsbCh2YWwpKSx2YWwuZW5kKCkpOwogICAgICAgIGJpdC5yZXNpemUodmFsLnNpemUoKSsxKTsKICAgICAgICBmb3J2KGkscGYpIHVwZChpLmZpLWkuc2UsaS5maSxpLnNlKTsKICAgIH0KfVRbTio0XTsKIAp2b2lkIGRmczEoaW50IHMsaW50IGwsaW50IHIpewogICAgaWYobDxyKXsKICAgICAgICBpbnQgbT0obCtyKS8yOwogICAgICAgIGRmczEoMipzLGwsbSk7IGRmczEoMipzKzEsbSsxLHIpOwogICAgfQogICAgZm9yaW5jKGksbCxyKSBUW3NdLmFkZChzYVtpXS1zYVtsLTFdLHNiW2ldLXNiW2wtMV0pOwogICAgVFtzXS5idWlsZCgpOwp9CiAKbG9uZyBsb25nIHBhLHBiLHJldDsKIAp2b2lkIGRmczIoaW50IHMsaW50IGwsaW50IHIsaW50IHUsaW50IHYpewogICAgaWYobD52fHx1PnIpIHJldHVybjsKICAgIGlmKHU8PWwmJnI8PXYpewogICAgICAgIGxvbmcgbG9uZyBkaWZmPXBhLXBiOwogICAgICAgIHBhY2sgaT1UW3NdLnF1ZSgtZGlmZik7CiAgICAgICAgcmV0Kz1pLnggKyBwYSAqIGkucW47CiAgICAgICAgcmV0Kz1UW3NdLnRvdC1pLnkgKyBwYiAqIChyLWwrMS1pLnFuKTsKICAgICAgICBwYSs9c2Fbcl0tc2FbbC0xXTsKICAgICAgICBwYis9c2Jbcl0tc2JbbC0xXTsKICAgICAgICByZXR1cm47CiAgICB9CiAgICBpbnQgbT0obCtyKS8yOwogICAgZGZzMigyKnMsbCxtLHUsdik7IGRmczIoMipzKzEsbSsxLHIsdSx2KTsKfQogCm1haW4oKXsKICAgICNkZWZpbmUgdGFzayAiVEFTSyIKICAgIC8vZnJlb3Blbih0YXNrIi5pbnAiLCJyIixzdGRpbik7CiAgICAvL2ZyZW9wZW4odGFzayIub3V0IiwidyIsc3Rkb3V0KTsKIAogICAgbj1pbixtPWluOwogICAgZm9yaW5jKGksMSxuKSBzYVtpXT1zYVtpLTFdKyhhW2ldPWluKTsKICAgIGZvcmluYyhpLDEsbikgc2JbaV09c2JbaS0xXSsoYltpXT1pbik7CiAKICAgIGRmczEoMSwxLG4pOwogICAgZm9yaW5jKGksMSxtKXsKICAgICAgICBpbnQgbD1pbixyPWluOyBwYT1wYj1yZXQ9MDsKICAgICAgICBkZnMyKDEsMSxuLGwscik7CiAgICAgICAgY291dDw8cmV0PDwiXG4iOwogICAgfQp9