#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fbo find_by_order
#define ook order_of_key
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define MOD 1000000007
#define MID (l+r)/2
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define mx 200003
#define pc(x) putchar_unlocked(x);
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds;

long long sum[mx*4],cuk[mx*4],a[mx],pos[mx],n,q,yo[mx*4],oy[mx*4];

void build(int idx,int l,int r){
	if(l==r){
		sum[idx]=a[l];
		cuk[idx]=a[l]*pos[l]%MOD;
		yo[idx]=a[l]*l%MOD;
		oy[idx]=a[l]*(n-l+1)%MOD;
		return;
	}
	build(2*idx,l,MID);
	build(2*idx+1,MID+1,r);
	sum[idx]=sum[idx*2]+sum[idx*2+1];
	cuk[idx]=(cuk[2*idx]+cuk[idx*2+1])%MOD;
	yo[idx]=(yo[2*idx]+yo[idx*2+1])%MOD;
	oy[idx]=(oy[2*idx]+oy[idx*2+1])%MOD;
}

void upd(int idx,int l,int r,int in,int val){
	if(in>r || in<l)return;
	if(l==r){
		sum[idx]=a[l];
		cuk[idx]=a[l]*pos[l]%MOD;
		yo[idx]=a[l]*l%MOD;
		oy[idx]=a[l]*(n-l+1)%MOD;
		return;
	}
	upd(2*idx,l,MID,in,val);
	upd(2*idx+1,MID+1,r,in,val);
	sum[idx]=sum[idx*2]+sum[idx*2+1];
	cuk[idx]=(cuk[2*idx]+cuk[idx*2+1])%MOD;
	yo[idx]=(yo[2*idx]+yo[idx*2+1])%MOD;
	oy[idx]=(oy[2*idx]+oy[idx*2+1])%MOD;
}

long long cari(int idx,int l,int r,int fl,int fr){
	if(fl>r || fr<l)return 0;
	if(fl<=l && r<=fr)return sum[idx];
	return cari(2*idx,l,MID,fl,fr)+cari(2*idx+1,MID+1,r,fl,fr);
}

long long cari1(int idx,int l,int r,int fl,int fr){
	if(fl>r || fr<l)return 0;
	if(fl<=l && r<=fr)return cuk[idx];
	return (cari1(2*idx,l,MID,fl,fr)+cari1(2*idx+1,MID+1,r,fl,fr))%MOD;	
}

long long cari2(int idx,int l,int r,int fl,int fr){
	if(fl>r || fr<l)return 0;
	if(fl<=l && r<=fr)return yo[idx];
	return (cari2(2*idx,l,MID,fl,fr)+cari2(2*idx+1,MID+1,r,fl,fr))%MOD;	
}

long long cari3(int idx,int l,int r,int fl,int fr){
	if(fl>r || fr<l)return 0;
	if(fl<=l && r<=fr)return oy[idx];
	return (cari3(2*idx,l,MID,fl,fr)+cari3(2*idx+1,MID+1,r,fl,fr))%MOD;	
}

int main(){
	// cin>>n>>q;
	scanf("%d%d",&n,&q);
	// for(int i=1;i<=n;i++)cin>>pos[i];
	for(int i=1;i<=n;i++)scanf("%d",&pos[i]);
	// for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	build(1,1,n);
	while(q--){
		int l,r;
		// cin>>l>>r;
		scanf("%d%d",&l,&r);
		if(l<0){
			l=-l;
			a[l]=r;
			upd(1,1,n,l,r);
		}
		else{
			int lo=l,hi=r,mid,mana=-1;
			long long tot=cari(1,1,n,l,r);
			while(lo<=hi){
				mid=(lo+hi)>>1;
				long long aa=cari(1,1,n,l,mid);
				if(aa*2>=tot){
					hi=mid-1;
					mana=mid;
				}
				else lo=mid+1;
			}
			assert(mana>0);
			long long kiri1=cari1(1,1,n,l,mana);
			long long kanan1=cari1(1,1,n,mana+1,r);
			long long kiri=cari(1,1,n,l,mana);
			long long kanan=cari(1,1,n,mana+1,r);
			long long ans1=((kiri*pos[mana]%MOD)-kiri1+MOD)%MOD;
			long long ans2=(kanan1-(kanan*pos[mana]%MOD)+MOD)%MOD;
			long long ans=(ans1+ans2)%MOD;
			long long kurangkiri=cari3(1,1,n,l,mana);
			int awal=(n-mana+1);
			kurangkiri=(kurangkiri-(awal*kiri%MOD)+MOD)%MOD;
			// debug(kurangkiri);
			long long kurangkanan=cari2(1,1,n,mana+1,r);
			awal=mana;
			kurangkanan=(kurangkanan-(awal*kanan%MOD)+MOD)%MOD;
			// debug(kurangkanan);
			ans=(ans-kurangkiri+MOD)%MOD;
			ans=(ans-kurangkanan+MOD)%MOD;
			// cout<<ans<<endl;
			printf("%lld\n",ans);
		}
	}
}

/* 
* (Actually read this pls)
    * Rlly bad errors: int overflow, array bounds
    * Less bad errors: special cases (n=1?), set tle
    * Common sense: do smth instead of nothing
*/