#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif
 
using namespace std;
 
/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define repd(i,k) for(int i=k;i>=0;i--)
#define rep(i,k) for(int i=0;i<k;i++)
#define repn(i,k1,k2) for(ll i=k1;i<k2;i++)
#define sz(x) (ll)(x).size()
#define ff first
#define ss second

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define ee6 (ll)1000001
#define ee5 (ll)100001

#define tt ll t;cin>>t; while(t--)
typedef long long int ll;
 
typedef pair<ll, ll> pr;
typedef vector<ll> vi;
typedef vector<string> vs;

typedef vector<pr> vpr;
typedef vector<vpr>vvpr;
typedef vector<vi> vvi;
typedef map<ll,ll> MPII;
typedef set<ll> SETI;
typedef multiset<ll> MSETI;
//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
 
ll powmod(ll a, ll e) {
	if (e == 0) return 1;
	ll x = powmod(a * a % MOD, e >> 1);
	return e & 1 ? x * a % MOD : x;
}

struct tr{
	ll a,b,c,cnt;
	bool op;
	tr(bool op,ll a=0,ll b=0,ll c=0,ll cnt=0):a(a),b(b),c(c),cnt(cnt),op(op){}
	tr operator+(const tr &rhs)
	{
		//cout<<a<<" "<<b<<" "<<c<<" "<<cnt<<" "<<"::";
		//cout<<rhs.a<<" "<<rhs.b<<" "<<rhs.c<<" "<<rhs.cnt<<"\n";

		if(op)
			c=(c+rhs.c+cnt*rhs.a%MOD)%MOD;//l2r op=1
		else {c=(c+rhs.c+rhs.cnt*a%MOD);
			}

		a=(a+rhs.a)%MOD;
		b=(b+rhs.b)%MOD;
		cnt+=rhs.cnt;
		return (*this);
	}
};

const ll N=2*ee5;
ll w[N],a[N],p[N];
ll seg[4*N],segsum[4*N],segtl2r[4*N],segtr2l[4*N];
void build(ll low,ll high,ll index)
{
	if(low==high)
	{
		segsum[index]=w[low]*a[low]%MOD;
		segtl2r[index]=segtr2l[index]=seg[index]=w[low];
		return;
	}
	ll mid=(low+high)/2;
	build(low,mid,index*2+1);
	build(mid+1,high,index*2+2);
	seg[index]=(seg[index*2+1]+seg[index*2+2])%MOD;
	segsum[index]=(segsum[index*2+1]+segsum[index*2+2])%MOD;
	segtl2r[index]=(segtl2r[index*2+1]+segtl2r[index*2+2]+seg[index*2+2]*(mid-low+1)%MOD)%MOD;
	segtr2l[index]=(segtr2l[index*2+2]+segtr2l[index*2+1]+seg[index*2+1]*(high-mid)%MOD)%MOD;
}

void update(ll low,ll high,ll index,ll idx,ll w)
{
	if(low>idx or high<idx)return;
	if(low==high){
		segsum[index]=w*a[low]%MOD;
		segtl2r[index]=segtr2l[index]=seg[index]=w;
		return;}
	ll mid=(low+high)/2;
	update(low,mid,index*2+1,idx,w);
	update(mid+1,high,index*2+2,idx,w);
	seg[index]=(seg[index*2+1]+seg[index*2+2])%MOD;
	segsum[index]=(segsum[index*2+1]+segsum[index*2+2])%MOD;
	segtl2r[index]=(segtl2r[index*2+1]+segtl2r[index*2+2]+seg[index*2+2]*(mid-low+1)%MOD)%MOD;
	segtr2l[index]=(segtr2l[index*2+2]+segtr2l[index*2+1]+seg[index*2+1]*(high-mid)%MOD)%MOD;
}

ll query(ll low,ll high,ll index,ll s)
{
	//	cout<<low<<" "<<high<<" "<<s<<"\n";
	if(low==high)return low;
	ll mid=(low+high)/2;
	if(s>=seg[index*2+1]+w[mid+1])
		return query(mid+1,high,index*2+2,s-seg[index*2+1]);
	else if(s>seg[index*2+1])return mid;
	else 
		return query(low,mid,index*2+1,s);
}

tr qx(ll low,ll high,ll index,ll l,ll h,ll segop[],bool op)
{
	
	if(low>high or l>h or low>h or l>high)return tr(op);
	if(low>=l and high<=h)return tr(op,seg[index],segsum[index],segop[index],high-low+1);
	ll mid=(low+high)/2;
	return qx(low,mid,index*2+1,l,h,segop,op)+qx(mid+1,high,index*2+2,l,h,segop,op);
}

ll qy(ll low,ll high,ll index,ll h)
{
	if(low>h)return 0;
	if(high<=h)return seg[index];
	ll mid=(low+high)/2;
	return qy(low,mid,index*2+1,h)+qy(mid+1,high,index*2+2,h);
}



int main()
{
	#if !ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll n,q;cin>>n>>q;
	rep(i,n)cin>>a[i];

	rep(i,n){cin>>w[i];}

	build(0,n-1,0);

	tr x=qx(0,n-1,0,0,3,segtl2r,1);
	//cout<<x.a<<" "<<x.b<<" "<<x.c<<"\n";
	while(q--)
	{
		ll l,r;cin>>l>>r;
		if(l<0)
		{
			l=-l;
			l--;
			update(0,n-1,0,l,r);
		}
		else
		{
			l--;r--;

			ll pl=qy(0,n-1,0,l-1);
			ll pr=qy(0,n-1,0,r);

			ll s=pl+(pr-pl)/2;

			ll idx=query(0,n-1,0,s);
			//idx=max(l,idx);
			
			idx++;
			//for(;idx<min(n,idx+2);idx++)
			//{
				//cout<<idx<<"\n";
				tr x=qx(0,n-1,0,idx+1,r,segtl2r,1);
				//cout<<x.a<<" "<<x.b<<" "<<x.c<<"\n";
				tr y=qx(0,n-1,0,l,idx-1,segtr2l,0);
				//cout<<y.a<<" "<<y.b<<" "<<y.c<<"\n";

				ll ans=(((x.b-y.b+MOD)%MOD+a[idx]*(y.a-x.a)%MOD-x.c+MOD)%MOD-y.c+MOD)%MOD;
			//}
			cout<<ans<<"\n";
		}
	}

}