#include<bits/stdc++.h>
#define N 200000
#define LL long long
using namespace std;
int n,a[N+5],b[N+5];LL B[N+5];set<int> G;
class SegmentTree
{
private:
#define PT int l=1,int r=n,int o=1
#define LT l,u,o<<1
#define RT u+1,r,o<<1|1
#define TA(o,v) (A[o]+=v,FA[o]+=v)
#define TG(o,v) (A[o]=v,FA[o]=0,FG[o]=v,GG[o]=1)
LL A[N<<2],FA[N<<2],FG[N<<2];bool GG[N<<2];
void PD(int o)
{
if(GG[o]) TG(o<<1,FG[o]),TG(o<<1|1,FG[o]),GG[o]=0;
if(FA[o]) TA(o<<1,FA[o]),TA(o<<1|1,FA[o]),FA[o]=0;
}
public:
void Build(PT)
{
if(l==r) return (void)(A[o]=a[l]);int u=l+r>>1;Build(LT),Build(RT);
}
void UA(int L,int R,LL v,PT)
{
if(L<=l&&r<=R) return (void)TA(o,v);int u=l+r>>1;PD(o),L<=u&&(UA(L,R,v,LT),0),R>u&&(UA(L,R,v,RT),0);
}
void UG(int L,int R,LL v,PT)
{
if(L<=l&&r<=R) return (void)TG(o,v);int u=l+r>>1;PD(o),L<=u&&(UG(L,R,v,LT),0),R>u&&(UG(L,R,v,RT),0);
}
LL Q(int x,PT)
{
if(l==r) return A[o];int u=l+r>>1;PD(o);return x<=u?Q(x,LT):Q(x,RT);
}
}S;
void Add(int l,int r,int v)
{
S.UA(l,r,v),G.insert(l),G.insert(r+1);
}
LL Q(int l,int r)
{
G.insert(l),G.insert(r+1);set<int>::iterator tl=G.lower_bound(l),tr=tl;
vector<pair<LL,LL> > V;V.clear();
int z=0;while(*tr<=r) V.push_back(make_pair(S.Q(*tr),(LL)*tr)),++z,++tr;
for(int i=0;i<z-1;++i) V[i].second=B[V[i+1].second-1]-B[V[i].second-1];V[z-1].second=B[r]-B[V[z-1].second-1];
sort(V.begin(),V.end());LL g,c=0,C=B[r]-B[l-1];for(int i=0;i<z;++i) {c+=V[i].second;if(2*c>=C) {g=V[i].first;break;}}
printf("%lld\n",g),S.UG(l,r,g),G.erase(tl,tr),G.insert(l),G.insert(r+1);
}
int main()
{
freopen("a.in","r",stdin),freopen("a.out","w",stdout);
int Qt;scanf("%d%d",&n,&Qt);
for(int i=1;i<=n;++i) scanf("%d",a+i);for(int i=1;i<=n;++i) scanf("%d",b+i),B[i]=B[i-1]+b[i];
S.Build();for(int i=1;i<=n+1;++i) G.insert(i);
while(Qt--) {int op,x,y;scanf("%d%d%d",&op,&x,&y);if(op==1) {int v;scanf("%d",&v),Add(x,y,v);}else Q(x,y);}
return 0;
}