#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=200010;
const int mod=19260817;
typedef long long ll;
ll n,m,d[maxn],s[maxn],s1[maxn],b[maxn],x[maxn];
inline ll read(){
ll num=0,flag=1; char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-') flag=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9') num=num*10+ch-'0',ch=getchar();
return flag*num;
}
int main(){
n=read(),m=read();
for(int i=2;i<=n;i++){
d[i]=read();
}
for(int i=1;i<=n;i++) b[i]=read();
x[1]=1;
for(int i=2;i<=n;i++){
x[i]=x[i-1]+d[i];
}
for(int i=1;i<=n;i++){
s[i]=s[i-1]+b[i];
s[i]%=mod;
s1[i]=s1[i-1]+(b[i]*x[i])%mod;
s1[i]%=mod;
}
/*for(int i=1;i<=n;i++) cout<<x[i]<<' ';
cout<<endl;
for(int i=1;i<=n;i++) cout<<s[i]<<' ';
cout<<endl;
for(int i=1;i<=n;i++) cout<<s1[i]<<' ';
cout<<endl;*/
ll l,r,xx,ans;
for(int i=1;i<=m;i++){
xx=read(),l=read(),r=read();
ans=0;
if(xx<=l){
ans=ans%mod+(s1[r]-s1[l-1])%mod;
ans%=mod;
ans=(ans%mod-((s[r]-s[l-1])%mod*x[xx]%mod)%mod+mod)%mod;
}
else if(xx>=r){
ans=(ans%mod+((s[r]-s[l-1])%mod*x[xx]%mod)%mod)%mod;
ans=(ans%mod-(s1[r]-s1[l-1])%mod
)%mod;
}
else{
ans=(ans%mod+(s1[r]-s1[xx])%mod)%mod;
ans=(ans%mod-(s[r]-s[xx])%mod*x[xx]%mod)%mod;
ans=(ans+((s[xx-1]-s[l-1])%mod*x[xx]%mod)%mod)%mod;
ans=(ans%mod-(s1[xx-1]-s1[l-1])%mod)%mod;
}
cout<<ans<<endl;
}
return 0;
}
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=200010;
const int mod=19260817;
typedef long long ll;
ll n,m,d[maxn],s[maxn],s1[maxn],b[maxn],x[maxn];
inline ll read(){
ll num=0,flag=1; char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-') flag=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9') num=num*10+ch-'0',ch=getchar();
return flag*num;
}
int main(){
n=read(),m=read();
for(int i=2;i<=n;i++){
d[i]=read();
}
for(int i=1;i<=n;i++) b[i]=read();
x[1]=1;
for(int i=2;i<=n;i++){
x[i]=x[i-1]+d[i];
}
for(int i=1;i<=n;i++){
s[i]=s[i-1]+b[i];
s[i]%=mod;
s1[i]=s1[i-1]+(b[i]*x[i])%mod;
s1[i]%=mod;
}
/*for(int i=1;i<=n;i++) cout<<x[i]<<' ';
cout<<endl;
for(int i=1;i<=n;i++) cout<<s[i]<<' ';
cout<<endl;
for(int i=1;i<=n;i++) cout<<s1[i]<<' ';
cout<<endl;*/
ll l,r,xx,ans;
for(int i=1;i<=m;i++){
xx=read(),l=read(),r=read();
ans=0;
if(xx<=l){
ans=ans%mod+(s1[r]-s1[l-1])%mod;
ans%=mod;
ans=(ans%mod-((s[r]-s[l-1])%mod*x[xx]%mod)%mod+mod)%mod;
}
else if(xx>=r){
ans=(ans%mod+((s[r]-s[l-1])%mod*x[xx]%mod)%mod)%mod;
ans=(ans%mod-(s1[r]-s1[l-1])%mod
)%mod;
}
else{
ans=(ans%mod+(s1[r]-s1[xx])%mod)%mod;
ans=(ans%mod-(s[r]-s[xx])%mod*x[xx]%mod)%mod;
ans=(ans+((s[xx-1]-s[l-1])%mod*x[xx]%mod)%mod)%mod;
ans=(ans%mod-(s1[xx-1]-s1[l-1])%mod)%mod;
}
cout<<ans<<endl;
}
return 0;
}