#include <iostream>
#include <string.h>
#include <vector>
#include <set>
using namespace std;
struct E{
long long int num,no;
bool commit;
};
struct E2{
int l,r,x,y,z;
};
const int maxS=600000;
int R=262143;
int no0=0;
vector<E2> copyData;
vector<long long int> areaSum;
E segA[maxS];
long long int fSegASet(int no,int p1,int l2,int r2,long long int num){
if(r2<p1 || p1<l2)return segA[no].num;
if(l2==r2){
segA[no].num=num;
return segA[no].num;
}
int m=(l2+r2)/2;
long long int res=fSegASet(no*2+1,p1,l2,m,num);
res+=fSegASet(no*2+2,p1,m+1,r2,num);
segA[no].num=res;
return res;
}
long long int calc(int no,int no2,int no3,int l,int r,int l2,int r2,bool commit){
//cout<<"<"<<commit<<" "<<no<<",no2="<<no2<<",no3="<<no3<<",l="<<l<<",r="<<r<<","<<l2<<","<<r2<<",>";
E2 e2=copyData[no2];
if(commit==true){
//cout<<1<<" "<<segA[no].num<<endl;
return segA[no].num;
}else{
if(e2.x<=l2 && r2<=e2.x+e2.z){
int l3=e2.y+(l2-e2.x);
int r3=l3+(r2-l2)+1;
long long int t=areaSum[r3]-areaSum[l3];
return t;
}
e2=copyData[no3];
//cout<<3<<e2.x<<" "<<e2.z<<endl;
return areaSum[e2.x+e2.z]-areaSum[e2.x];
}
}
long long int fSegACalcAns(int no,int l,int r,int l2,int r2,int no2,bool commit){
commit=commit && segA[no].commit;
no2=(no2<segA[no].no)?segA[no].no:no2;
long long int res=calc(no,no2,no2,l,r,l2,r2,commit);
if(r2<l || r<l2){
return 0;
}
if(l<=l2 && r2<=r){
return res;
}else{
int m=(l2+r2)/2;
res=fSegACalcAns(no*2+1,l,r,l2,m,no2,commit);
res+=fSegACalcAns(no*2+2,l,r,m+1,r2,no2,commit);
return res;
}
}
long long int fSegAUpData(int no,int l,int r,int l2,int r2,int no2,int no3,bool commit){
commit=commit && segA[no].commit;
no3=(no3<segA[no].no)?segA[no].no:no3;
long long int res=calc(no,no3,no3,l,r,l2,r2,commit);
if(r2<l || r<l2){
return res;
}
res=calc(no,no2,no2,l,r,l2,r2,false);
if(l2==r2){
segA[no].no=no2;
segA[no].num=res;
return res;
}
if(l<=l2 && r2<=r){
segA[no].no=no2;
segA[no].num=res;
segA[no].commit=true;
segA[no*2+1].commit=false;
segA[no*2+2].commit=false;
return res;
}else{
int m=(l2+r2)/2;
res=fSegAUpData(no*2+1,l,r,l2,m,no2,no3,commit);
res+=fSegAUpData(no*2+2,l,r,m+1,r2,no2,no3,commit);
segA[no].num=res;
segA[no].commit=true;
return res;
}
}
int main() {
for(int i=0;i<maxS;i++){
segA[i].num=0;
segA[i].no=-1;
segA[i].commit=true;
}
int n,m;
cin>>n>>m;
for(int i=0;i<n;i++){
long long int num;
cin>>num;
fSegASet(0,i,0,R,num);
}
areaSum.push_back(0);
long long int sum=0;
for(int i=0;i<n;i++){
long long int num;
cin>>num;
sum+=num;
areaSum.push_back(sum);
}
for(int i=0;i<maxS;i++){
areaSum.push_back(sum);
}
for(int i=0;i<m;i++){
int c1,l,r,x,y,z;
cin>>c1;
if(c1==0){
cin>>x>>y>>z;
E2 e2;
e2.l=y-1;
e2.r=y-2+z;
e2.x=x-1;
e2.y=y-1;
e2.z=z;
l=x-1;
r=x-2+z;
copyData.push_back(e2);
fSegAUpData(0,l,r,0,R,no0,-1,true);
no0++;
}else{
cin>>l>>r;
l--;
r--;
long long int t=fSegACalcAns(0,l,r,0,R,-1,true);
cout<<t<<endl;
}
//for(int i=0;i<maxS;i++){
//cout<<"("<<i<<","<<segA[i].num<<")";
//}
//cout<<endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nLmg+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxzZXQ+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpzdHJ1Y3QgRXsKCWxvbmcgbG9uZyBpbnQgbnVtLG5vOwoJYm9vbCBjb21taXQ7Cn07CnN0cnVjdCBFMnsKCWludCBsLHIseCx5LHo7Cn07CmNvbnN0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