#include <bits/stdc++.h>
using namespace std;

#define N 200005
const int mod = 1e9 + 7;

#define ll long long

int add(int x,int y) {
  return ((x+y)%mod+mod)%mod;
}
int mul(int x,int y) {
  return (ll)x*y%mod;
}
int mypow(int x,int c) {
  int ret = 1;
  while(c>0) {
    if(c&1) {
      ret = mul(ret,x);
    }
    c/=2;
    x = mul(x,x);
  }
  return ret;
}

ll pen[N];

void update(int ind,int add) {
  while(ind<N) {
    pen[ind] += add;
    ind += ind&(-ind);
  }
}

ll query(int ind) {
  ll ret = 0;
  while(ind>0) {
    ret = ret + pen[ind];
    ind = ind&(ind-1);
  }
  return ret;
}

int a[N],w[N];

int pen2[N];
int pen3[N];

void update2(int *pp,int ind,int ad) {
  while(ind<N) {
    pp[ind] = add(pp[ind],ad);
    ind += ind&(-ind);
  }
}

int query2(int *pp,int ind) {
  int ret = 0;
  while(ind>0) {
    ret = add(ret,pp[ind]);
    ind = ind&(ind-1);
  }
  return ret;
}

int getS(int x,int y,int wei) {
  ll s = query(y)- query(x-1);
  int sum = s%mod;
  int r = add(add(query2(pen3,y) ,-query2(pen3,x-1)), -mul(sum,x));
  return add(r, mul(sum,wei));
}

void solve() {
  int n,q;
  scanf("%d %d ", &n,&q);
  for(int i=1;i<=n;++i) {
    scanf("%d ", &a[i]);
  }
  for(int i=1;i<=n;++i) {
    scanf("%d ", &w[i]);
    update(i,w[i]);
    update2(pen2,i,mul(w[i],a[i]));
    update2(pen3,i,mul(i,w[i]));

  }

  while(q--) {
    int x,y;
    scanf("%d %d ", &x,&y);
    if(x<0) {
      int id = -x;
      update(id,-w[id]);
      update2(pen2,id,-mul(w[id],a[id]));
      update2(pen3,id,-mul(id,w[id]));
      w[id] = y;
      update(id,w[id]);
      update2(pen2,id,mul(w[id],a[id]));
      update2(pen3,id,mul(id,w[id]));
    } else {
      ll pre = query(x-1);
      ll sum = query(y) - pre;
      int l = x,r = y,mid;
      while(l<r) {
        mid = (l + r)/2;
        if( (query(mid) - pre)*2>sum) {
          r = mid;
        } else {
          l = mid + 1;
        }
      }
      int ind = l;
      int ret = 0;
      if(x<=ind-1) {
        int wei = a[ind] - ind  + x;
        ret = add(ret, add(getS(x,ind-1,wei),-add(query2(pen2,ind-1),-query2(pen2,x-1))));
      }
      if(ind+1<=y) {
        int wei = a[ind] + 1;
        ret = add(ret, add(-getS(ind+1,y,wei),add(query2(pen2,y),-query2(pen2,ind))));
      }
      printf("%d\n", ret);
    }
  }

}

int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define ld long double
#define pb push_back
#define mkp make_pair
#define pii pair<int, int>
#define pll pair<long long int, long long int>
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define fi first
#define sc second
#define eps 1e-9

int A[200005], I[200005];
ll BIT[200005];

struct node {
	ll W, L, R;
	int RI, LI, E;
} T[1000001];

void make(int n, int start, int end) {
	if (start == end) {
		T[n].W = A[start];
		T[n].RI = T[n].LI = I[start];
		T[n].E = 1;
		return;
	}
	int mid = (start + end) >> 1;
	make(n<<1, start, mid);
	make(n<<1|1, mid+1, end);
	T[n].W = (T[n<<1].W + T[n<<1|1].W) % MOD;
	T[n].L = (T[n<<1].L + T[n<<1|1].L + T[n<<1|1].W * (T[n<<1|1].LI - T[n<<1].LI - T[n<<1].E)) % MOD;
	T[n].R = (T[n<<1|1].R + T[n<<1].R + T[n<<1].W * (T[n<<1|1].RI - T[n<<1|1].E - T[n<<1].RI)) % MOD;
	T[n].RI = T[n<<1|1].RI;
	T[n].LI = T[n<<1].LI;
	T[n].E = end - start + 1;
}

void update(int n, int start, int end, int idx) {
	if (start > idx || end < idx) return;
	if (start == end) {
		T[n].W = A[start];
		T[n].RI = T[n].LI = I[start];
		T[n].E = 1;
		return;
	}
	int mid = (start + end) >> 1;
	update(n<<1, start, mid, idx);
	update(n<<1|1, mid+1, end, idx);
	T[n].W = (T[n<<1].W + T[n<<1|1].W) % MOD;
	T[n].L = (T[n<<1].L + T[n<<1|1].L + T[n<<1|1].W * (T[n<<1|1].LI - T[n<<1].LI - T[n<<1].E)) % MOD;
	T[n].R = (T[n<<1|1].R + T[n<<1].R + T[n<<1].W * (T[n<<1|1].RI - T[n<<1|1].E - T[n<<1].RI)) % MOD;
	T[n].RI = T[n<<1|1].RI;
	T[n].LI = T[n<<1].LI;
	T[n].E = end - start + 1;
}

node query(int n, int start, int end, int l, int r) {
	node ret; ret.W = ret.L = ret.R = ret.LI = ret.RI = ret.E = 0;
	if (start > r || end < l) return ret;
	if (start >= l && end <= r) return T[n];
	int mid = (start + end) >> 1;
	node A = query(n<<1, start, mid, l, r);
	node B = query(n<<1|1, mid+1, end, l, r);
	if (A.E == 0) return B;
	else if (B.E == 0) return A;
	ret.W = (A.W + B.W) % MOD;
	ret.L = (A.L + B.L + B.W * (B.LI - A.LI - A.E)) % MOD;
	ret.R = (B.R + A.R + A.W * (B.RI - B.E - A.RI)) % MOD;
	ret.RI = B.RI;
	ret.LI = A.LI;
	ret.E = A.E + B.E;
	return ret;
}

void insert(int x, int val) {
	for (; x <= 200000; x += (x&-x)) BIT[x] += val;
}

ll query(int x) {
	ll ret = 0;
	for (; x > 0; x -= (x&-x)) ret += BIT[x];
	return ret;
}

int main()
{
	int n, q, i, j, k, x, y, z, l, r;
	sci(n); sci(q);
	for (i = 1; i <= n; ++i) sci(I[i]);
	for (i = 1; i <= n; ++i) {
		sci(A[i]);
		insert(i, A[i]);
	}
	make(1, 1, n);
	while (q--) {
		sci(x); sci(y);
		if (x < 0) {
			x *= -1;
			insert(x, -A[x]);
			A[x] = y;
			insert(x, A[x]);
			update(1, 1, n, x);
		} else {
			l = x;
			r = y;
			int start = l;
			int end = r;
			int idx = -1;
			ll a = query(l-1);
			ll b = query(r);
			while (start <= end) {
				int mid = (start + end) >> 1;
				ll c = query(mid);
				ll x = c - a;
				ll y = b - c;
				if (x >= y) {
					idx = mid;
					end = mid - 1;
				} else {
					start = mid + 1;
				}
			}
			node A = query(1, 1, n, l, idx);
			node B = query(1, 1, n, idx, r);
			printf("%lld\n", (A.R + B.L) % MOD);
		}
	}

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int mod = (1e9) + 7;

const int N = 200020;

int n, q;

long long sum[N];
long long bit[N];

int a[N];
int w[N];

int main(){

  scanf("%d%d", &n, &q);

  for(int i = 1; i <= n; ++i){
    scanf("%d", a + i);
  }

  for(int i = 1; i <= n; ++i){
    scanf("%d", w + i);

    for(int j = i; j < N; j += j & -j) {
      sum[j] += w[i];
      bit[j] += 1LL * (a[i] - i) * w[i];
      bit[j] %= mod;
    }
  }

  while(q--){
    int l, r;
    scanf("%d%d", &l, &r);

    if(l < 0){
      l = -l;

      for(int i = l; i < N; i += i & -i) {
        bit[i] += 1LL * (a[l] - l) * (r - w[l]);
        bit[i] = ((bit[i] % mod) + mod) % mod;
        sum[i] += r - w[l];
      }

      w[l] = r;
    }
    else{
      int lo = l, hi = r, pos = hi;

      long long all = 0;
      for(int i = r; i > 0; i &= i - 1) all += sum[i];
      for(int i = l - 1; i > 0; i &= i - 1) all += sum[i];

      while(lo <= hi){
        int m = (lo + hi) >> 1;

        long long tot = 0;
        for(int i = m; i > 0; i &= i - 1) tot += sum[i];

        if(tot * 2 >= all) {
          pos = m;
          hi = m - 1;
        }
        else lo = m + 1;
      }

      int best = a[pos] - pos;

      long long lef = 0, rig = 0;
      long long ans = 0;
      for(int i = pos - 1; i > 0; i &= i - 1) {
        lef = (lef + sum[i]) % mod;
        rig = (rig - sum[i] + 1LL * mod * mod) % mod;
        ans = (ans - bit[i] * 2 + mod + mod) % mod;
      }
      for(int i = l - 1; i > 0; i &= i - 1) ans = (ans + bit[i]) % mod, lef = (lef - sum[i] + 1LL * mod * mod) % mod;
      for(int i = r; i > 0; i &= i - 1) ans = (ans + bit[i]) % mod, rig = (rig + sum[i]) % mod;

      printf("%d\n", (ans + lef * best - rig * best + 1LL * mod * mod) % mod);
    }
  }

	return 0;
}

#include<bits/stdc++.h>

typedef long long ll;
const int moder = (int) 1e9 + 7;
const int N = 200010;

ll c[2][N];
int a[N], w[N];

void add(ll *c, int sit, int x){
    for ( ; sit < N; sit += sit & -sit){
        c[sit] += x;
    }
}

ll query(ll *c, int sit){
    ll ret = 0;
    for ( ; sit; sit -= sit & -sit){
        ret += c[sit];
    }
    return ret;
}

ll query(ll *c, int l, int r){
    return query(c, r) - query(c, l - 1);
}

int main(){
    int n, q;
    scanf("%d%d", &n, &q);
    for (int i = 1; i <= n; ++ i){
        scanf("%d", &a[i]);
        a[i] -= i;
    }
    for (int i = 1; i <= n; ++ i){
        scanf("%d", &w[i]);
        add(c[0], i, w[i]);
        add(c[1], i, 1ll * w[i] * a[i] % moder);
    }
    while (q --){
        int x, y;
        scanf("%d%d", &x, &y);
        if (x < 0){
            add(c[0], -x, y - w[-x]);
            add(c[1], -x, 1ll * (y - w[-x]) * a[-x] % moder);
            w[-x] = y;
            continue;
        }
        ll sum = query(c[0], x, y);
        int left = x, right = y;
        while (left < right){
            int mid = left + right >> 1;
            if (query(c[0], x, mid) << 1 >= sum){
                right = mid;
            }
            else{
                left = mid + 1;
            }
        }
        int sit = left;
        int value = a[sit];
        int ans = (query(c[1], sit + 1, y) % moder - 1ll * value * (query(c[0], sit + 1, y) % moder)) % moder;
        ans = (ans - query(c[1], x, sit) % moder + 1ll * value * (query(c[0], x, sit) % moder)) % moder;
        ans += ans < 0 ? moder : 0;
        printf("%d\n", ans);
    }
    return 0;
}

#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 1000000000
#define MOD 1000000007
#define M 15000007
#define N 200005
#define MAX 5032117
#define LOG 100
#define KOK 333
using namespace std;

struct seg {

	ll ws;
	int as;

	inline seg operator+(seg a) {

		return {ws+a.ws,(as+a.as)%MOD};

    }

} S[N*4];

int n,q,x,t,y;
int l[N];

int get2(int node,int bas,int son,int x,int y,int cas) {

	if(bas>y || son<x) return 0;

	if(bas>=x && son<=y) {

		int pos=(cas?x-1:y+1);

		return (S[node].ws%MOD*(l[pos]-pos)%MOD+S[node].as)%MOD;

	}

	return (get2(node*2,bas,orta,x,y,cas)+get2(node*2+1,orta+1,son,x,y,cas))%MOD;

}

ll get1(int node,int bas,int son,int x,int y) {

	if(bas>y || son<x) return 0;

	if(bas>=x && son<=y) return S[node].ws;

	return get1(node*2,bas,orta,x,y)+get1(node*2+1,orta+1,son,x,y);

}

void up(int node,int bas,int son,int x,int val) {

	if(bas>x || son<x) return ;

	if(bas==x && son==x) {

		S[node]={val,1ll*val*(bas-l[bas]+MOD)%MOD};

		return ;

	}

	up(node*2,bas,orta,x,val);
	up(node*2+1,orta+1,son,x,val);

	S[node]=S[node*2]+S[node*2+1];

}

int main() {

	//freopen("input.txt","r",stdin);

	scanf("%d %d",&n,&q);

	for(int i=1;i<=n;i++) {

		scanf("%d",&l[i]);

	}

	for(int i=1;i<=n;i++) {

		scanf("%d",&x);

		up(1,1,n,i,x);

	}

	while(q--) {

		scanf("%d %d",&x,&y);

		if(x>0) {

			int bas=x,son=y;
			ll alle=get1(1,1,n,x,y);

			while(bas<=son) {

				if(get1(1,1,n,x,orta)>=(alle+1)/2) son=orta-1;
				else bas=orta+1;

			}

			printf("%d\n",(get2(1,1,n,x,bas-1,0)-get2(1,1,n,bas+1,y,1)+MOD)%MOD);

		}
		else {

			x=-x;

			up(1,1,n,x,y);

		}

	}

}

#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=(x);i<=(y);i++)
#define dep(i,x,y) for(int i=(x);i>=(y);i--)
#define add(x,y) x=(x+(y))%mo
#define dec(x,y) x=(x+mo-(y))%mo
#define sqr(x) ((x)*(x))
#define gc getchar()
#define pb push_back
#define N 600000
#define ll long long
#define mo 1000000007
#define inf 1000000000
#define Inf 1000000000000000000ll
#define eps 1e-8
using namespace std;
int n,m,x,y,b[N];
struct pr{ll x,p,a;}a[N];
pr operator +(pr x,pr y){
	return {x.x+y.x,(x.p+y.p)%mo,(x.a+y.a)%mo};
}
int fm(int x,ll y,int l,int r){
	if(l==r)return l;int rr=(l+r)/2;
	if(y<=a[x*2].x)return fm(x*2,y,l,rr);
	else return fm(x*2+1,y-a[x*2].x,rr+1,r);
}
void f(int x,int y,ll z,int l,int r){
	if((l==y)&&(r==y)){
		a[x]={z,z*y%mo,z*b[y]%mo};return;
	}int rr=(l+r)/2;
	if(y<=rr)f(x*2,y,z,l,rr);else f(x*2+1,y,z,rr+1,r);
	a[x]=a[x*2]+a[x*2+1];
}
pr q(int x,int l,int r,int L,int R){
	if((l==L)&&(r==R))return a[x];int rr=(L+R)/2;
	if(r<=rr)return q(x*2,l,r,L,rr);
	else if(l>rr)return q(x*2+1,l,r,rr+1,R);
	else return q(x*2,l,rr,L,rr)+q(x*2+1,rr+1,r,rr+1,R);
}
int main(){
	scanf("%d%d",&n,&m);
	rep(i,1,n)scanf("%d",&b[i]);
	rep(i,1,n){
		scanf("%d",&x);f(1,i,x,1,n);
	}
	rep(i,1,m){
		scanf("%d%d",&x,&y);
		if(x<0)f(1,-x,y,1,n);else{
			ll tq=(q(1,x,y,1,n).x+1)/2;
			if(x>1)tq+=q(1,1,x-1,1,n).x;
			int rr=fm(1,tq,1,n);
			ll sp=(b[rr]-rr+mo)%mo;
			pr l=q(1,x,rr,1,n);
			pr r;if(rr<y)r=q(1,rr+1,y,1,n);else r={0,0,0};
			printf("%I64d\n",(l.x%mo*sp+l.p-l.a+r.a-r.x%mo*sp%mo-r.p+mo*3ll)%mo);
		}
	}
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

template<typename T>
struct SegmentTree{
    using F=function<T(T,T)>;

    int n;
    vector<T> dat;
    F f;
    T ti;

    SegmentTree(int n_ ,F f ,T ti) :f(f),ti(ti){
        n=1;
        while(n<n_) n*=2;
        dat.assign(2*n-1,ti);
    }

    SegmentTree(int n_ ,vector<T> &v ,F f,T ti) :f(f),ti(ti){
        n=1;
        while(n<n_) n*=2;
        dat.assign(2*n-1,ti);

        for(int i=n-1;i-(n-1)<v.size();i++) dat[i]=v[i-(n-1)];

        for(int i=n-2;i>=0;i--) dat[i]=f(dat[i*2+1],dat[i*2+2]);
    }

    void update(int k,T x){
        k+=n-1;
        dat[k]=x;

        while(k){
            k=(k-1)/2;
            dat[k]=f(dat[k*2+1],dat[k*2+2]);
        }
    }

    void set(int k,T x){
        dat[n-1+k]=x;
    }

    void built(){
        for(int i=n-2;i>=0;i--) dat[i]=f(dat[i*2+1],dat[i*2+2]);
    }

    T query_(int a,int b,int k,int l,int r){
        if(r<=a||b<=l) return ti;
        if(a<=l&&r<=b) return dat[k];
        else{
            T vl=query_(a,b,2*k+1,l,(l+r)/2);
            T vr=query_(a,b,2*k+2,(l+r)/2,r);
            return f(vl,vr);
        }
    }

    T query(int a,int b){
        return query_(a,b,0,0,n);
    }

    T get(int k){
        return dat[k+n-1];
    }

    template<typename C>
    int findright(int st,C &check,T &acc,int k,int l,int r){
        if(l+1==r){
            acc=f(acc,dat[k]);
            return check(acc)?k-(n-1):-1;
        }
        int m=(l+r)/2;
        if(m<=st) return findright(st,check,acc,2*k+2,m,r);
        if(st<=l&&!check(f(acc,dat[k]))){
            acc=f(acc,dat[k]);
            return -1;
        }
        int vl=findright(st,check,acc,2*k+1,l,m);
        if(~vl) return vl;
        return findright(st,check,acc,2*k+2,m,r);
    }

    template<typename C>
    int findright(int st,C &check){
        T acc=ti;
        return findright(st,check,acc,0,0,n);
    }//条件を満たす最小のidxを返す

    template<typename C>
    int findleft(int st,C &check,T &acc,int k,int l,int r){
        if(l+1==r){
            acc=f(acc,dat[k]);
            return check(acc)?k-(n-1):INF;
        }
        int m=(l+r)/2;
        if(m>=st) return findleft(st,check,acc,2*k+1,l,m);
        if(st>=r&&!check(f(acc,dat[k]))){
            acc=f(acc,dat[k]);
            return INF;
        }
        int vr=findleft(st,check,acc,2*k+2,m,r);
        if(vr!=INF) return vr;
        return findleft(st,check,acc,2*k+1,l,m);
    }

    template<typename C>
    int findleft(int st,C &check){
        T acc=ti;
        return findleft(st,check,acc,0,0,n);
    }//条件を満たす最大のidxを返す

};

int main(){

    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N,Q;cin>>N>>Q;
    vector<ll> pos(N);
    vector<ll> w(N);

    for(int i=0;i<N;i++){
        cin>>pos[i];
        pos[i]-=i;
    }

    for(int i=0;i<N;i++){
        cin>>w[i];
    }

    SegmentTree<pair<ll,ll>> seg(N,
                                 [](pair<ll,ll> a,pair<ll,ll> b){return mp((a.fi+b.fi)%mod,(a.se+b.se)%mod);},
                                 mp(0,0));

    SegmentTree<ll> wsum(N,
                         w,
                         [](ll a,ll b){return a+b;},
                         0);

    for(int i=0;i<N;i++){
        seg.update(i,mp(w[i]*pos[i]%mod,(w[i]*(mod-pos[i]))%mod));
    }

    while(Q--){
        ll l,r;cin>>l>>r;
        if(l<0){
            l*=-1;
            l--;
            seg.update(l,mp(r*pos[l]%mod,(r*(mod-pos[l]))%mod));
            wsum.update(l,r);
            w[l]=r;
        }else{
            l--;
            r--;

            ll left=l,right=r+1;

            ll sum=wsum.query(left,right);

            auto check=[&](ll x){return 2*x>=sum;};
            int d=wsum.findright(l,check);

            /*while(right-left>1){
                ll mid=(left+right)/2;
                ll a=wsum.query(l,mid),b=wsum.query(l,mid+1);

                if(a*2<=sum&&b*2>=sum){
                    left=mid;
                    break;
                }else if(a*2>sum) right=mid;
                else left=mid;
            }

            int d=left;*/

            ll lsum=0,rsum=0;

            lsum+=seg.query(l,d).se-(wsum.query(l,d)%mod*(mod-pos[d]))%mod+mod;
            rsum+=seg.query(d,r+1).fi-wsum.query(d,r+1)%mod*pos[d]%mod+mod;

            /*ll ans=0;

            for(int i=l;i<=r;i++){
                ans+=abs(pos[d]-pos[i])*w[i];
                ans%=mod;
            }

            cout<<ans<<"\n";*/

            cout<<(lsum+rsum)%mod<<"\n";
            //cout<<d<<endl;
        }
    }
}

#include <bits/stdc++.h>

using namespace std;

const long long mod = 1e9 + 7;

int n, q, i, j, l, mid, r;
long long a[200010], w[200010];

////////////////////////// PARTEA I - simple partial sums on weight
long long aibpart[200010];
long long part(int poz)
{
    long long ret = 0LL;
    for(;poz;poz-=poz&-poz)
        ret = ret + aibpart[poz] ;
    return ret;
}
void updpart(int poz, int val)
{
    for(;poz<=n;poz+=poz&-poz)
        aibpart[poz] += val;
    return ;
}
//////////////////////////

////////////////////////// PARTEA II - simple partial sums on products between weight and position
long long aibprodus[200010];
int produs(int poz)
{
    int ret = 0;
    for(;poz;poz-=poz&-poz)
    {
        ret = ret + aibprodus[poz] ;
        ret = ( ret > mod ) ? ret - mod : ret ;
    }
    return ret;
}
void updprodus(int poz, int val)
{
    for(;poz<=n;poz+=poz&-poz)
        aibprodus[poz] = ( aibprodus[poz] + val >= mod ) ? aibprodus[poz] + val - mod : aibprodus[poz] + val ;
    return ;
}
//////////////////////////

////////////////////////// PARTEA III - first grade function
long long aibA[200010], aibB[200010], aibretard[200010];
int getA(int poz)
{
    int ret = 0;
    for(;poz;poz-=poz&-poz)
    {
        ret = ret + aibA[poz] ;
        ret = ( ret > mod ) ? ret - mod : ret ;
    }
    return ret;
}
void updA(int poz,long long val)
{
    for(;poz<=n;poz+=poz&-poz)
        aibA[poz] = ( aibA[poz] + val >= mod ) ? aibA[poz] + val - mod : aibA[poz] + val ;
    return ;
}

int getB(int poz)
{
    int ret = 0;
    for(;poz;poz-=poz&-poz)
    {
        ret = ret + aibB[poz] ;
        ret = ( ret > mod ) ? ret - mod : ret ;
    }
    return ret;
}
void updB(int poz,long long val)
{
    for(;poz<=n;poz+=poz&-poz)
        aibB[poz] = ( aibB[poz] + val >= mod ) ? aibB[poz] + val - mod : aibB[poz] + val ;
    return ;
}

int getthird(int poz)
{
    long long ret = ( getA(poz) * ( long long ) poz + getB(poz) ) % mod ;
    return ( ret < 0 ) ? ret + mod : ret ;
}

void updretard(int poz,int val)
{
    for(;poz<=n;poz+=poz&-poz)
        aibretard[poz] = ( aibretard[poz] + val >= mod ) ? aibretard[poz] + val - mod : aibretard[poz] + val;
    return ;
}
int retard(int poz)
{
    int ret = 0;
    for(;poz;poz-=poz&-poz)
        ret = ( ret + aibretard[poz] >= mod ) ? ret + aibretard[poz] - mod : ret + aibretard[poz];
    return ret;
}
//////////////////////////

int main()
{
    cin>>n>>q;
    for(i=1;i<=n;i++) cin >> a[i];
    for(i=1;i<=n;i++)
    {
        cin >> w[i];
        updpart   ( i , w[i] );
        updprodus ( i , ( w[i] * a[i] ) % mod );
        updA      ( i , w[i] );
        long long aux = ( w[i] * ( 1 - i ) ) % mod ;
        aux = ( aux < 0 ) ? aux + mod : aux ;
        updB      ( i , aux );
        updretard ( i , ( w[i] * i ) % mod );
    }

    for(;q;q--)
    {
        cin >> l >> r;

        if( l < 0 )
        {
            l = -l;
            long long dif = ( r - w[l] < 0 ) ? r - w[l] + mod : r - w[l] ;
            updpart   ( l , r - w[l] );
            updprodus ( l , ( dif * a[l] ) % mod );
            updA      ( l , dif );
            long long aux = ( dif * ( 1 - l ) ) % mod ;
            aux = ( aux < 0 ) ? aux + mod : aux ;
            updB      ( l , aux );
            updretard ( l , ( dif * l ) % mod );
            w[l] = r;
            continue ;
        }

        int laux=l, raux=r;long long L=part(l-1);long long total=part(r)-L;
        while( laux < raux )
        {
            mid = ( laux + raux ) / 2;
            if( ( part(mid) - L ) * 2 < total )
                laux = mid + 1;
            else
                raux = mid;
        }
        mid = laux;
        long long ans = 0;
//        for(j=l;j<mid;j++)    ans = ( ans + ( a[mid] - a[j] - ( mid - j ) ) * w[j] ) % mod;
//        for(j=mid+1;j<=r;j++) ans = ( ans + ( a[j] - a[mid] - ( j - mid ) ) * w[j] ) % mod;
//        cout << "ACTUAL ANSWER: " << ans << '\n';
//
//        cout << "MIDDLE : " << mid - l + 1 << '\n';
//        cout << "WEIGHTS: ";for(j=l;j<=r;j++) cout << part(j)-part(j-1) << ' ';cout<<'\n';
//        cout << "POSES  : ";for(j=l;j<=r;j++) cout << a[j] << ' ';cout<<'\n';
//        cout << "PRODUSE: ";for(j=l;j<=r;j++) cout << (produs(j)-produs(j-1)+mod)%mod << ' ';cout<<'\n';
//        cout << "A & B  : ";for(j=l;j<=r;j++) cout << getthird(j) << ' ';cout<<'\n';

//        ans = 0LL;
////////////////////////// PARTEA I
        ans = ( ans + a[mid] * ( ( part(mid-1) - part(l-1) ) % mod ) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans ;

        ans = ( ans - a[mid] * ( ( part(r)   -   part(mid) ) % mod ) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans ;
//        cout << " PARTEA I: " << ans << '\n';

        //ans = 0LL;
////////////////////////// PARTEA II
        ans = ( ans - ( produs(mid-1) - produs (l-1) ) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans ;

        ans = ( ans + ( produs(r) - produs(mid) ) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans ;
//        cout << " PARTEA II: " << ans << '\n';

        //ans = 0LL;
////////////////////////// PARTEA III
        ans = ( ans - getthird(mid-1) );
        ans = ( ans < 0 ) ? ans + mod : ans;
        ans = ( ans  +  getthird(l-1) );
        ans = ( ans < 0 ) ? ans + mod : ans;
        ans = ( ans  + ( ( mid - l ) * part(l-1) ) % mod ) % mod;

//        cout << " PARTEA III a: " << ans << '\n';

        //ans = 0LL;

        ans = ( ans - retard(r) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans;
        ans = ( ans + retard (mid) ) % mod;
        if(mid!=r)ans = ( ans + mid * ( part(r) - part(mid) ) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans;

//        cout << " PARTEA III b: " << ans << '\n';
        cout << ans << '\n';
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

template<typename T>
struct SegmentTree{
    using F=function<T(T,T)>;

    int n;
    vector<T> dat;
    F f;
    T ti;

    SegmentTree(int n_ ,F f ,T ti) :f(f),ti(ti){
        n=1;
        while(n<n_) n*=2;
        dat.assign(2*n-1,ti);
    }

    SegmentTree(int n_ ,vector<T> &v ,F f,T ti) :f(f),ti(ti){
        n=1;
        while(n<n_) n*=2;
        dat.assign(2*n-1,ti);

        for(int i=n-1;i-(n-1)<v.size();i++) dat[i]=v[i-(n-1)];

        for(int i=n-2;i>=0;i--) dat[i]=f(dat[i*2+1],dat[i*2+2]);
    }

    void update(int k,T x){
        k+=n-1;
        dat[k]=x;

        while(k){
            k=(k-1)/2;
            dat[k]=f(dat[k*2+1],dat[k*2+2]);
        }
    }

    void set(int k,T x){
        dat[n-1+k]=x;
    }

    void built(){
        for(int i=n-2;i>=0;i--) dat[i]=f(dat[i*2+1],dat[i*2+2]);
    }

    T query_(int a,int b,int k,int l,int r){
        if(r<=a||b<=l) return ti;
        if(a<=l&&r<=b) return dat[k];
        else{
            T vl=query_(a,b,2*k+1,l,(l+r)/2);
            T vr=query_(a,b,2*k+2,(l+r)/2,r);
            return f(vl,vr);
        }
    }

    T query(int a,int b){
        return query_(a,b,0,0,n);
    }

    T get(int k){
        return dat[k+n-1];
    }

    template<typename C>
    int findright(int st,C &check,T &acc,int k,int l,int r){
        if(l+1==r){
            acc=f(acc,dat[k]);
            return check(acc)?k-(n-1):-1;
        }
        int m=(l+r)/2;
        if(m<=st) return findright(st,check,acc,2*k+2,m,r);
        if(st<=l&&!check(f(acc,dat[k]))){
            acc=f(acc,dat[k]);
            return -1;
        }
        int vl=findright(st,check,acc,2*k+1,l,m);
        if(~vl) return vl;
        return findright(st,check,acc,2*k+2,m,r);
    }

    template<typename C>
    int findright(int st,C &check){
        T acc=ti;
        return findright(st,check,acc,0,0,n);
    }//条件を満たす最小のidxを返す

    template<typename C>
    int findleft(int st,C &check,T &acc,int k,int l,int r){
        if(l+1==r){
            acc=f(acc,dat[k]);
            return check(acc)?k-(n-1):INF;
        }
        int m=(l+r)/2;
        if(m>=st) return findleft(st,check,acc,2*k+1,l,m);
        if(st>=r&&!check(f(acc,dat[k]))){
            acc=f(acc,dat[k]);
            return INF;
        }
        int vr=findleft(st,check,acc,2*k+2,m,r);
        if(vr!=INF) return vr;
        return findleft(st,check,acc,2*k+1,l,m);
    }

    template<typename C>
    int findleft(int st,C &check){
        T acc=ti;
        return findleft(st,check,acc,0,0,n);
    }//条件を満たす最大のidxを返す

};

int main(){

    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N,Q;cin>>N>>Q;
    vector<ll> pos(N);
    vector<ll> w(N);

    for(int i=0;i<N;i++){
        cin>>pos[i];
        pos[i]-=i;
    }

    for(int i=0;i<N;i++){
        cin>>w[i];
    }

    SegmentTree<pair<ll,ll>> seg(N,
                                 [](pair<ll,ll> a,pair<ll,ll> b){return mp((a.fi+b.fi)%mod,(a.se+b.se)%mod);},
                                 mp(0,0));

    SegmentTree<ll> wsum(N,
                         w,
                         [](ll a,ll b){return a+b;},
                         0);

    for(int i=0;i<N;i++){
        seg.update(i,mp(w[i]*pos[i]%mod,(w[i]*(mod-pos[i]))%mod));
    }

    while(Q--){
        ll l,r;cin>>l>>r;
        if(l<0){
            l*=-1;
            l--;
            seg.update(l,mp(r*pos[l]%mod,(r*(mod-pos[l]))%mod));
            wsum.update(l,r);
            w[l]=r;
        }else{
            l--;
            r--;

            ll left=l,right=r+1;

            ll sum=wsum.query(left,right);

            while(right-left>1){
                ll mid=(left+right)/2;
                ll a=wsum.query(l,mid),b=wsum.query(l,mid+1);

                if(a*2<=sum&&b*2>=sum){
                    left=mid;
                    break;
                }else if(a*2>sum) right=mid;
                else left=mid;
            }

            int d=left;

            ll lsum=0,rsum=0;

            lsum+=seg.query(l,d).se-(wsum.query(l,d)%mod*(mod-pos[d]))%mod+mod;
            rsum+=seg.query(d,r+1).fi-wsum.query(d,r+1)%mod*pos[d]%mod+mod;

            /*ll ans=0;

            for(int i=l;i<=r;i++){
                ans+=abs(pos[d]-pos[i])*w[i];
                ans%=mod;
            }

            cout<<ans<<"\n";*/

            cout<<(lsum+rsum)%mod<<"\n";

        }
    }
}

#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

namespace IO {
    const int BUFFER_SIZE = 4096;

    char input_buffer[BUFFER_SIZE];
    int input_pos = BUFFER_SIZE;
    int input_read = BUFFER_SIZE;

    char output_buffer[BUFFER_SIZE];
    int output_pos = 0;

    void _update_input_buffer() {
        if (input_pos >= input_read && input_read == BUFFER_SIZE) {
            input_read = fread(input_buffer, sizeof(char), BUFFER_SIZE, stdin);
            input_pos = 0;
        }
    }

    char next_char(bool advance = true) {
        _update_input_buffer();
        return input_buffer[advance ? input_pos++ : input_pos];
    }

    void skip_whitespace() {
        while (isspace(next_char(false)))
            next_char();
    }

    bool input_finished() {
        skip_whitespace();
        return input_pos >= input_read && input_read < BUFFER_SIZE;
    }

    template<typename T>
    void read_int(T &number) {
        skip_whitespace();
        bool negative = next_char(false) == '-';

        if (negative)
            next_char();

        number = 0;

        while (isdigit(next_char(false)))
            number = 10 * number + (next_char() - '0');

        if (negative)
            number = -number;
    }

    void flush_output() {
        fwrite(output_buffer, sizeof(char), output_pos, stdout);
        output_pos = 0;
    }

    void write_char(char c) {
        if (output_pos == BUFFER_SIZE)
            flush_output();

        output_buffer[output_pos++] = c;
    }

    template<typename T>
    void write_int(T number, char after = 0) {
        if (number < 0) {
            write_char('-');
            number = -number;
        }

        static char number_buffer[100];
        int length = 0;

        do {
            number_buffer[length++] = number % 10 + '0';
            number /= 10;
        } while (number > 0);

        for (int i = length - 1; i >= 0; i--)
            write_char(number_buffer[i]);

        if (after)
            write_char(after);
    }

    // Make sure flush_output() is called at the end of the program.
    bool exit_success = atexit(flush_output) == 0;
}

const int MOD = 1e9 + 7;

struct tree_node {
    long long w_sum, aw_sum;

    tree_node() : w_sum(0), aw_sum(0) {}

    void join(const tree_node &other) {
        w_sum += other.w_sum;
        aw_sum += other.aw_sum;
    }
};

int N, LOG, Q;
vector<int> A, W;
vector<tree_node> tree;

// O(N) initialization of our BIT.
void build_tree() {
    for (int i = 1; i <= N; i++) {
        for (int k = (i & -i) >> 1; k > 0; k >>= 1)
            tree[i].join(tree[i - k]);

        tree[i].w_sum += W[i - 1];
        tree[i].aw_sum = (tree[i].aw_sum + (long long) W[i - 1] * A[i - 1]) % MOD;
    }
}

void tree_update(int index, long long w_change, int a) {
    int aw_change = (MOD + w_change) * a % MOD;

    for (int i = index + 1; i <= N; i += i & -i) {
        tree[i].w_sum += w_change;
        tree[i].aw_sum += aw_change;
    }
}

tree_node tree_query(int count) {
    tree_node answer;

    for (int i = count; i > 0; i -= i & -i)
        answer.join(tree[i]);

    return answer;
}

int solve(int start, int end) {
    tree_node end_range = tree_query(end);
    tree_node start_range = tree_query(start);
    long long search = (start_range.w_sum + end_range.w_sum + 1) / 2;
    int goal = 0;
    tree_node goal_range;

    for (int k = LOG - 1; k >= 0; k--)
        if (goal + (1 << k) <= N && goal_range.w_sum + tree[goal + (1 << k)].w_sum < search) {
            goal += 1 << k;
            goal_range.join(tree[goal]);
        }

    // goal is the last point such that the w_sum of [start, goal) < the w_sum of [goal, end)
    assert(start <= goal && goal < end);
    long long left_w_sum = goal_range.w_sum - start_range.w_sum;
    long long right_w_sum = end_range.w_sum - goal_range.w_sum;
    assert(left_w_sum < right_w_sum);
    long long left_aw_sum = goal_range.aw_sum - start_range.aw_sum;
    long long right_aw_sum = end_range.aw_sum - goal_range.aw_sum;

    // result = sum W[i] * |A[i] - A[goal]|
    long long result = ((left_w_sum - right_w_sum) % MOD * A[goal] + right_aw_sum - left_aw_sum) % MOD;
    if (result < 0) result += MOD;
    return result;
}

int main() {
    assert(IO::exit_success);
    IO::read_int(N);
    IO::read_int(Q);
    A.resize(N);
    W.resize(N);
    LOG = 32 - __builtin_clz(N);
    assert(1 << LOG > N);
    tree.resize(N + 1);

    for (int i = 0; i < N; i++) {
        IO::read_int(A[i]);
        A[i] -= i;
    }

    for (int i = 0; i < N; i++)
        IO::read_int(W[i]);

    build_tree();

    for (int q = 0; q < Q; q++) {
        int x, y;
        IO::read_int(x);
        IO::read_int(y);

        if (x < 0) {
            x = -x - 1;
            tree_update(x, y - W[x], A[x]);
            W[x] = y;
        } else {
            IO::write_int(solve(x - 1, y), '\n');
        }
    }
}

#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

namespace IO {
    const int BUFFER_SIZE = 4096;
    const int NUMBER_BUFFER = 100;

    FILE *input_stream = stdin;
    FILE *output_stream = stdout;

    char input_buffer[BUFFER_SIZE];
    int input_pos = BUFFER_SIZE;
    int input_read = BUFFER_SIZE;

    char output_buffer[BUFFER_SIZE];
    int output_pos = 0;

    char number_buffer[NUMBER_BUFFER];

    void init(const char *input_file, const char *output_file) {
        input_stream = fopen(input_file, "r");
        output_stream = fopen(output_file, "w");
    }

    void _update_input_buffer() {
        if (input_pos >= input_read && input_read == BUFFER_SIZE) {
            input_read = fread(input_buffer, sizeof(char), BUFFER_SIZE, input_stream);
            input_pos = 0;
        }
    }

    char next_char(bool advance = true) {
        _update_input_buffer();
        return input_buffer[advance ? input_pos++ : input_pos];
    }

    bool on_whitespace() {
        return isspace(next_char(false));
    }

    bool on_digit() {
        return isdigit(next_char(false));
    }

    void skip_whitespace() {
        while (on_whitespace())
            next_char();
    }

    bool input_finished() {
        skip_whitespace();
        return input_pos >= input_read && input_read < BUFFER_SIZE;
    }

    template<typename T>
    void read_int(T &number) {
        skip_whitespace();
        bool negative = next_char(false) == '-';

        if (negative)
            next_char();

        number = 0;

        while (on_digit())
            number = 10 * number + (next_char() - '0');

        if (negative)
            number = -number;
    }

    void flush_output() {
        fwrite(output_buffer, sizeof(char), output_pos, output_stream);
        output_pos = 0;
    }

    void write_char(char c) {
        if (output_pos == BUFFER_SIZE)
            flush_output();

        output_buffer[output_pos++] = c;
    }

    template<typename T>
    void write_int(T number, char after = 0) {
        if (number < 0) {
            write_char('-');
            number = -number;
        }

        int length = 0;

        do {
            number_buffer[length++] = number % 10 + '0';
            number /= 10;
        } while (number > 0);

        for (int i = length - 1; i >= 0; i--)
            write_char(number_buffer[i]);

        if (after)
            write_char(after);
    }

    // Make sure flush_output() is called at the end of the program.
    struct Dummy {
        ~Dummy() {
            flush_output();
        }
    } dummy;
}

const int MOD = 1e9 + 7;

template<typename T1, typename T2>
void mod_add(T1 &a, T2 b) {
    a += b;

    if (a >= MOD)
        a -= MOD;
}

struct tree_node {
    long long w_sum;
    int aw_sum;

    tree_node() : w_sum(0), aw_sum(0) {}

    void join(const tree_node &other) {
        w_sum += other.w_sum;
        mod_add(aw_sum, other.aw_sum);
    }
};

int N, LOG, Q;
vector<int> A, W;
vector<tree_node> tree;

// O(N) initialization of our BIT.
void build_tree() {
    for (int i = 1; i <= 1 << LOG; i++) {
        int bit = i & -i;
        int position = i - bit;

        for (int k = bit >> 1; k > 0; k >>= 1) {
            position += k;
            tree[i].join(tree[position]);
        }

        if (i <= N) {
            tree[i].w_sum += W[i - 1];
            tree[i].aw_sum = (tree[i].aw_sum + (long long) W[i - 1] * A[i - 1]) % MOD;
        }
    }
}

void tree_update(int index, long long w_change, int a) {
    int aw_change = (MOD + w_change) * a % MOD;

    for (int i = index + 1; i <= 1 << LOG; i += i & -i) {
        tree[i].w_sum += w_change;
        mod_add(tree[i].aw_sum, aw_change);
    }
}

tree_node tree_query(int count) {
    tree_node answer;

    for (int i = count; i > 0; i -= i & -i)
        answer.join(tree[i]);

    return answer;
}

int solve(int start, int end) {
    tree_node tree_end = tree_query(end);
    tree_node tree_start = tree_query(start);
    long long search = (tree_end.w_sum + tree_start.w_sum + 1) / 2;
    int goal = 0;
    long long w_sum = 0, aw_sum = 0;

    for (int k = LOG - 1; k >= 0; k--)
        if (search > w_sum + tree[goal + (1 << k)].w_sum) {
            goal += 1 << k;
            w_sum += tree[goal].w_sum;
            aw_sum += tree[goal].aw_sum;
        }

    assert(start <= goal && goal < end);
    long long result = ((w_sum - tree_start.w_sum) - (tree_end.w_sum - w_sum)) % MOD * A[goal] +
        (tree_end.aw_sum - aw_sum) - (aw_sum - tree_start.aw_sum);
    result %= MOD;
    mod_add(result, MOD);
    return result;
}

int main() {
    IO::read_int(N);
    IO::read_int(Q);
    A.resize(N);
    W.resize(N);
    LOG = 32 - __builtin_clz(N);
    tree.resize((1 << LOG) + 1);

    for (int i = 0; i < N; i++) {
        IO::read_int(A[i]);
        A[i] -= i;
    }

    for (int i = 0; i < N; i++)
        IO::read_int(W[i]);

    build_tree();

    for (int q = 0; q < Q; q++) {
        int x, y;
        IO::read_int(x);
        IO::read_int(y);

        if (x < 0) {
            x = -x - 1;
            tree_update(x, y - W[x], A[x]);
            W[x] = y;
        } else {
            IO::write_int(solve(x - 1, y), '\n');
        }
    }
}

#include<bits/stdc++.h>

using namespace std;

/*************************************I love Poland*************************************/

#define int long long

const int N = 2e5 + 5, mod = 1e9 + 7, limA = 1e9 + 7;
int n, q, a[N], w[N];

struct Bit {
    int a[1 << 20];
    Bit () { memset(a, 0, sizeof a); }
    void update (int pos, int val, bool _) {
        for (; pos < (1 << 20); pos += pos & -pos) {
            a[pos] += val;
            if (_) a[pos] %= mod;
        }
    }
    int get (int pos, bool _) {
        int ret = 0;
        for (; pos > 0; pos -= pos & -pos) {
            ret += a[pos];
            if (_) ret %= mod;
        }
        return ret;
    }
    int findPos (int S) {
        int ret = 0, sum = 0;
        for (int i = 19; i >= 0; --i) if (2 * (sum + a[ret | (1 << i)]) < S) ret |= (1 << i), sum += a[ret];
        return ret + 1;
    }
} bit[3];

int getAns (int l, int mid, int r) {
    int ret = 0;
    ret += bit[1].get(r, 1) - bit[1].get(mid, 1) - (a[mid] - mid) * (bit[0].get(r, 1)- bit[0].get(mid, 1) );
    ret %= mod;
    ret += bit[2].get(mid - 1, 1) - bit[2].get(l - 1, 1) - (limA - a[mid] - n + mid - 1) * (bit[0].get(mid - 1, 1) - bit[0].get(l - 1, 1) );
    ret %= mod;
    return (ret + mod) % mod;
}

signed main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> q;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i <= n; ++i) cin >> w[i];
    for (int i = 1; i <= n; ++i) {
        bit[0].update(i, w[i], 0);
        bit[1].update(i, (w[i] * (a[i] - i) ) % mod, 1);
        bit[2].update(i, (w[i] * (limA - a[i] - (n - i + 1) ) ) % mod, 1);
    }

    while (q --) {
        int x, y; cin >> x >> y;
        if (x < 0) {
            bit[0].update(-x, -w[-x], 0);
            bit[1].update(-x, -(w[-x] * (a[-x] + x) ) % mod, 1);
            bit[2].update(-x, -(w[-x] * (limA - a[-x] - (n + x + 1) ) ) % mod, 1);
            w[-x] = y;
            bit[0].update(-x, w[-x], 0);
            bit[1].update(-x, (w[-x] * (a[-x] + x) ) % mod, 1);
            bit[2].update(-x, (w[-x] * (limA - a[-x] - (n + x + 1) ) ) % mod, 1);
        }
        else {
            int pos = bit[0].findPos(bit[0].get(x - 1, 0) + bit[0].get(y, 0) );
            cout << getAns(x, pos, y) << '\n';
        }
    }

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define mem(x) memset(x,0,sizeof(x))
#define mes(x,y) memset(x,y,sizeof(x))
#define max(x,y) ( (x)>(y)?(x):(y) )
#define min(x,y) ( (x)<(y)?(x):(y) )
#define dd(x) cout<<#x<<"="<<x<<' ';
#define de(x) cout<<#x<<"="<<x<<'\n';
#define DBG cout<<"^_^"<<endl;
#define vi vector<int>
#define pb push_back
#define INF 0x3f3f3f3f
typedef long long ll;
const int SI=2e5+100;
const ll mod=1e9+7;
struct Bit_Tree{
	ll N;
	ll bit[SI];
	ll sum(ll i){
		ll s=0;
		while( i>0 ){
			s+=bit[i];
			i-=i&-i;
		}
		return s;
	}
	void add(ll i,ll x){
		while(i<=N){
			bit[i]+=x;
			i+=i&-i;
		}
	}
};
Bit_Tree W;
ll a[SI],w[SI];
ll n,q;
ll bit[SI];
inline void add(int i,ll v)
{
	v%=mod;
	while( i<=n ){
		bit[i]=( bit[i]+v+mod)%mod;
		i+=i&-i;
	}
}
inline ll sum(int i)
{
	ll res=0;
	while( i>0 ){
		res=( res+bit[i])%mod;
		i-=i&-i;
	}
	return res;
}
inline void Change(ll ad,ll val)
{
	ll v=W.sum(ad)-W.sum(ad-1);
	W.add(ad,-v);
	W.add(ad,val);
	v=( sum(ad)-sum(ad-1)+mod )%mod;
	add(ad,-v);
	add(ad,val*a[ad] );
}
inline void Query( ll ql,ll qr )
{
	int l=ql,r=qr,mid,ans;
	ll left=W.sum(ql-1);
	while( l<=r )
		{
			mid=(l+r)>>1;
			if ( W.sum(mid)-left>=W.sum(qr)-W.sum(mid) )
				{
					ans=mid;
					r=mid-1;
				}
			else
				l=mid+1;
		}
	ll r1=a[ ans ]*( (W.sum(ans)-left)%mod )%mod;
	ll r2=a[ ans ]*( ( W.sum(qr)-W.sum(ans) )%mod )%mod;
	ll res=( r1-( sum(ans)-sum(ql-1) +mod)%mod +mod+mod )%mod+( ( sum(qr)-sum(ans)+mod )%mod-r2+mod +mod+mod)%mod;
	res%=mod;
	cout<<res<<endl;
}
int main()
{
	cin>>n>>q;
	W.N=n;
	mes(W.bit,0);
	for( ll i=1;i<=n;i++ )
		{
			cin>>a[i];
			a[i]-=i;
		}
	for( ll i=1;i<=n;i++ )
		{
			cin>>w[i];
			W.add(i,w[i]);
			add(i,w[i]*a[i]);
		}
	ll l,r;
	while( q-- )
		{
			cin>>l>>r;
			if ( l<0 )
				Change(-l,r);
			else
				Query(l,r);
		}
    return 0;
}

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=200005,tt=1e9+7;
int n,Q,a[maxn],w[maxn],T[maxn],t[4*maxn],t1[maxn];
void Ins(int x,int y){for (int i=x;i<=n;i+=(i&(-i))) T[i]+=y;}
int Get(int x){int r=0; for (int i=x;i;i-=(i&(-i))) r+=T[i]; return r;}
void ins1(int x,int y){for (int i=x;i<=n;i+=(i&(-i))) t1[i]=(t1[i]+y)%tt;}
int get1(int x){int r=0; for (int i=x;i;i-=(i&(-i))) r=(r+t1[i])%tt; return r;}
int get(int L,int R){
    int l=L,r=R,all=Get(R)-Get(L-1),ret=R;
    while (l<=r){
        int mid=(l+r)>>1;
        if (2*(Get(mid)-Get(L-1))>=all) ret=mid,r=mid-1; else l=mid+1;
    }
    return ret;
}
void ins(int x,int l,int r,int p){
    if (l==r) {t[x]=1ll*a[l]*w[l]%tt; return;}
    int mid=(l+r)>>1;
    if (p<=mid) ins(2*x,l,mid,p); else ins(2*x+1,mid+1,r,p);
    t[x]=(t[2*x]+t[2*x+1])%tt;
}
int query(int x,int l,int r,int ql,int qr){
    if (l==ql&&r==qr) return t[x];
    int mid=(l+r)>>1;
    if (qr<=mid) return query(2*x,l,mid,ql,qr);
    else if (ql>mid) return query(2*x+1,mid+1,r,ql,qr);
    else return (query(2*x,l,mid,ql,mid)+query(2*x+1,mid+1,r,mid+1,qr))%tt;
}
signed main(){
    scanf("%lld%lld",&n,&Q);
    for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
    for (int i=1;i<=n;i++) scanf("%lld",&w[i]),Ins(i,w[i]),ins(1,1,n,i),ins1(i,w[i]*i%tt);
    for (int i=1;i<=Q;i++){
        int x,y; scanf("%lld%lld",&x,&y);
        if (x<0){
            Ins(-x,-w[-x]); ins1(-x,tt-w[-x]*(-x)%tt);
            w[-x]=y; Ins(-x,y); ins1(-x,y*(-x)%tt);
            ins(1,1,n,-x);
        } else {
            int p=get(x,y),ret=0; //printf("!!!%lld\n",p);
            if (p!=x) ret+=((a[p]-p)*((Get(p-1)-Get(x-1))%tt)%tt-query(1,1,n,x,p-1)+get1(p-1)-get1(x-1))%tt;
            if (p!=y) ret+=(query(1,1,n,p+1,y)-(a[p]-p)*((Get(y)-Get(p))%tt)%tt-get1(y)+get1(p))%tt;
            ret=(ret%tt+tt)%tt;
            printf("%lld\n",ret);
        }
    }
    return 0;
}

#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

const int MOD = 1e9 + 7;

template<typename T1, typename T2>
void mod_add(T1 &a, T2 b) {
    a += b;

    if (a >= MOD)
        a -= MOD;
}

struct segment_change {
    int new_w;
    int a;

    segment_change(int _new_w = 0, int _a = 0) : new_w(_new_w), a(_a) {}
};

struct segment {
    long long w_sum;
    int aw_sum;

    segment() : w_sum(0), aw_sum(0) {}

    void apply(int start, int end, const segment_change &change) {
        assert(end - start == 1);
        w_sum = change.new_w;
        aw_sum = (long long) change.a * change.new_w % MOD;
    }

    void join(const segment &other) {
        w_sum += other.w_sum;
        mod_add(aw_sum, other.aw_sum);
    }

    void join(const segment &a, const segment &b) {
        *this = a;
        join(b);
    }
};

struct seg_tree {
    int tree_n;
    vector<segment> tree;

    seg_tree(int n = 0) {
        tree_n = 0;

        if (n > 0)
            init(n);
    }

    void init(int n) {
        tree_n = 1;

        while (tree_n < n)
            tree_n *= 2;

        tree.assign(2 * tree_n, segment());
    }

    void build(const vector<segment_change> &initial) {
        int n = initial.size();
        assert(n <= tree_n);

        for (int i = 0; i < n; i++)
            tree[tree_n + i].apply(i, i + 1, initial[i]);

        for (int position = tree_n - 1; position > 0; position--)
            tree[position].join(tree[2 * position], tree[2 * position + 1]);
    }

    template<typename T_range_op, typename T_join_op>
    void process_range(int position, int start, int end, int a, int b, T_range_op &&range_op, T_join_op &&join_op) {
        if (a <= start && end <= b) {
            range_op(position, start, end);
            return;
        }

        if (position >= tree_n)
            return;

        int mid = (start + end) / 2;
        if (a < mid) process_range(2 * position, start, mid, a, b, range_op, join_op);
        if (b > mid) process_range(2 * position + 1, mid, end, a, b, range_op, join_op);
        join_op(position);
    }

    segment query(int a, int b) {
        segment answer;

        process_range(1, 0, tree_n, a, b, [&](int position, int, int) {
            answer.join(tree[position]);
        }, [&](int) {});

        return answer;
    }

    void update(int a, int b, const segment_change &change) {
        process_range(1, 0, tree_n, a, b, [&](int position, int start, int end) {
            tree[position].apply(start, end, change);
        }, [&](int position) {
            tree[position].join(tree[2 * position], tree[2 * position + 1]);
        });
    }

    // Returns the first index k such that query(0, k).w_sum >= w_sum
    int lower_bound(long long w_sum) {
        int position = 1;

        while (position < tree_n)
            if (w_sum <= tree[2 * position].w_sum) {
                position = 2 * position;
            } else {
                w_sum -= tree[2 * position].w_sum;
                position = 2 * position + 1;
            }

        return position - tree_n + 1;
    }
};

int N, Q;
vector<int> A, W;
seg_tree tree;

int solve(int start, int end) {
    long long total_w = tree.query(start, end).w_sum;
    long long start_w = tree.query(0, start).w_sum;

    // We need 2 * tree.query(start, goal + 1).w_sum >= total_w
    int goal = tree.lower_bound((total_w + 1) / 2 + start_w) - 1;
    assert(start <= goal && goal < end);

    // goal is the meeting point
    segment left = tree.query(start, goal);
    segment right = tree.query(goal, end);
    long long result = (left.w_sum - right.w_sum) % MOD * (long long) A[goal] + right.aw_sum - left.aw_sum;
    return (result % MOD + MOD) % MOD;
}

int main() {
    scanf("%d %d", &N, &Q);
    A.resize(N);
    W.resize(N);

    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
        A[i] -= i;
    }

    vector<segment_change> initial(N);

    for (int i = 0; i < N; i++) {
        scanf("%d", &W[i]);
        initial[i] = segment_change(W[i], A[i]);
    }

    tree.init(N);
    tree.build(initial);

    for (int q = 0; q < Q; q++) {
        int x, y;
        scanf("%d %d", &x, &y);

        if (x < 0) {
            x = -x - 1;
            tree.update(x, x + 1, segment_change(y, A[x]));
        } else {
            printf("%d\n", solve(x - 1, y));
        }
    }
}

#include<bits/stdc++.h>
#define Fst first
#define Snd second
#define RG register
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef unsigned long long ULL;
template<typename T> inline void read(T& x) {
	char c = getchar();
	bool f = false;
	for (x = 0; !isdigit(c); c = getchar()) {
		if (c == '-') {
			f = true;
		}
	}
	for (; isdigit(c); c = getchar()) {
		x = x * 10 + c - '0';
	}
	if (f) {
		x = -x;
	}
}
template<typename T, typename... U> inline void read(T& x, U& ... y) {
	read(x), read(y...);
}
const int N=2e5+10,P=1e9+7;
int n,Q;
int A[N],W[N];
LL X[N],S[N],G[N];
#define Lowbit(a) (a&-a)
void Modify(int pos,int val) {
	while(pos<=n) {
		X[pos]+=val;
		pos+=Lowbit(pos);
	}
}
LL Sum(int pos) {
	LL res=0;
	while(pos) {
		res+=X[pos];
		pos-=Lowbit(pos);
	}
	return res;
}
void ADD(int pos,int val) {
	while(pos<=n) {
		S[pos]+=val;
		if(S[pos]>=P) S[pos]-=P;
		pos+=Lowbit(pos);
	}
}
LL Get(int pos) {
	LL res=0;
	while(pos) {
		res+=S[pos];
		if(res>=P) res-=P;
		pos-=Lowbit(pos);
	}
	return res;
}
void Update(int pos,int val) {
	while(pos<=n) {
		G[pos]+=val;
		if(S[pos]>=P) G[pos]-=P;
		pos+=Lowbit(pos);
	}
}
LL Calc(int pos) {
	LL res=0;
	while(pos) {
		res+=G[pos];
		if(res>=P) res-=P;
		pos-=Lowbit(pos);
	}
	return res;
}
int Find(int l,int r,LL x,LL Sl) {
	if(l==r) return l;
	int mid=l+r>>1;
	LL t=Sum(mid)-Sl;
	if(t>=x-t) return Find(l,mid,x,Sl);
	return Find(mid+1,r,x,Sl);
}
int Query(int l,int r) {
	if(l==r) return 0;
	int p=Find(l,r,Sum(r)-Sum(l-1),Sum(l-1));
	LL SUM=(Sum(p)-Sum(l-1))%P,S1=1ll*A[p]*SUM%P,S2=1ll*p*SUM%P,S3=(Calc(p)-Calc(l-1))%P,S4=(Get(p)-Get(l-1))%P;
	LL t1=((S1-S2+S3-S4)%P+P)%P;
	SUM=(Sum(r)-Sum(p))%P,S1=(Get(r)-Get(p))%P,S2=1ll*A[p]*SUM%P,S3=(Calc(r)-Calc(p))%P,S4=1ll*p*SUM%P;
	LL t2=((S1-S2-S3+S4)%P+P)%P;
	return (t1+t2)%P;
}
int main() {
#ifdef rua
	freopen("GG.out","w",stdout);
#endif
	read(n,Q);
	for(int i=1;i<=n;++i) read(A[i]);
	for(int i=1;i<=n;++i) read(W[i]),Modify(i,W[i]),ADD(i,1ll*W[i]*A[i]%P),Update(i,1ll*i*W[i]%P);
	while(Q--) {
		int l,r; read(l,r);
		if(l<0) Modify(-l,r-W[-l]),ADD(-l,(1ll*(r-W[-l])*A[-l]%P+P)%P),Update(-l,(1ll*(r-W[-l])*(-l)%P+P)%P),W[-l]=r;
		else printf("%d\n",Query(l,r));
	}
	return 0;
}

#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

namespace IO {
    const int BUFFER_SIZE = 1 << 15;

    char input_buffer[BUFFER_SIZE];
    int input_pos = 0, input_len = 0;

    char output_buffer[BUFFER_SIZE];
    int output_pos = 0;

    uint8_t lookup[100];

    void _update_input_buffer() {
        input_len = fread(input_buffer, sizeof(char), BUFFER_SIZE, stdin);
        input_pos = 0;
    }

    inline char next_char(bool advance = true) {
        if (input_pos >= input_len)
            _update_input_buffer();

        return input_buffer[advance ? input_pos++ : input_pos];
    }

    inline bool isspace(char c) {
        return (unsigned char) (c - '\t') < 5 || c == ' ';
    }

    template<typename T>
    inline void read_int(T &number) {
        while (isspace(next_char(false)))
            next_char();

        bool negative = next_char(false) == '-';

        if (negative)
            next_char();

        number = 0;

        while (isdigit(next_char(false)))
            number = 10 * number + (next_char() - '0');

        if (negative)
            number = -number;
    }

    void _flush_output() {
        fwrite(output_buffer, sizeof(char), output_pos, stdout);
        output_pos = 0;
    }

    inline void write_char(char c) {
        if (output_pos == BUFFER_SIZE)
            _flush_output();

        output_buffer[output_pos++] = c;
    }

    template<typename T>
    inline void write_int(T number, char after = 0) {
        if (number < 0) {
            write_char('-');
            number = -number;
        }

        static char number_buffer[100];
        int length = 0;

        do {
            if (number < 10) {
                number_buffer[length++] = number + '0';
                number = 0;
            } else {
                uint8_t lookup_value = lookup[number % 100];
                number /= 100;
                number_buffer[length++] = (lookup_value & 15) + '0';
                number_buffer[length++] = (lookup_value >> 4) + '0';
            }
        } while (number != 0);

        for (int i = length - 1; i >= 0; i--)
            write_char(number_buffer[i]);

        if (after)
            write_char(after);
    }

    void init() {
        // Make sure _flush_output() is called at the end of the program.
        bool exit_success = atexit(_flush_output) == 0;
        assert(exit_success);

        for (int i = 0; i < 100; i++)
            lookup[i] = (i / 10 << 4) + i % 10;
    }
}

const int MOD = 1e9 + 7;

struct tree_node {
    long long w_sum, aw_sum;

    tree_node() : w_sum(0), aw_sum(0) {}

    void join(const tree_node &other) {
        w_sum += other.w_sum;
        aw_sum += other.aw_sum;
    }
};

int N, LOG, Q;
vector<int> A, W;
vector<tree_node> tree;

// O(N) initialization of our BIT.
void build_tree() {
    for (int i = 1; i <= N; i++) {
        for (int k = (i & -i) >> 1; k > 0; k >>= 1)
            tree[i].join(tree[i - k]);

        tree[i].w_sum += W[i - 1];
        tree[i].aw_sum = (tree[i].aw_sum + (long long) W[i - 1] * A[i - 1]) % MOD;
    }
}

void tree_update(int index, long long w_change, int a) {
    int aw_change = (MOD + w_change) * a % MOD;

    for (int i = index + 1; i <= N; i += i & -i) {
        tree[i].w_sum += w_change;
        tree[i].aw_sum += aw_change;
    }
}

tree_node tree_query(int count) {
    tree_node answer;

    for (int i = count; i > 0; i -= i & -i)
        answer.join(tree[i]);

    return answer;
}

int solve(int start, int end) {
    tree_node end_range = tree_query(end);
    tree_node start_range = tree_query(start);
    long long search = (start_range.w_sum + end_range.w_sum + 1) / 2;
    int goal = 0;
    tree_node goal_range;

    for (int k = LOG - 1; k >= 0; k--)
        if (goal + (1 << k) <= N && goal_range.w_sum + tree[goal + (1 << k)].w_sum < search) {
            goal += 1 << k;
            goal_range.join(tree[goal]);
        }

    // goal is the last point such that the w_sum of [start, goal) < the w_sum of [goal, end)
    assert(start <= goal && goal < end);
    long long left_w_sum = goal_range.w_sum - start_range.w_sum;
    long long right_w_sum = end_range.w_sum - goal_range.w_sum;
    assert(left_w_sum < right_w_sum);
    long long left_aw_sum = goal_range.aw_sum - start_range.aw_sum;
    long long right_aw_sum = end_range.aw_sum - goal_range.aw_sum;

    // result = sum W[i] * |A[i] - A[goal]|
    long long result = ((left_w_sum - right_w_sum) % MOD * A[goal] + right_aw_sum - left_aw_sum) % MOD;
    if (result < 0) result += MOD;
    return result;
}

int main() {
    IO::init();
    IO::read_int(N);
    IO::read_int(Q);
    A.resize(N);
    W.resize(N);
    LOG = 32 - __builtin_clz(N);
    assert(1 << LOG > N);
    tree.resize(N + 1);

    for (int i = 0; i < N; i++) {
        IO::read_int(A[i]);
        A[i] -= i;
    }

    for (int i = 0; i < N; i++)
        IO::read_int(W[i]);

    build_tree();

    for (int q = 0; q < Q; q++) {
        int x, y;
        IO::read_int(x);
        IO::read_int(y);

        if (x < 0) {
            x = -x - 1;
            tree_update(x, y - W[x], A[x]);
            W[x] = y;
        } else {
            IO::write_int(solve(x - 1, y), '\n');
        }
    }
}

#include <bits/stdc++.h>

#define int long long

#define fi first
#define se second

const int N = 3e5 + 10, M = 60, Mo = 1e9 + 7;

// std::vector<int> f[N];

int a[N], n, x, y, l, r, mid,  q, f2[N], w[N];
long long f1[N];

inline int read() {
    int x = 0, k = 1; char c = getchar();
    for (; c < 48 || c > 57; c = getchar()) k ^= (c == '-');
    for (; c >= 48 && c <= 57; c = getchar()) x = x * 10 + (c ^ 48);
    return k ? x : -x;
}

inline void add1(int x, int y) {
    for (; x <= n; x += x & (-x))
        f1[x] = f1[x] + y;
}

inline void add2(int x, int y) {
    for (; x <= n; x += x & (-x))
        f2[x] = (f2[x] + y) % Mo;
}

inline int ask1(int x) {
    int ans = 0;
    for (; x; x -= x & (-x))
        ans += f1[x];
    return ans;
}

inline int ask2(int x) {
    int ans = 0;
    for (; x; x -= x & (-x))
        ans = (ans + f2[x]) % Mo;
    return ans;
}

signed main() {
    n = read(), q = read();
    for (int i = 1; i <= n; i++)
        a[i] = read() - i;
    for (int i = 1; i <= n; i++)
        w[i] = read();
    for (int i = 1; i <= n; i++) {
        add2(i, 1LL * a[i] * w[i] % Mo);
        add1(i, w[i]);
    }
    for (; q--; ) {
        x = read(), y = read();
        if (x < 0) {
            x = -x;
            add1(x, y - w[x]), add2(x, 1LL * a[x] * (y - w[x] + Mo) % Mo);
			w[x] = y;
        }
        else {
            long long ansl = ask1(x - 1), ansr = ask1(y), ans = 0, now;
            for (l = x, r = y, mid = (x + y) / 2; l <= r; mid = (l + r) / 2) {
                now = ask1(mid - 1);
                if (now - ansl << 1 <= ansr - ansl) {
                    ans = mid, l = mid + 1;
                }
                else r = mid - 1;
            }
            printf("%d\n", (((ask1(ans - 1) - ansl - ansr + ask1(ans)) % Mo * a[ans] % Mo - ask2(ans - 1) + ask2(x - 1) + ask2(y) - ask2(ans)) % Mo + Mo) % Mo);
        }
    }
    return 0;
}

#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

const int N = 2e5 + 7;
const int M = 1e9 + 7;

ll f_w[N];
ll f_aw[N];

void inc_w(int x, int y)
{
    for (; x < N; x = (x | (x + 1)))
    {
        f_w[x] += y;
    }
}

void inc_aw(int x, ll y)
{
    y %= M;
    if (y < 0) y += M;
    for (; x < N; x = (x | (x + 1)))
    {
        f_aw[x] += y;
        if (f_aw[x] >= M)
        {
            f_aw[x] -= M;
        }
    }
}

ll get_w(int x)
{
    ll res = 0;
    for (; x >= 0; x = (x & (x + 1)) - 1)
    {
        res += f_w[x];
    }
    return res;
}

int get_aw(int x)
{
    int res = 0;
    for (; x >= 0; x = (x & (x + 1)) - 1)
    {
        res += f_aw[x];
        if (res >= M) res -= M;
    }
    return res;
}

ll get_w(int l, int r)
{
    return get_w(r) - get_w(l - 1);
}

int get_aw(int l, int r)
{
    int res = get_aw(r);
    res -= get_aw(l - 1);
    if (res < 0) res += M;
    return res;
}

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector <int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        a[i] -= i;
    }
    vector <int> w(n);
    for (int i = 0; i < n; i++)
    {
        cin >> w[i];
        inc_w(i, w[i]);
        inc_aw(i, a[i] * (ll) w[i]);
    }
    while (q--)
    {
        int x, y;
        cin >> x >> y;
        if (x < 0)
        {
            x = -x;
            x--;
            inc_w(x, -w[x]);
            inc_aw(x, -(a[x] * (ll) w[x]));
            w[x] = y;
            inc_w(x, w[x]);
            inc_aw(x, (a[x] * (ll) w[x]));
        }
        else
        {
            x--, y--;
            ll sum = get_w(x, y);
            ll need = sum / 2 + get_w(x - 1);
            int l = x - 1, r = y;
            while (l < r - 1)
            {
                int m = (l + r) / 2;
                if (get_w(m) <= need)
                {
                    l = m;
                }
                else
                {
                    r = m;
                }
            }
            int p = l + 1;
            ll ans = -get_aw(x, p) + get_aw(p + 1, y);
            if (ans < 0) ans += M;
            ans += (get_w(x, p) % M * (ll) a[p]) % M;
            if (ans >= M) ans -= M;
            ans -= (get_w(p + 1, y) % M * (ll) a[p]) % M;
            if (ans < 0) ans += M;
            cout << ans << '\n';
        }
    }
}

#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

const int MOD = 1e9 + 7;

template<typename T1, typename T2>
void mod_add(T1 &a, T2 b) {
    a += b;

    if (a >= MOD)
        a -= MOD;
}

struct tree_node {
    long long w_sum;
    int aw_sum;

    tree_node() : w_sum(0), aw_sum(0) {}

    void join(const tree_node &other) {
        w_sum += other.w_sum;
        mod_add(aw_sum, other.aw_sum);
    }
};

int N, LOG, Q;
vector<int> A, W;
vector<tree_node> tree;

// O(N) initialization of our BIT.
void build_tree() {
    for (int i = 1; i <= 1 << LOG; i++) {
        int bit = i & -i;
        int position = i - bit;

        for (int k = bit >> 1; k > 0; k >>= 1) {
            position += k;
            tree[i].join(tree[position]);
        }

        if (i <= N) {
            tree[i].w_sum += W[i - 1];
            tree[i].aw_sum = (tree[i].aw_sum + (long long) W[i - 1] * A[i - 1]) % MOD;
        }
    }
}

void tree_update(int index, long long w_change, int a) {
    int aw_change = (MOD + w_change) * a % MOD;

    for (int i = index + 1; i <= 1 << LOG; i += i & -i) {
        tree[i].w_sum += w_change;
        mod_add(tree[i].aw_sum, aw_change);
    }
}

tree_node tree_query(int count) {
    tree_node answer;

    for (int i = count; i > 0; i -= i & -i)
        answer.join(tree[i]);

    return answer;
}

int solve(int start, int end) {
    tree_node tree_end = tree_query(end);
    tree_node tree_start = tree_query(start);
    long long search = (tree_end.w_sum + tree_start.w_sum + 1) / 2;
    int goal = 0;
    long long w_sum = 0, aw_sum = 0;

    // Note: this search needs an extra check that goal + (1 << k) <= N if our updates only go up to N rather than to 1 << LOG.
    for (int k = LOG - 1; k >= 0; k--)
        if (search > w_sum + tree[goal + (1 << k)].w_sum) {
            goal += 1 << k;
            w_sum += tree[goal].w_sum;
            aw_sum += tree[goal].aw_sum;
        }

    assert(start <= goal && goal < end);
    long long result = ((w_sum - tree_start.w_sum) - (tree_end.w_sum - w_sum)) % MOD * A[goal] +
        (tree_end.aw_sum - aw_sum) - (aw_sum - tree_start.aw_sum);
    result %= MOD;
    mod_add(result, MOD);
    return result;
}

int main() {
    scanf("%d %d", &N, &Q);
    A.resize(N);
    W.resize(N);
    LOG = 32 - __builtin_clz(N);
    tree.resize((1 << LOG) + 1);

    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
        A[i] -= i;
    }

    for (int i = 0; i < N; i++)
        scanf("%d", &W[i]);

    build_tree();

    for (int q = 0; q < Q; q++) {
        int x, y;
        scanf("%d %d", &x, &y);

        if (x < 0) {
            x = -x - 1;
            tree_update(x, y - W[x], A[x]);
            W[x] = y;
        } else {
            printf("%d\n", solve(x - 1, y));
        }
    }
}

#include<bits/stdc++.h>
const int mod=1e9+7;
const int maxn=2e5+7;
int n,q,a[maxn],w[maxn];
typedef long long ll;
struct Fenwick1
{
	ll bs[maxn];
	void add(int x,ll y)
	{
		for(;x<=n;x+=x&-x) bs[x]+=y;
	}
	ll sum(int x)
	{
		ll s=0;
		for(;x>=1;x-=x&-x) s+=bs[x];
		return s;
	}
}B0;
struct Fenwick
{
	int bs[maxn];
	void add(int x,int y)
	{
		for(;x<=n;x+=x&-x) (bs[x]+=y)%=mod;
	}
	ll sum(int x)
	{
		int s=0;
		for(;x>=1;x-=x&-x) (s+=bs[x])%=mod;
		return s;
	}
}B1;
int main()
{
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;++i)
		scanf("%d",a+i),a[i]-=i;
	for(int i=1;i<=n;++i) scanf("%d",w+i);
	for(int i=1;i<=n;++i)
		B0.add(i,w[i]),
		B1.add(i,w[i]*1ll*a[i]%mod);
	while(q--)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if(x<0)
		{
			x=-x; int dt=y-w[x];
			w[x]=y; B0.add(x,dt);
			B1.add(x,dt*1ll*a[x]%mod);
		}
		else
		{
			ll sl=B0.sum(x-1),
			su=B0.sum(y)-sl;
			su=(su+1)/2;
			int l=x,r=y;
			while(l<r)
			{
				int m=(l+r)>>1;
				if(B0.sum(m)-sl>=su) r=m;
				else l=m+1;
			}
			int m=l;
			//mid pos is m
			ll ans=
			(B1.sum(y)-B1.sum(m))-(B0.sum(y)-B0.sum(m))%mod*1ll*(a[m])%mod
			-(B1.sum(m)-B1.sum(x-1))+(B0.sum(m)-B0.sum(x-1))%mod*(a[m])%mod;
			ans=(ans%mod+mod)%mod;
			printf("%d\n",int(ans));
		}
	}
}

#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define f first
#define s second

using namespace std;

const ll mod=1LL*1000*1000*1000+7;
ll ftree_S[200005];
ll ftree_wa[200005];
ll a[200005],w[200005];

void upd(ll *ftree,ll x,ll d)
{
          for(int i=x;i<200005;i|=i+1)
                    ftree[i]=ftree[i]+d;
}

ll normm(ll a) {
	if(a >= mod)
		a -= mod;
	if(a < 0)
		a += mod;
	return a;
}

ll norm(ll a) {
	return normm((a % mod));
}

ll mul(ll a, ll b) {
	return ((a * 1ll * b) % mod);
}

ll s(ll *ftree,ll x)
{
          ll res=0;
          for(int i=x;i>=0;i=(i&(i+1))-1)
                    res+=ftree[i];
          return res;
}

ll s(ll *ftree,ll l,ll r)
{
          return s(ftree,r)-s(ftree,l-1);
}

int n,q;

int main()
{
          ios_base::sync_with_stdio(0);
          cin>>n>>q;
          for(int i=1;i<=n;i++)
          {
                    cin>>a[i];
                    a[i]-=i;
          }
          for(int i=1;i<=n;i++)
          {
                    cin>>w[i];
                    upd(ftree_S,i,w[i]);
                    upd(ftree_wa,i,mul(w[i],a[i]));
          }

          for(int i=0;i<q;i++)
          {
                    ll x,y;
                    cin>>x>>y;
                    if(x<0)
                    {
                              x=-x;

                              upd(ftree_S,x,-w[x]);
                              upd(ftree_wa,x,-mul(w[x],a[x]));

                              w[x]=y;

                              upd(ftree_S,x,w[x]);
                              upd(ftree_wa,x,mul(w[x],a[x]));
                    }
                    else
                    {
                              ll l=x,r=y+1;
                              while(r-l>1)
                              {
                                        ll mid=(r+l)/2;
                                        if(2*s(ftree_S,x,mid-1)>s(ftree_S,x,y))
                                                  r=mid;
                                        else
                                                  l=mid;
                              }
                              ll res=0;
                              res=norm(mul(norm(s(ftree_S,x,l-1)),a[l])-norm(s(ftree_wa,x,l-1)));
                              res=norm(res+norm(s(ftree_wa,l,y))-mul(norm(s(ftree_S,l,y)),a[l]));
                              cout<<res<<endl;
                    }
          }
}

#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

namespace IO {
    const int BUFFER_SIZE = 4096;

    char input_buffer[BUFFER_SIZE];
    int input_pos = BUFFER_SIZE;
    int input_read = BUFFER_SIZE;

    char output_buffer[BUFFER_SIZE];
    int output_pos = 0;

    void _update_input_buffer() {
        if (input_pos >= input_read && input_read == BUFFER_SIZE) {
            input_read = fread(input_buffer, sizeof(char), BUFFER_SIZE, stdin);
            input_pos = 0;
        }
    }

    char next_char(bool advance = true) {
        _update_input_buffer();
        return input_buffer[advance ? input_pos++ : input_pos];
    }

    void skip_whitespace() {
        while (isspace(next_char(false)))
            next_char();
    }

    bool input_finished() {
        skip_whitespace();
        return input_pos >= input_read && input_read < BUFFER_SIZE;
    }

    template<typename T>
    void read_int(T &number) {
        skip_whitespace();
        bool negative = next_char(false) == '-';

        if (negative)
            next_char();

        number = 0;

        while (isdigit(next_char(false)))
            number = 10 * number + (next_char() - '0');

        if (negative)
            number = -number;
    }

    void flush_output() {
        fwrite(output_buffer, sizeof(char), output_pos, stdout);
        output_pos = 0;
    }

    void write_char(char c) {
        if (output_pos == BUFFER_SIZE)
            flush_output();

        output_buffer[output_pos++] = c;
    }

    template<typename T>
    void write_int(T number, char after = 0) {
        if (number < 0) {
            write_char('-');
            number = -number;
        }

        static char number_buffer[100];
        int length = 0;

        do {
            number_buffer[length++] = number % 10 + '0';
            number /= 10;
        } while (number > 0);

        for (int i = length - 1; i >= 0; i--)
            write_char(number_buffer[i]);

        if (after)
            write_char(after);
    }

    // Make sure flush_output() is called at the end of the program.
    bool exit_success = atexit(flush_output) == 0;
}

const int MOD = 1e9 + 7;

template<typename T1, typename T2>
void mod_add(T1 &a, T2 b) {
    a += b;

    if (a >= MOD)
        a -= MOD;
}

struct tree_node {
    long long w_sum;
    int aw_sum;

    tree_node() : w_sum(0), aw_sum(0) {}

    void join(const tree_node &other) {
        w_sum += other.w_sum;
        mod_add(aw_sum, other.aw_sum);
    }
};

int N, LOG, Q;
vector<int> A, W;
vector<tree_node> tree;

// O(N) initialization of our BIT.
void build_tree() {
    for (int i = 1; i <= N; i++) {
        for (int k = (i & -i) >> 1; k > 0; k >>= 1)
            tree[i].join(tree[i - k]);

        tree[i].w_sum += W[i - 1];
        tree[i].aw_sum = (tree[i].aw_sum + (long long) W[i - 1] * A[i - 1]) % MOD;
    }
}

void tree_update(int index, long long w_change, int a) {
    int aw_change = (MOD + w_change) * a % MOD;

    for (int i = index + 1; i <= N; i += i & -i) {
        tree[i].w_sum += w_change;
        mod_add(tree[i].aw_sum, aw_change);
    }
}

tree_node tree_query(int count) {
    tree_node answer;

    for (int i = count; i > 0; i -= i & -i)
        answer.join(tree[i]);

    return answer;
}

int solve(int start, int end) {
    tree_node tree_end = tree_query(end);
    tree_node tree_start = tree_query(start);
    long long search = (tree_end.w_sum + tree_start.w_sum + 1) / 2;
    int goal = 0;
    long long w_sum = 0, aw_sum = 0;

    // Note: this search needs an extra check that goal + (1 << k) <= N if our updates only go up to N rather than to 1 << LOG.
    for (int k = LOG - 1; k >= 0; k--)
        if (goal + (1 << k) <= N && search > w_sum + tree[goal + (1 << k)].w_sum) {
            goal += 1 << k;
            w_sum += tree[goal].w_sum;
            aw_sum += tree[goal].aw_sum;
        }

    assert(start <= goal && goal < end);
    long long result = ((w_sum - tree_start.w_sum) - (tree_end.w_sum - w_sum)) % MOD * A[goal] +
        (tree_end.aw_sum - aw_sum) - (aw_sum - tree_start.aw_sum);
    result %= MOD;
    mod_add(result, MOD);
    return result;
}

int main() {
    assert(IO::exit_success);
    IO::read_int(N);
    IO::read_int(Q);
    A.resize(N);
    W.resize(N);
    LOG = 32 - __builtin_clz(N);
    assert(1 << LOG > N);
    tree.resize(N + 1);

    for (int i = 0; i < N; i++) {
        IO::read_int(A[i]);
        A[i] -= i;
    }

    for (int i = 0; i < N; i++)
        IO::read_int(W[i]);

    build_tree();

    for (int q = 0; q < Q; q++) {
        int x, y;
        IO::read_int(x);
        IO::read_int(y);

        if (x < 0) {
            x = -x - 1;
            tree_update(x, y - W[x], A[x]);
            W[x] = y;
        } else {
            IO::write_int(solve(x - 1, y), '\n');
        }
    }
}

#include <string.h>
#include <sstream>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <stack>
#include <queue>
#include <set>

#include <map>
#include <vector>
#include <string>
#include <stdlib.h>

#define ll long long
using namespace std;
typedef long long LL;
const int N=200005,mod=1e9+7;
LL read(){
    LL x=0,f=1;
    char ch=getchar();
    while (!isdigit(ch)&&ch!='-')
        ch=getchar();
    if (ch=='-')
        f=-1,ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+ch-48,ch=getchar();
    return x*f;
}
int n,Q;
int a[N],w[N];
LL c1[N];
int c2[N];

ll sum1[N],sum2[N];

void add_sum1(int x, ll d) {
	for(;x<=n;x+=x&-x) {
		sum1[x] += d;
	}
}

void add_sum2(int x, ll d) {
	for(;x<=n;x+=x&-x) {
		sum2[x] = (sum2[x] + d+mod)%mod;
	}
}

ll get_sum1(int x) {
	ll ret = 0;
	while(x>0) {
		ret += sum1[x];
		x-=x&-x;
	}
	return ret;
}

ll get_sum2(int x) {
	ll ret = 0;
	while(x>0) {
		ret = (ret + sum2[x])%mod;
		x-=x&-x;
	}
	//printf("x = %d ret = %lld\n",x,ret);
	return ret;

}

ll get_sum1(int s, int e) {
	return get_sum1(e)-get_sum1(s-1);
}

ll get_sum2(int s, int e) {
	return (get_sum2(e)-get_sum2(s-1)+mod)%mod;
}

void opt1(int i,int nw){
    add_sum1(i,-w[i]);
    add_sum2(i,(-1LL*w[i]*a[i]%mod+mod)%mod);
    w[i]=nw;
    add_sum1(i,w[i]);
    add_sum2(i,1LL*w[i]*a[i]%mod);
}
ll sol2(int s, int e, int mid) {
	ll t1 = get_sum2(s,mid-1);
	ll t2 = get_sum2(mid+1,e);
	ll t3 = get_sum1(s,mid-1);
	ll t4 = get_sum1(mid+1,e);
	//printf("s = %d e = %d mid = %d t1 = %lld t2 = %lld t3 = %lld t4 = %lld\n",s,e,mid,t1,t2,t3,t4);
	return ((-t1+t2+mod)+(t3-t4+mod)*a[mid]+mod)%mod;
}

void opt2(int s,int e){
	/*
    LL sum=get_sum1(L,R);
    int le=L,ri=R,mid,ans=R;
    while (le<=ri){
        mid=(le+ri)>>1;
        LL v=get_sum1(L,mid);
        if (v*2>=sum)
            ri=mid-1,ans=mid;
        else
            le=mid+1;
    }
	*/
	ll tot = get_sum1(s,e);
	int l = s-1, r = e;
	while(l+1<r) {
		int mid = (l+r)>>1;
		ll v = get_sum1(s,mid);
		if(v*2>=tot) {
			r = mid;
		}
		else {
			l = mid;
		}
	}
	ll ans2 = sol2(s,e,r);
	cout<<ans2<<endl;

    //LL v11=get_sum2(L,ans),v12=-1LL*a[ans]*(get_sum1(L,ans)%mod)%mod;
    //LL v21=get_sum2(ans+1,R),v22=-1LL*a[ans]*(get_sum1(ans+1,R)%mod)%mod;
    //LL Ans=(v21+v22-v11-v12)%mod;
    //Ans=(Ans+mod)%mod;
	//LL Ans = sol2(L,R,ans);
	//cout<<Ans<<endl;
}
int main(){
    n=read(),Q=read();
    for (int i=1;i<=n;i++)
        a[i]=read()-i+n;
    memset(sum1,0,sizeof sum1);
    memset(sum2,0,sizeof sum2);
    for (int i=1;i<=n;i++){
        w[i]=read();
        add_sum1(i,w[i]);
        add_sum2(i,1LL*w[i]*a[i]%mod);
    }
    while (Q--){
        int x=read(),y=read();
        if (x<0)
            opt1(-x,y);
        else
            opt2(x,y);
    }
    return 0;
}

// @betaveros :: vim:set fdm=marker syntax=cppc:
#define NDEBUG
// #includes, using namespace std {{{
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <cinttypes> // C++11?
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <functional>
#include <new>
#include <algorithm>
#include <iostream>
using namespace std;
// }}}
// #defines, typedefs, constants {{{
#define fori(i,s,e) for(int i = s; i < ((int)e); i++)
#define fori0(i,e) for(int i = 0; i < ((int)e); i++)
#define fori1(i,e) for(int i = 1; i <= ((int)e); i++)
#define forui(i,s,e) for(unsigned int i = s; i < ((unsigned int)e); i++)
#define foruin(i,c) for(unsigned int i = 0; i < ((unsigned int)(c).size()); i++)
#define _conc(x,y) x ## y
#define _conc2(x,y) _conc(x,y)
#define repeat(n) fori(_conc2(_,__LINE__),0,n)
#define allof(s) (s).begin(), (s).end()
#define scan_d(x) scanf("%d",&(x))
#define scan_dd(x,y) scanf("%d%d",&(x),&(y))
#define scan_ddd(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define scan_dddd(x,y,z,w) scanf("%d%d%d%d",&(x),&(y),&(z),&(w))
#define pushb push_back
#define popb push_back

#ifdef NDEBUG
#define debug(code)
#define debugf(...) ((void)0)
#else
#define debug(code) code
#define debugf(...) fprintf(stderr, __VA_ARGS__)
#endif
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> Vint;
typedef vector<int>::iterator Vit;

// const int OO  = 1000 << 20;
// const int OO2 = 2000 << 20;
// const int       M7  = 1000000007;
// const int       M9  = 1000000009;
const long long M7L = 1000000007L;
// }}}
// dump, min/maxify {{{
template <class T> void dumpBetween(const T & a, const T & b) {
	for (T it = a; it != b; it++) cout << *it << " ";
	cout << endl;
}
template <class T> void dumpAll(const T & a) { dumpBetween(allof(a)); }
template <class T> void minify(T & a, const T & b) { if (a > b) a = b; }
template <class T> void maxify(T & a, const T & b) { if (a < b) a = b; }
// }}}

int n, q;
const int N = 200008;

ll position[N];
ll weight[N];
ll wtree[N];
ll wptree[N];
ll witree[N];

long long mod(long long x, long long m) {
	long long r = x % m;
	return r < 0 ? r + m : r;
}

void readInput() {
	scan_dd(n, q);
	fori (i, 1, n+1) { scanf("%" SCNd64, &position[i]); }
	fori (i, 1, n+1) { scanf("%" SCNd64, &weight[i]); }
}

void update(int i, ll diff) {
	int ii = i;
	while (ii <= n) {
		wtree[ii] += diff;
		wptree[ii] += diff * position[i];
		wptree[ii] = mod(wptree[ii], M7L);
		witree[ii] += diff * i;
		witree[ii] = mod(witree[ii], M7L);

		ii += ii & -ii;
	}
}

ll getSum(int i) {
	ll ret = 0;
	int ii = i;
	while (ii) {
		ret += wtree[ii];

		ii -= ii & -ii;
	}
	return ret;
}

ll getWpSum(int i) {
	ll ret = 0;
	int ii = i;
	while (ii) {
		ret = mod(ret + wptree[ii], M7L);

		ii -= ii & -ii;
	}
	return ret;
}

ll getWiSum(int i) {
	ll ret = 0;
	int ii = i;
	while (ii) {
		ret = mod(ret + witree[ii], M7L);

		ii -= ii & -ii;
	}
	return ret;
}

void tc() {
	readInput();

	// build a fenwick tree so we can calculate sums of weights and sums of
	// weight*positions

	fori (i, 1, n+1) {
		update(i, weight[i]);
	}

	//
	repeat(q) {
		int qa, qb;
		scan_dd(qa, qb);
		debugf("doing %d %d\n", qa, qb);
		if (qa < 0) {
			// to update, update the fenwick tree
			ll newWeight = qb;
			int i = -qa;
			ll diff = newWeight - weight[i];
			weight[i] = newWeight;
			update(i, diff);
		} else {
			// do a binary search; the best place is where sum of weight on both sides is balanced.
			int lo = qa;
			int hi = qb + 1;
			ll loWs = getSum(lo - 1);
			ll hiWs = getSum(hi - 1);
			while (hi - lo > 1) {
				int mid = (lo + hi) / 2;
				ll midWs = getSum(mid - 1);
				ll left = midWs - loWs;
				ll right = hiWs - midWs;
				debugf("%lld | (%d) | %lld", left, mid, right);
				if (left > right) {
					hi = mid;
				} else {
					lo = mid;
				}
			}

			int center = lo;
			debugf("center = %d\n", center);
			ll centerPos = position[center];
			ll leftCost =
				(centerPos - center) * mod(getSum(center - 1) - getSum(qa - 1), M7L)
				+ (getWiSum(center - 1) - getWiSum(qa - 1))
				- (getWpSum(center - 1) - getWpSum(qa - 1));
			ll rightCost =
				(getWpSum(qb) - getWpSum(center))
				- (centerPos - center) * mod(getSum(qb) - getSum(center), M7L)
				- (getWiSum(qb) - getWiSum(center))
				;
			leftCost = mod(leftCost, M7L);
			rightCost = mod(rightCost, M7L);
			printf("%" PRId64 "\n", mod(leftCost + rightCost, M7L));
		}
	}
}

int main() { tc(); }

#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a))
#define MEM_1(a) memset((a),-1,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<db> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[] = { -1,-2,1,-2,2,-1,2,1 }, ddy[] = { -2,-1,-2,1,-1,2,1,2 };

ll a[200001],b[200001];
ll tree1[524288],tree2[524288];

void init(int node, int S, int E)
{
	if (S == E)
	{
		tree1[node] = (a[S]*b[S])%MOD;
		tree2[node]=b[S];
		return;
	}
	init(2 * node, S, (S + E) / 2);
	init(2 * node + 1, (S + E) / 2 + 1, E);
	tree1[node] = (tree1[node * 2] + tree1[node * 2 + 1])%MOD;
	tree2[node] = tree2[node * 2] + tree2[node * 2 + 1];
}

void upd(int node, int S, int E, int k)
{
	if (S == E)
	{
		tree1[node] = (a[S]*b[S])%MOD;
		tree2[node]=b[S];
		return;
	}
	if (k <= (S + E) / 2)upd(node * 2, S, (S + E) / 2, k);
	else upd(node * 2 + 1, (S + E) / 2 + 1, E, k);
	tree1[node] = (tree1[node * 2] + tree1[node * 2 + 1])%MOD;
	tree2[node] = tree2[node * 2] + tree2[node * 2 + 1];
}
Pll operator + (const Pll &p1,const Pll &p2){
	return mp((p1.X+p2.X)%MOD,p1.Y+p2.Y);
}
Pll find(int node, int S, int E, int i, int j)
{
	if (i > E || j < S)return {0,0};
	if (i <= S && j >= E)return {tree1[node],tree2[node]};
	return find(node * 2, S, (S + E) / 2, i, j) + find(node * 2 + 1, (S + E) / 2 + 1, E, i, j);
}

int findK(int node, int S, int E, ll k)
{
	if (S == E)return S;
	if (k <= tree2[node * 2])return findK(node * 2, S, (S + E) / 2, k);
	return findK(node * 2 + 1, (S + E) / 2 + 1, E, k - tree2[node * 2]);
}
int main(){
	int n,q;
	scanf("%d%d",&n,&q);
	fup(i,1,n,1){
		scanf("%lld",a+i);
		a[i]-=i;
	}
	fup(i,1,n,1)scanf("%lld",b+i);
	init(1,1,n);
	while(q--){
		int x,y;
		scanf("%d%d",&x,&y);
		if(x>0){
			ll k=(find(1,1,n,x,y).Y+1)/2;
			int i=findK(1,1,n,k+find(1,1,n,1,x-1).Y);
			Pll s1=find(1,1,n,x,i-1),s2=find(1,1,n,i+1,y);
			ll ans=((s1.Y*a[i]-s1.X)+(s2.X-s2.Y*a[i]))%MOD;
			if(ans<0)ans+=MOD;
			printf("%lld\n",ans);
		}else{
			x=-x;
			b[x]=y;
			upd(1,1,n,x);
		}
	}
}

#include<bits/stdc++.h>
#define mod 1000000007
#define NN 200200

using namespace std;
typedef long long INT;

INT X[NN];
int Xi[NN], xi;
int X2[NN], x2;
int Xm[NN], xm;
int a[NN], w[NN], x, n, q;

inline void update(int u) {
	for(; u<=n; u+=u&-u) {
		X[u]+=x;
		Xi[u]=(Xi[u]+xi)%mod;
		X2[u]=(X2[u]+x2)%mod;
		Xm[u]=(Xm[u]+xm)%mod;
	}
}

inline INT calc_x(int u, INT ans=0) {
	for(; u; u-=u&-u) ans+=X[u];
	return ans;
}

inline void calc(int u) {
	x=0, xi=0, x2=0, xm=0;
	for(; u; u-=u&-u) {
		x=(x+X[u])%mod;
		xi=(xi+Xi[u])%mod;
		x2=(x2+X2[u])%mod;
		xm=(xm+Xm[u])%mod;
	}
}

int collect(int u, int L, int R) {
	calc(L-1);
	int tx=x, txi=xi, tx2=x2, txm=xm;
	calc(u-1);
	tx=(x-tx+mod)%mod, txi=(xi-txi+mod)%mod, tx2=(x2-tx2+mod)%mod, txm=(xm-txm+mod)%mod;

	INT ans=0;
	if(L<u) {
		ans+=(INT)a[u]*tx;
		ans-=txm;
		ans+=txi-(INT)u*tx;
	}

	tx=(x+w[u])%mod, txi=(xi+(INT)u*w[u])%mod, tx2=(x2+(INT)w[u]*w[u])%mod, txm=(xm+(INT)a[u]*w[u])%mod;
	calc(R);
	tx=(x-tx+mod)%mod, txi=(xi-txi+mod)%mod, tx2=(x2-tx2+mod)%mod, txm=(xm-txm+mod)%mod;

	if(u<R) {
		ans+=txm;
		ans-=(INT)a[u]*tx;
		ans+=(INT)u*tx-txi;
	}

	ans%=mod;
	if(ans<0) ans+=mod;
	return ans;
}

int main() {
	scanf("%d %d", &n, &q);
	for(int i=1; i<=n; i++) scanf("%d", a+i);
	for(int i=1; i<=n; i++) {
		scanf("%d", w+i);

		x=w[i];
		xi=(INT)i*x%mod;
		x2=(INT)x*x%mod;
		xm=(INT)a[i]*x%mod;
		update(i);
	}

	while(q--) {
		int L, R; scanf("%d %d", &L, &R);
		if(L<0) {
			L=-L;

			x=-w[L];
			xi=mod-(INT)L*w[L]%mod;
			x2=mod-(INT)w[L]*w[L]%mod;
			xm=mod-(INT)a[L]*w[L]%mod;
			update(L);

			w[L]=R;

			x=w[L];
			xi=(INT)L*x%mod;
			x2=(INT)x*x%mod;
			xm=(INT)a[L]*x%mod;
			update(L);
		}
		else if(L==R) puts("0");
		else {
			INT L_=calc_x(L-1), all=calc_x(R)-L_;
			int st=L-1, ed=R;
			while(st+1<ed) {
				int md=st+ed>>1;

				INT sa=calc_x(md)-L_, sb=all-sa;
				if(sa>sb) ed=md;
				else st=md;
			}
			printf("%d\n", collect(ed, L, R));
		}
	}
}

#include<bits/stdc++.h>

using namespace std;

const int maxi=1e6+2;
long long a[maxi],w[maxi];
int n,q;
long long mo=1e9+7;
long long bit[maxi];
long long bit1[maxi];
long long bit2[maxi];

void update(long long *bit, int  x, long long val)
{
    for (int i=x;i<maxi;i+=i&(-i))
        bit[i]+=val;
    return;
}

long long get(long long *bit,int x)
{
    long long ans=0;

    for (int i=x;i>0;i-=i&(-i))
        ans+=bit[i];
    return ans;
}

void update2(long long *bit2, int  x, long long val)
{
    for (int i=x;i<maxi;i+=i&(-i)){
        bit2[i]=(bit2[i]+val)%mo;
        if (bit2[i]<0) bit2[i]+=mo;
    }
    return;
}

long long get2(long long *bit2, int x)
{
    long long ans=0;

    for (int i=x;i>0;i-=i&(-i)){
        ans+=bit2[i];
        ans%=mo;
    }
    return ans;
}
int main()
{
    cin>>n>>q;

    for (int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    for (int i=1;i<=n;i++)
        scanf("%lld",&w[i]);

    for (int i=1;i<=n;i++)
        update2(bit2,i,w[i]*a[i]);

    for (int i=1;i<=n;i++)
        update(bit,i,w[i]);

    for (int i=1;i<=n;i++)
        update2(bit1,i,1ll*i*w[i]);

   while(q--)
   {
       int tip;
       int idx,l;
       scanf("%d",&tip);
       if (tip<0)
       {
           idx=-tip;
           tip=1;
       } else
       {
           l=tip;
           tip=2;
       }
       if (tip==1)
       {
           long long val;
           scanf("%lld",&val);
           update(bit,idx,-w[idx]);
           update2(bit1,idx,-1ll*idx*w[idx]);
           update2(bit2,idx,-1ll*a[idx]*w[idx]);
           w[idx]=val;
           update(bit,idx,w[idx]);
           update2(bit1,idx,1ll*idx*w[idx]);
           update2(bit2,idx,1ll*a[idx]*w[idx]);
       }
       else
       {    int r;
            scanf("%d",&r);
            if (l==r) printf("0\n"); else
            {
               int li=-1;
               int ri=r-l+1;
               long long sum=get(bit,r)-get(bit,l-1);
               long long pola=(sum+1)/2;
               while(li<ri-1)
               {
                   int mid=li+ri>>1;
                   long long val=get(bit,l+mid)-get(bit,l-1);
                   if (val>=pola) ri=mid; else li=mid;
               }
               int poz=l+ri; //oko a[poz] treba da se kupe
               long long ans=0;
               //[l,poz-1]
               if (poz-1>=l)
               {
                long long x=a[poz]-poz;
                long long sumWi=get(bit,poz-1)-get(bit,l-1);
                sumWi%=mo;
                ans+=sumWi*x;
                ans%=mo;
                ans+=get2(bit1,poz-1)-get2(bit1,l-1);
                ans%=mo;
                if (ans<0) ans+=mo;
                ans-=(get2(bit2,poz-1)-get2(bit2,l-1));
                ans%=mo;
                if (ans<0) ans+=mo;
               }

               //[poz+1,i]
               if (poz+1<=r)
               {
                   long long x=a[poz]-poz;
                   ans+=get2(bit2,r)-get2(bit2,poz);
                   ans%=mo;
                   if (ans<0) ans+=mo;
                   ans-=get2(bit1,r)-get2(bit1,poz);
                   ans%=mo;
                   if (ans<0) ans+=mo;
                   long long sumWi=get(bit,r)-get(bit,poz);
                   sumWi%=mo;
                   ans-=sumWi*x;
                   ans%=mo;
                   if (ans<0) ans+=mo;
               }

               printf("%lld\n",ans);
            }
       }
   }

   return 0;
}
//nesto mi ladnjikavo sine moj, koliko li me pici temperatura
//al mi ladne noge
//sve moje njeno je, da odem vreme je

#include<cstdio>
#include<iostream>
#define mo 1000000007
using namespace std;
using LL=long long;

struct Finwick
{
	int n,logn;
	LL C[200005];

	void init(int x)
	{
		logn=sizeof(int)*8-__builtin_clz(n=x)-1;
	}

	LL sum(int x, int o=0)
	{
		LL res=0;
		while(x)
		{
			res+=C[x];
			if(o)
				res%=mo;
			x-=x&-x;
		}
		return res;
	}

	void add(int x, LL d, int o=0)
	{
		while(x<=n)
		{
			C[x]+=d;
			if(o)
				C[x]%=mo;
			x+=x&-x;
		}
	}

	int lower_bound(LL v)
	{
		LL sum=0;
		int pos=0;
		for(int i=logn;i>=0;i--)
			if((pos|1<<i)<=n&&sum+C[pos|1<<i]<v)
				sum+=C[pos|=1<<i];
		return pos+1;
	}
}F,H;

int n,q,pos,x,y;
LL ans,w[200005],a[200005];

int main()
{
	scanf("%d%d",&n,&q);
	F.init(n),H.init(n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&w[i]);
		F.add(i,w[i]);
		H.add(i,w[i]*(a[i]-i)%mo,1);
	}
	while(q--)
	{
		scanf("%d%d",&x,&y);
		if(x<0)
		{
			x=-x;
			F.add(x,y-w[x]);
			H.add(x,(y-w[x]+mo)*(a[x]-x)%mo,1);
			w[x]=y;
		}
		else
		{
			pos=F.lower_bound(F.sum(y)+F.sum(x-1)+1>>1);
			ans=(F.sum(pos-1,1)-F.sum(x-1,1)+mo)*(a[pos]-pos)%mo+mo-H.sum(pos-1,1)+H.sum(x-1,1);
			ans+=(-F.sum(y,1)+F.sum(pos,1)+mo)*(a[pos]-pos)%mo+mo+H.sum(y,1)-H.sum(pos,1);
			printf("%d\n",int((ans+mo)%mo));
		}
	}
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define int long long

const int MAXN = 2e5 + 7;
const int MOD = 1000 * 1000 * 1000 + 7;

int mod(int n) {
    return (n % MOD + MOD) % MOD;
}

int n, q;
int a[MAXN], w[MAXN];
void read() {
    cin >> n >> q;
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> w[i];
}

int f[MAXN], f1[MAXN];

void add_(int i, int x) {
    for (; i < MAXN; i |= (i + 1)) {
        f[i] += x;
    }
}

int getpr_(int i) {
    int ans = 0;
    for (; i >= 0; i = (i & (i + 1)) - 1) {
        ans += f[i];
    }
    return ans;
}

int get_(int l, int r) {
    return getpr_(r) - getpr_(l - 1);
}

void add1_(int i, int x) {
    int t = x * (i - a[i]);
    for (; i < MAXN; i |= (i + 1)) {
        f1[i] += t;
        f1[i] = mod(f1[i]);
    }
}

int getpr1_(int i) {
    int ans = 0;
    for (; i >= 0; i = (i & (i + 1)) - 1) {
        ans += f1[i];
    }
    return ans;
}

int get1_(int l, int r) {
    return mod(getpr1_(r) - getpr1_(l - 1));
}

int p[MAXN];
void solve() {
    for (int i = 0; i < n; ++i) add_(i, w[i]);
    for (int i = 0; i < n; ++i) add1_(i, w[i]);
    for (int i = 0; i < n; ++i) p[i] = a[i] - i;
}

void upd(int i, int x) {
    int delt = x - w[i];
    add_(i, delt);
    add1_(i, delt);
    w[i] = x;
}

int getl(int l, int r) {
    int bl = a[l] - 1;
    int br = a[r] - (r - l) + 1;
    int sum = get_(l, r);
    while (bl < br - 1) {
        int bm = (bl + br) / 2;
        //a[i] <= (bm + (i - l))
        //a[i] <= bm + i - l
        //a[i] - i <= bm - l
        auto t = upper_bound(p + l, p + r + 1, bm - l);
        int sum1 = get_(t - p, r);
        if (sum < sum1 * 2) bl = bm;
        else br = bm;
    }
    return br;
}

int getans(int l, int r, int tl) {
    auto t = upper_bound(p + l, p + r + 1, tl - l);
    int bl = t - p - 1;
    int ans = 0;
    ans += mod(mod(get_(l, bl)) * (tl - l)) + get1_(l, bl);
    ans -= mod(mod(get_(bl + 1, r)) * (tl - l)) + get1_(bl + 1, r);
    return mod(ans);
}

int get(int l, int r) {
    int tl = getl(l, r);
    return getans(l, r, tl);
}

void print() {
    for (int i = 0; i < q; ++i) {
        int x, y;
        cin >> x >> y;
        if (x < 0) {
            upd(-x - 1, y);
        }
        else {
            cout << get(x - 1, y - 1) << '\n';
        }
    }
}

signed main() {
    //freopen("input.txt", "r", stdin);

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    read();
    solve();
    print();

    return 0;
}

#include <iostream>
#include <stdio.h>
#define maxn 800000
#define mod 1000000007
using namespace std;
long long n,q,t1[maxn];
long long w[maxn],a[maxn],t2[maxn];
void build(int left,int right,int p)
{
	if(left==right)
	{
		t1[p]=w[left];
		t2[p]=w[left]*(left-a[left]);
		t2[p]%=mod;
		return;
	}
	int mid=(left+right)>>1;
	build(left,mid,p*2);
	build(mid+1,right,p*2+1);
	t1[p]=t1[p*2]+t1[p*2+1];
	t2[p]=t2[p*2]+t2[p*2+1];
	t2[p]%=mod;
}
void update1(int left,int right,int q,int p,long long c)
{
	if(left>q||right<q)
	{
		return;
	}
	if(left==right)
	{
		t1[p]+=c;
//		t1[p]%=mod;
		return;
	}
	int mid=(left+right)>>1;
	update1(left,mid,q,p*2,c);
	update1(mid+1,right,q,p*2+1,c);
	t1[p]=t1[p*2]+t1[p*2+1];
//	t1[p]%=mod;
}
void update2(int left,int right,long long q,int p,long long c)
{
	if(left>q||right<q)
	{
		return;
	}
	if(left==right)
	{
		t2[p]+=c*(q-a[q]);
		t2[p]%=mod;
		return;
	}
	int mid=(left+right)>>1;
	update2(left,mid,q,p*2,c);
	update2(mid+1,right,q,p*2+1,c);
	t2[p]=t2[p*2]+t2[p*2+1];
	t2[p]%=mod;
}
long long query1(int left,int right,int ql,int qr,int p)
{
	if(left>=ql&&right<=qr)
	{
		return t1[p];
	}
	if(left>qr||right<ql)
	{
		return 0;
	}
	long long mid=(left+right)>>1;
	return query1(left,mid,ql,qr,p*2)+query1(mid+1,right,ql,qr,p*2+1);
}
long long query2(int left,int right,int ql,int qr,int p)
{
	if(left>=ql&&right<=qr)
	{
		return t2[p];
	}
	if(left>qr||right<ql)
	{
		return 0;
	}
	int mid=(left+right)>>1;
	return (query2(left,mid,ql,qr,p*2)+query2(mid+1,right,ql,qr,p*2+1))%mod;
}
int main()
{
	cin>>n>>q;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		cin>>w[i];
	}
	build(1,n,1);
	while(q--)
	{
		long long x,y;
		scanf("%I64d%I64d",&x,&y);
		if(x<0)
		{
			x=-x;
			update1(1,n,x,1,y-w[x]);
			update2(1,n,x,1,y-w[x]);
			w[x]=y;
//			for(int i=1;i<=n;i++)
//			{
//				cout<<w[i]<<' ';
//			}
//			cout<<endl;
//			for(int i=1;i<=4*n;i++)
//			{
//				cout<<t1[i]<<' ';
//			}
//			cout<<endl;
		}
		else
		{
			long long l=1,r=n,res=0;
			while(l<=r)
			{
				long long mid=(l+r)>>1;
//				cout<<mid<<":"<<query1(1,n,x,mid,1)<<' '<<query1(1,n,mid+1,y,1)<<endl;
				if(query1(1,n,x,mid,1)<query1(1,n,mid+1,y,1))
				{
					l=mid+1;
				}
				else
				{
					res=mid;
					r=mid-1;
				}
			}
//			cout<<query1(1,n,1,n,1)<<endl;
//			cout<<query1(1,n,x,l-1,1)<<' '<<a[l]-l<<' '<<query2(1,n,x,l-1,1)<<' '<<query1(1,n,l+1,y,1)<<' '<<l-a[l]<<' '<<query2(1,n,l+1,y,1)<<endl;
			long long ans=(query1(1,n,x,res-1,1)%mod*(a[res]-res))%mod+query2(1,n,x,res-1,1)+(query1(1,n,res+1,y,1)%mod*(res-a[res]))%mod-query2(1,n,res+1,y,1);
			while(ans<0)ans+=mod;
			printf("%I64d\n",ans%mod);
		}
	}
	return 0;
}

#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;
const int MAXN=200005,mod=1000000007;

int n,Q,a[MAXN];
struct Fenwick
{
	bool mode;
	ll c[MAXN];
	void add(int x,ll d)
	{
		if(mode)d=(d%mod+mod)%mod;
		for(int i=x;i<=n;i+=(i&-i))
		{
			c[i]+=d;
			if(mode && c[i]>=mod)c[i]-=mod;
		}
	}
	ll query(int x)const
	{
		ll ans=0;
		for(int i=x;i;i-=(i&-i))
		{
			ans+=c[i];
			if(mode && ans>=mod)ans-=mod;
		}
		return ans;
	}
	ll operator ()(int l,int r)const
	{
		ll ans=query(r)-query(l-1);
		return mode?(ans+mod)%mod:ans;
	}
}w,wa;

int main()
{
    #ifdef OnCode
    freopen("code.in","r",stdin);
    //freopen("code.out","w",stdout);
    #endif
    int x,y;
    scanf("%d%d",&n,&Q);
    for(int i=1;i<=n;i++)
    {
    	scanf("%d",&a[i]);
    	a[i]-=i;
    }
    w.mode=0;
    wa.mode=1;
    for(int i=1;i<=n;i++)
    {
    	scanf("%d",&x);
    	w.add(i,x);
    	wa.add(i,(ll)x*a[i]);
    }
    while(Q--)
    {
    	scanf("%d%d",&x,&y);
    	if(x<0)
    	{
    		x=-x;
    		w.add(x,y-w(x,x));
    		wa.add(x,(ll)y*a[x]-wa(x,x));
    	}
    	else
    	{
    		ll t=(w(x,y)+1)/2;
    		int l=x,r=y,mid,ans=y;
    		while(l<=r)
    		{
    			mid=(l+r)>>1;
    			if(w(x,mid)>=t)ans=mid,r=mid-1;
    			else l=mid+1;
    		}
    		//cout<<ans<<" "<<wa(x,ans)<<" "<<wa(ans+1,y)<<" ";
    		cout<<(((ll)a[ans]*w(x,ans)-wa(x,ans)-(ll)a[ans]*w(ans+1,y)
				+wa(ans+1,y))%mod+mod)%mod<<endl;
    	}
    }
    return 0;
}

#include<bits/stdc++.h>

#define ll long long
#define INF 2147483647
#define lc(a) ((a) << 1)
#define rc(a) ((a) << 1 | 1)
#define mod 1000000007

int inp(){
    char c = getchar();
    int neg = 1;
    while(c < '0' || c > '9'){
        if(c == '-')
            neg = -1;
        c = getchar();
    }
    int sum = 0;
    while(c >= '0' && c <= '9'){
        sum = sum * 10 + c - '0';
        c = getchar();
    }
    return sum * neg;
}

struct SEG{
    int l;
    int r;
    ll sum;
    ll ls;
    ll rs;
};

ll s[200010], dis[200010];

SEG operator + (SEG a, SEG b){
    SEG ret;
    if(a.l == -1)
        return b;
    if(b.l == -1)
        return a;
    ret.sum = a.sum + b.sum;
    a.sum %= mod;
    b.sum %= mod;
    ret.ls = a.ls + b.ls + b.sum * (dis[a.r] - dis[a.l - 1]);
    ret.rs = b.rs + a.rs + a.sum * (dis[b.r + 1] - dis[b.l]);
    ret.ls %= mod;
    ret.rs %= mod;
    ret.l = a.l;
    ret.r = b.r;
    return ret;
}

struct SEG_Tree{
    SEG t[800010];

    void push_up(int cur){
        t[cur] = t[lc(cur)] + t[rc(cur)];
    }

    void build(int cur, int l, int r){
        t[cur].l = l;
        t[cur].r = r;
        if(l == r){
            t[cur].sum = s[l];
            t[cur].ls = s[l] * (dis[l] - dis[l - 1]);
            t[cur].rs = s[l] * (dis[l + 1] - dis[l]);
            return ;
        }
        int mid = (l + r) >> 1;
        build(lc(cur), l, mid);
        build(rc(cur), mid + 1, r);
        push_up(cur);
    }

    ll query2(int cur, int l, int r){
        if(t[cur].l > r || t[cur].r < l)
            return 0;
        if(t[cur].l >= l && t[cur].r <= r)
            return t[cur].sum;
        return query2(lc(cur), l, r) + query2(rc(cur), l, r);
    }

    SEG query(int cur, int l, int r){
        if(l > r)
            return (SEG){0, 0, 0, 0, 0};
        if(t[cur].l > r || t[cur].r < l)
            return (SEG){-1, -1, -1, -1, -1};
        if(t[cur].l >= l && t[cur].r <= r)
            return t[cur];
        return query(lc(cur), l, r) + query(rc(cur), l, r);
    }

    void modify(int cur, int x,int c){
        if(t[cur].l == t[cur].r){
            t[cur].sum = c;
            t[cur].ls = c * (dis[t[cur].l] - dis[t[cur].l - 1]);
            t[cur].rs = c * (dis[t[cur].l + 1] - dis[t[cur].l]);
            return ;
        }
        if(x <= t[lc(cur)].r)
            modify(lc(cur), x, c);
        else
            modify(rc(cur), x, c);
        push_up(cur);
    }
}t;

int solve(int lb, int rb){
    int l = lb;
    int r = rb;
    while(l < r){
        int mid = (l + r) >> 1;
        if(t.query2(1, lb, mid) >= t.query2(1, mid + 1, rb))
            r = mid;
        else
            l = mid + 1;
    }
    return l;
}

int main(){
    int n = inp();
    int q = inp();
    for(int i = 1; i <= n; i++)
        dis[i] = inp() - i;
    for(int i = 1; i <= n; i++)
        s[i] = inp();
    t.build(1, 1, n);
    while(q--){
        int id = inp();
        int c = inp();
        if(id < 0){
            t.modify(1, -id, c);
        } else {
            int pos = solve(id, c);
            ll ans = 0;
            if(id <= pos - 1)
                ans += t.query(1, id, pos - 1).rs;
            if(pos + 1 <= c)
                ans += t.query(1, pos + 1, c).ls;
            ans %= mod;
            printf("%lld\n", ans);
            // printf("[%d, %d, %d] %lld + %lld = %lld\n", id, pos, c, t.query(1, id, pos - 1).rs, t.query(1, pos + 1, c).ls, ans);
        }
    }
}
// ...

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 2e5 + 7;
const ll mod = 1e9 + 7;

int n, q;
ll id[maxn], w[maxn];

// 权值w[i]前缀和  用于寻找带权中位数
ll c[maxn];
void add(int id, ll v) {
    for(int i = id; i < maxn; i += (i&-i)) {
        c[i] += v;
    }
}
ll sum(int id) {
    ll res = 0;
    for(int i = id; i > 0; i -= (i&-i)) {
        res += c[i];
    }
    return res;
}

// 维护 id[i]*w[i];  最后求答案
ll c1[maxn];
void add1(int id, ll v) {
    for(int i = id; i < maxn; i += (i&-i)) {
        (c1[i] += v) %= mod;
    }
}
ll sum1(int id) {
    ll res = 0;
    for(int i = id; i > 0; i -= (i&-i)) {
        res += c1[i];
    }
    return res%mod;
}

int main() {
    scanf("%d%d", &n, &q);
    for(int i = 1; i <= n; ++i) {
        scanf("%lld", &id[i]);
        id[i] += (n - i);
    }
    for(int i = 1; i <= n; ++i) {
        scanf("%lld", &w[i]);
        add(i, w[i]);
        add1(i, id[i]*w[i]%mod);
    }
    while(q--) {
        ll l_, r_;
        scanf("%lld", &l_);

        if(l_ < 0) {
            l_ = -l_;
            scanf("%lld", &r_);
            add(l_, r_-w[l_]);
            add1(l_, (id[l_]*(r_-w[l_])%mod));
            w[l_] = r_;
        } else {
            scanf("%lld", &r_);
            ll u = sum(l_-1);
            ll t = (sum(r_) - u);

            int l = l_, r = r_;
            int pos = -1;
            while(l <= r) {
                int mid = (l + r) >> 1;
                ll num = (sum(mid) - u);
                if(num*2 >= t) {
                    pos = mid;
                    r = mid - 1;
                } else {
                    l = mid + 1;
                }
            }
            ll ans = ( (sum(pos)-sum(l_-1))%mod*id[pos]%mod - ((sum1(pos))-(sum1(l_-1)+mod))%mod + mod) % mod; // 左边的ans
            ans = (ans + ((sum1(r_))-(sum1(pos-1))+mod)%mod - (sum(r_)-sum(pos-1))%mod*id[pos] + mod  ) % mod; // 右边的ans
            ans = (ans % mod + mod) % mod;
            printf("%lld\n", ans);
        }
    }

    return 0;
}

#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }
template<typename T, typename U> inline ostream &operator<< (ostream &_out, const pair<T, U> &_p) { _out << _p.first << ' ' << _p.second; return _out; }
template<typename T, typename U> inline istream &operator>> (istream &_in, pair<T, U> &_p) { _in >> _p.first >> _p.second; return _in; }
template<typename T> inline ostream &operator<< (ostream &_out, const vector<T> &_v) { if (_v.empty()) { return _out; } _out << _v.front(); for (auto _it = ++_v.begin(); _it != _v.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T> inline istream &operator>> (istream &_in, vector<T> &_v) { for (auto &_i : _v) { _in >> _i; } return _in; }
template<typename T> inline ostream &operator<< (ostream &_out, const set<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T> inline ostream &operator<< (ostream &_out, const multiset<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T> inline ostream &operator<< (ostream &_out, const unordered_set<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T> inline ostream &operator<< (ostream &_out, const unordered_multiset<T> &_s) { if (_s.empty()) { return _out; } _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) { _out << ' ' << *_it; } return _out; }
template<typename T, typename U> inline ostream &operator<< (ostream &_out, const map<T, U> &_m) { if (_m.empty()) { return _out; } _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')'; for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) { _out << ", (" << _it->first << ": " << _it->second << ')'; } return _out; }
template<typename T, typename U> inline ostream &operator<< (ostream &_out, const unordered_map<T, U> &_m) { if (_m.empty()) { return _out; } _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')'; for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) { _out << ", (" << _it->first << ": " << _it->second << ')'; } return _out; }
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define left left228
#define right right228
#define next next228
#define rank rank228
#define prev prev228
#define y1 y1228
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define files(FILENAME) read(FILENAME), write(FILENAME)
#define pb push_back
#define x first
#define y second
const string FILENAME = "input";
const int MAXN = 200228;
const int M = 1000000007;
const long long base = 1000000000000000000LL;

struct fenwick {
    vector<long long> f;
    int nn;
    void init(int n) {
        f.resize(n, 0);
        nn = n;
    }
    void inc(int i, long long val) {
        for (int j = i; j < nn; j = (j | (j + 1))) {
            f[j]+= val;
        }
    }
    long long getsum(int l) {
        if (l < 0) {
            return 0;
        }
        long long t = 0;
        for (int j = l; j >= 0; j = (j & (j + 1)) - 1) {
            t += f[j];
        }
        return t;
    }
    long long get(int l, int r) {
        return getsum(r) - getsum(l - 1);
    }
};

struct fenwick1 {
    vector<long long> f;
    int nn;
    void init(int n) {
        f.resize(n, 0);
        nn = n;
    }
    void inc(int i, long long val) {
        for (int j = i; j < nn; j = (j | (j + 1))) {
            f[j]+= val;
            f[j] %= M;
        }
    }
    long long getsum(int l) {
        if (l < 0) {
            return 0;
        }
        long long t = 0;
        for (int j = l; j >= 0; j = (j & (j + 1)) - 1) {
            t += f[j];
            t %= M;
        }
        return t;
    }
    long long get(int l, int r) {
        return (getsum(r) - getsum(l - 1)) % M;
    }
};

int n, q;
int a[MAXN];
int w[MAXN];
fenwick wss;
fenwick1 wss1;
fenwick1 pref;
fenwick1 suff;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   // read(FILENAME);
    cin >> n >> q;
    wss.init(n);
    wss1.init(n);
    pref.init(n);
    suff.init(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> w[i];
        wss.inc(i, w[i]);
        wss1.inc(i, 1LL * w[i] * a[i] % M);
    }
    for (int i = 0; i < n; i++) {
        pref.inc(i, 1LL * w[i] * (i + 1) % M);
    }
    for (int i = 0; i < n; i++) {
        suff.inc(i, 1LL * w[i] * (n - i) % M);
    }
    for (int it = 0; it < q; it++) {
        int x;
        cin >> x;
        if (x < 0) {
            int y;
            cin >> y;
            x *= -1;
            x--;
            wss.inc(x, y - w[x]);
            wss1.inc(x, (1LL * y * a[x]) % M -(1LL * w[x] * a[x]) % M);
             pref.inc(x, (1LL * y * (x + 1)) % M - 1LL * w[x] * (x + 1) % M);
             suff.inc(x, (1LL * y * (n - x)) % M - 1LL * w[x] * (n - x) % M);
            w[x] = y;
        } else {
            int y;
            cin >> y;
            x--, y--;
            int l = x;
            int r = y;
            long long f = wss.get(x, y);
            while (l != r) {
                int mid = (l + r) >> 1;
                long long k = wss.get(x, mid);
                if (k >= f - k) {
                    r = mid;
                } else {
                    l = mid + 1;
                }
            }
            //cout << l << endl;
            long long ans = 0;
            if (x < l) {
                long long t = wss1.get(x, l - 1);
                long long f = 1LL * a[l] * (wss.get(x, l - 1) % M) % M;
                //1 * w[l - 1];
                //2 * w[l - 2];
                f -= suff.get(x, l - 1);
                f += (wss.get(x, l - 1) * (n - l)) % M;
                f -= t;
                f %= M;
                if (f < 0) {
                    f += M;
                }
                ans += f;
                ans %= M;
            }
           //  cout << ans << ' ' << it + 1 << ' ' << l << endl;
            if (l + 1 <= y) {
                long long t = wss1.get(l + 1, y);
                //out << t << endl;
                long long f = 1LL * a[l] * (wss.get(l + 1, y) % M) % M;
              //  cout << f << endl;
                //1 * w[l - 1];
                //2 * w[l - 2];
                f += pref.get(l + 1, y);
              // cout << wss.get(l + 1, y) * (l + 1) << endl;
                f -= (wss.get(l + 1, y) * (l + 1)) % M;
               // cout << f - 13 << endl;
                t -= f;
                t %= M;
                if (t < 0) {
                    t += M;
                }
                ans += t;
                ans %= M;
            }
            cout << ans << '\n';
        }
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define L 1000000007

template <class T>
class SegmentTree {
 private:
  vector<T> tree;
  vector<T> data;
  int N;

  inline T OP(T x, T y) { return x + y; }

  T count_sum(int tv, int tl, int tr, int l, int r) {
    l = max(l, tl);
    r = min(r, tr);
    if (l >= r) return T();
    if (l == tl && r == tr) return tree[tv];
    int tm = (tl + tr) / 2;
    return OP(count_sum(2 * tv, tl, tm, l, r),
              count_sum(2 * tv + 1, tm, tr, l, r));
  }

  void update_value(int tv, int tl, int tr, int idx, T new_val) {
    if (tl >= tr) return;
    if (tl == idx && tr == idx + 1) {
      tree[tv] = new_val;
      return;
    }
    int tm = (tl + tr) / 2;
    if (idx < tm)
      update_value(2 * tv, tl, tm, idx, new_val);
    else
      update_value(2 * tv + 1, tm, tr, idx, new_val);
    tree[tv] = OP(tree[2 * tv], tree[2 * tv + 1]);
  }

  T build(int tv, int tl, int tr) {
    if (tl >= tr) return T();
    if (tl + 1 == tr) return tree[tv] = data[tl];
    int tm = (tl + tr) / 2;
    return tree[tv] = OP(build(2 * tv, tl, tm), build(2 * tv + 1, tm, tr));
  }

 public:
  SegmentTree() : SegmentTree(vector<T>()) {}
  SegmentTree(int n) : SegmentTree(vector<T>(n)) {}
  SegmentTree(vector<T> data_) {
    data = data_;
    N = data.size();
    tree = vector<T>(4 * N);
    if (N > 0) build(1, 0, N);
  }

  void set(int idx, T new_value) {
    data[idx] = new_value;
    update_value(1, 0, N, idx, new_value);
  }

  T get(int idx) { return data[idx]; }

  // Counts sum [l, r).
  T sum(int l, int r) { return count_sum(1, 0, N, max(0, l), min(N, r)); }
};

vector<int64_t> a, b;
SegmentTree<int64_t> w, wb;

int64_t find_ans(int l, int r) {
  int zl = l, zr = r, zm;
  while (zl + 1 != zr) {
    int zm = (zl + zr) / 2;
    int64_t SL = w.sum(l, zm);
    int64_t SR = w.sum(zm, r);
    if (SL - SR <= 0)
      zl = zm;
    else
      zr = zm;
  }
  int z = zl;  // Static crate.
  int64_t s1 = (b[z] * (w.sum(l, z) - w.sum(z, r))) % L;
  int64_t s2 = (wb.sum(l, z) - wb.sum(z, r)) % L;
  return ((s1 - s2) % L + L) % L;
}

vector<int64_t> read_vector(int n) {
  vector<int64_t> ans(n);
  for (int i = 0; i < n; i++) cin >> ans[i];
  return ans;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n, q;
  cin >> n >> q;
  a = read_vector(n);
  w = SegmentTree<int64_t>(read_vector(n));
  b = vector<int64_t>(n);
  wb = SegmentTree<int64_t>(n);
  for (int i = 0; i < n; i++) {
    b[i] = a[i] - i;
    wb.set(i, (w.get(i) * b[i]) % L);
  }

  for (int i = 0; i < q; i++) {
    int64_t x, y;
    cin >> x >> y;
    if (x < 0) {
      int idx = (-x) - 1;
      w.set(idx, y);
      wb.set(idx, (y * b[idx]) % L);
    } else {
      cout << find_ans(x - 1, y) << "\n";
    }
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=a;i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ull=unsigned long long;

template<int i,class T>
void print_tuple(ostream&,const T&){
}

template<int i,class T,class H,class ...Args>
void print_tuple(ostream&os,const T&t){
	if(i)os<<",";
	os<<get<i>(t);
	print_tuple<i+1,T,Args...>(os,t);
}

template<class ...Args>
ostream& operator<<(ostream&os,const tuple<Args...>&t){
	os<<"{";
	print_tuple<0,tuple<Args...>,Args...>(os,t);
	return os<<"}";
}

void print(ll x,int suc=1){
	cout<<x;
	if(suc==1)
		cout<<"\n";
	if(suc==2)
		cout<<" ";
}

ll read(){
	ll i;
	cin>>i;
	return i;
}

vi readvi(int n,int off=0){
	vi v(n);
	rep(i,n)v[i]=read()+off;
	return v;
}

template<class T>
void print(const vector<T>&v,int suc=1){
	rep(i,v.size())
		print(v[i],i==int(v.size())-1?suc:2);
}

string readString(){
	string s;
	cin>>s;
	return s;
}

template<class T>
T sq(const T& t){
	return t*t;
}

//#define CAPITAL
void yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void no(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

constexpr ll ten(int n){
	return n==0?1:ten(n-1)*10;
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

int topbit(signed t){
	return t==0?-1:31-__builtin_clz(t);
}
int topbit(ll t){
	return t==0?-1:63-__builtin_clzll(t);
}
int popcount(signed t){
	return __builtin_popcount(t);
}
int popcount(ll t){
	return __builtin_popcountll(t);
}
bool ispow2(int i){
	return i&&(i&-i)==i;
}

bool inc(int a,int b,int c){
	return a<=b&&b<=c;
}

template<class t> void mkuni(vc<t>&v){
	sort(all(v));
	v.erase(unique(all(v)),v.ed);
}

ll rand_int(ll l, ll r) { //[l, r]
    static random_device rd;
    static mt19937 gen(rd());
    return uniform_int_distribution<ll>(l, r)(gen);
}

using uint=unsigned;
using ull=unsigned long long;

//const uint mod=998244353;
const uint mod=1000000007;
//uint mod=1;
struct mint{
	uint v;
	mint(ll vv=0){s(vv%mod+mod);}
	mint& s(uint vv){
		v=vv<mod?vv:vv-mod;
		return *this;
	}
	mint operator-()const{return mint()-*this;}
	mint& operator+=(const mint&rhs){return s(v+rhs.v);}
	mint&operator-=(const mint&rhs){return s(v+mod-rhs.v);}
	mint&operator*=(const mint&rhs){
		v=ull(v)*rhs.v%mod;
		return *this;
	}
	mint&operator/=(const mint&rhs){return *this*=rhs.inv();}
	mint operator+(const mint&rhs)const{return mint(*this)+=rhs;}
	mint operator-(const mint&rhs)const{return mint(*this)-=rhs;}
	mint operator*(const mint&rhs)const{return mint(*this)*=rhs;}
	mint operator/(const mint&rhs)const{return mint(*this)/=rhs;}
	mint pow(int n)const{
		mint res(1),x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}
	mint inv()const{return pow(mod-2);}
	/*mint inv()const{
		int x,y;
		int g=extgcd(v,mod,x,y);
		assert(g==1);
		if(x<0)x+=mod;
		return mint(x);
	}*/
	friend ostream& operator<<(ostream&os,const mint&m){
		return os<<m.v;
	}
	bool operator<(const mint&r)const{return v<r.v;}
	bool operator==(const mint&r)const{return v==r.v;}
};

const int vcmax=(1<<21)+10;
mint fact[vcmax],finv[vcmax],invs[vcmax];
void initfact(){
	fact[0]=1;
	rng(i,1,vcmax){
		fact[i]=fact[i-1]*i;
	}
	finv[vcmax-1]=fact[vcmax-1].inv();
	for(int i=vcmax-2;i>=0;i--){
		finv[i]=finv[i+1]*(i+1);
	}
	for(int i=vcmax-1;i>=1;i--){
		invs[i]=finv[i]*fact[i-1];
	}
}
mint choose(int n,int k){
	return fact[n]*finv[n-k]*finv[k];
}
mint binom(int a,int b){
	return fact[a+b]*finv[a]*finv[b];
}
mint catalan(int n){
	return binom(n,n)-(n-1>=0?binom(n-1,n+1):0);
}

//CF Global3 H
//point update
template<class T,class F>
struct SegTree{
	vc<T> buf;
	int s;
	const F f;
	const T g;
	SegTree(const vc<T>& d,F ff,T gg):f(ff),g(gg){
		int n=d.size();
		s=1;
		while(s<n)s*=2;
		buf.resize(s*2,g);
		rep(i,n)
			buf[i+s]=d[i];
		gnr(i,1,s)
			u(i);
	}
	void u(int i){
		buf[i]=f(buf[i*2],buf[i*2+1]);
	}
	void set(int i,T t){
		i+=s;
		buf[i]=t;
		while(i>>=1)u(i);
	}
	T get(int b,int e,int l,int r,int i){
		if(e<=l||r<=b)return g;
		if(b<=l&&r<=e)return buf[i];
		int m=(l+r)/2;
		return f(get(b,e,l,m,i*2),get(b,e,m,r,i*2+1));
	}
	T get(int b,int e){
		return get(b,e,0,s,1);
	}
};
template<class T,class F>
SegTree<T,F> segtree(const vc<T>& d,F f,T g){
	return SegTree<T,F>(d,f,g);
}

//KUPC2017I
//HDU 5306 Gorgeous Sequence
template<class N>
struct segbeats{
	vc<N> x;
	int s;
	template<class T>
	segbeats(const vc<T>& a){
		int n=a.size();
		s=1;
		while(s<n)s*=2;
		x.resize(s*2);
		rep(i,n)
			x[s+i]=N(a[i]);
		gnr(i,1,s)
			upd(i);
	}
	void push(int i){
		x[i].push(x[i*2],x[i*2+1]);
	}
	void upd(int i){
		x[i]=N::merge(x[i*2],x[i*2+1]);
	}
	template<class F,class... Args>
	void chr(int l,int r,int i,int b,int e,F f,Args... args){
		if(e<=l||r<=b)
			return;
		if(b<=l&&r<=e&&(x[i].*f)(args...))
			return;
		push(i);
		int m=(l+r)/2;
		chr(l,m,i*2,b,e,f,args...);
		chr(m,r,i*2+1,b,e,f,args...);
		upd(i);
	}
	template<class F,class... Args>
	void ch(int b,int e,F f,Args... args){
		assert(b<e);
		chr(0,s,1,b,e,f,args...);
	}
	//use decltype((declval<N>().*F())()) for old-fashioned judges
	template<class F,class G,class H>
	auto getr(int l,int r,int i,int b,int e,F f,G g,H h){
		if(e<=l||r<=b)
			return h;
		if(b<=l&&r<=e)
			return (x[i].*f)();
		push(i);
		int m=(l+r)/2;
		return g(getr(l,m,i*2,b,e,f,g,h),getr(m,r,i*2+1,b,e,f,g,h));
	}
	template<class F,class G,class H>
	auto get(int b,int e,F f,G g,H h){
		assert(b<e);
		return getr(0,s,1,b,e,f,g,h);
	}
	//return minimum index
	template<class F,class...Args>
	pair<int,N> findr(int i,int l,int r,int b,int e,F f,Args&...args){
		if(e<=l||r<=b)return {e,N()};
		if(b<=l&&r<=e){
			if(!(x[i].*f)(args...))return {e,N()};
			if(r-l==1)return {l,x[i]};
		}
		push(i);
		int m=(l+r)/2;
		auto a=findr(i*2,l,m,b,e,f,args...);
		if(a.a<e)return a;
		return findr(i*2+1,m,r,b,e,f,args...);
	}
	template<class F,class...Args>
	pair<int,N> find(int b,int e,F f,Args&...args){
		assert(b<e);
		return findr(1,0,s,b,e,f,args...);
	}
};

//usage

//point set,range query sum lower_bound
struct N{
	int s;
	N(int v=0):s(v){}
	bool set(int v){
		s=v;
		return true;
	}
	void push(N&,N&){
	}
	static N merge(N x,N y){
		return N(x.gets()+y.gets());
	}
	int gets(){return s;}
	bool find(int&v){
		if(s<v){
			v-=s;
			return false;
		}
		return true;
	}
};

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);

	int n,q;cin>>n>>q;
	vi a=readvi(n);
	rep(i,n)a[i]-=i;
	vi w=readvi(n);

	segbeats<N> seg1(w);
	vc<mint> aw(n);
	rep(i,n)aw[i]=a[i]*w[i];
	auto seg2=segtree(aw,[](mint x,mint y){return x+y;},mint(0));

	rep(_,q){
		int x,y;cin>>x>>y;
		if(x<0){
			x=-x-1;
			aw[x]=a[x]*(w[x]=y);
			seg1.ch(x,x+1,&N::set,w[x]);
			seg2.set(x,aw[x]);
		}else{
			x--;
			dmp(x);
			dmp(y);
			dmp(accumulate(w.bg+x,w.bg+y,int(0)));
			dmp(w);
			int s=seg1.get(x,y,&N::gets,[](int p,int r){return p+r;},int(0));
			int h=(s+1)/2;
			dmp(s);
			dmp(h);
			int m=seg1.find(x,y,&N::find,h).a;
			dmp(m);
			dmp(h);
			mint lw=seg1.get(x,m+1,&N::gets,[](int p,int r){return p+r;},int(0));
			mint law=seg2.get(x,m+1);
			mint rw=seg1.get(m,y,&N::gets,[](int p,int r){return p+r;},int(0));
			mint raw=seg2.get(m,y);
			mint ans=lw*a[m]-law+raw-rw*a[m];
			print(ans.v);
			/*int ans=inf;
			rng(m,x,y){
				mint lw=seg1.get(x,m+1,&N::gets,[](int p,int r){return p+r;},int(0));
				mint law=seg2.get(x,m+1);
				mint rw=seg1.get(m,y,&N::gets,[](int p,int r){return p+r;},int(0));
				mint raw=seg2.get(m,y);
				chmin(ans,(lw*a[m]-law+raw-rw*a[m]).v);
			}
			print(ans);*/
		}
	}
}

#include<bits/stdc++.h>
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define index Index
using namespace std;
typedef long long LL;
LL S[400005];
void add(LL x,int k){
	for(int i=x;i<400005;i+=i&-i)
	S[i]+=k;
}
int query(int l,int r){
	LL res1=0,res2=0;
	for(int i=l-1;i>0;i-=i&-i){
		res1+=S[i];
	}
	for(int i=r;i>0;i-=i&-i){
		res2+=S[i];
	}
	LL need=(res1+res2)/2;
//	printf("%lld\n",need);
	int ret=0;
	LL now=0;
//	printf("%d\n",1<<17);
	for(int i=17;i>=0;i--){
		if(now+S[ret+(1<<i)]<=need){
			ret+=(1<<i);
			now+=S[ret];
		}
	}
//	printf("%d\n",now);
	return ret+1;
}
int mod=1e9+7;
LL s1[200005];
LL s2[200005];
LL s3[200005];
LL s4[200005];
void add1(LL *s,int x,LL k){
	for(int i=x;i<200005;i+=i&-i){
		s[i]+=k;
		s[i]=(s[i]%mod+mod)%mod;
	}
}
LL query1(LL *s,int x){
	LL res=0;
	for(int i=x;i>0;i-=i&-i){
		res+=s[i];
		res%=mod;
	}
	return res;
}
int main(){
	int n,q;
	scanf("%d %d",&n,&q);
	LL w[200005];
	LL pos[200005];
	for(int i=1;i<=n;i++)
		scanf("%lld",&pos[i]);
	for(int i=1;i<=n;i++){
		scanf("%lld",&w[i]);
		add(i,w[i]);
		add1(s1,i,w[i]*pos[i]%mod);
		add1(s2,i,w[i]*(1000000005-pos[i])%mod);
		add1(s3,i,w[i]*i%mod);
		add1(s4,i,w[i]*(n+1-i)%mod);
	}
	while(q--){
		int x,y;
		scanf("%d %d",&x,&y);
		if(x>0){
			int mid=query(x,y);
			//printf("%d\n",mid);
			int l=x,r=y;
			LL ret1=query1(s1,r)-query1(s1,mid)-(query1(S,r)-query1(S,mid))%mod*pos[mid]%mod;
			LL ret2=query1(s2,mid-1)-query1(s2,l-1)-(query1(S,mid-1)-query1(S,l-1))%mod*(1000000005-pos[mid])%mod;
			ret1-=query1(s3,r)-query1(s3,mid)-mid*(query1(S,r)-query1(S,mid));
			ret2-=query1(s4,mid-1)-query1(s4,l-1)-(query1(S,mid-1)-query1(S,l-1))*(n+1-mid)%mod;
			ret1=(ret1%mod+mod)%mod;
			ret2=(ret2%mod+mod)%mod;
			printf("%lld\n",(ret1+ret2)%mod);
		}
		else{
			x=-x;
			add(x,y-w[x]);
			add1(s1,x,(y-w[x])*pos[x]%mod);
			add1(s2,x,(y-w[x])*(1000000005-pos[x])%mod);
			add1(s3,x,(y-w[x])*x%mod);
			add1(s4,x,(y-w[x])*(n+1-x)%mod);
			w[x]=y;
		}
	}
}

#include <bits/stdc++.h>

using namespace std;

// array size = 2^k + (n+1) + 1 >= 2(n+1) + 1 (upper bound 3n+2)
// 1-based

#define MOD 1000000007

int n, q, M = 1, at;
long long x[600005], y[600005], z[600005], sum;
int ta, tb, tc;

// [a, b]
inline long long query(int a, int b) {
	long long re = 0;
	a += M - 1;
	b += M + 1;
	while ((a ^ b) != 1) {
		if (!(a & 1))
			re += y[a ^ 1];
		if (b & 1)
			re += y[b ^ 1];
		a >>= 1;
		b >>= 1;
	}
	return re;
}

inline long long dquery(int a, int b, long long c) {
	long long yy = 0;
	long long zz = 0;
	a += M - 1;
	b += M + 1;
	while ((a ^ b) != 1) {
		if (!(a & 1)) {
			yy += y[a ^ 1];
			zz += z[a ^ 1];
		}
		if (b & 1) {
			yy += y[b ^ 1];
			zz += z[b ^ 1];
		}
		a >>= 1;
		b >>= 1;
	}
	return (yy % MOD * c + MOD - zz % MOD) % MOD;
}

int main() {
	scanf("%d%d", &n, &q);
	while (M <= n)
		M <<= 1;
	ta = M | n;
	for (int i = M | 1, j = 0; i <= ta; i++, j++) {
		scanf("%lld", x + i);
		x[i] -= j;
	}
	ta = M | n;
	for (int i = M | 1; i <= ta; i++) {
		scanf("%lld", y+ i);
		z[i] = y[i] * x[i] % MOD;
	}
	for (int i = (M | n) >> 1; i; i--) {
		ta = i << 1;
		tb = ta | 1;
		y[i] = y[ta] + y[tb];
		z[i] = z[ta] + z[tb];
	}
	// for (int i = 1; i <= (M | n); i++) printf("%lld%c", y[i], i & (i + 1) ? ' ' : '\n');
	while (q--) {
		scanf("%d%d", &ta, &tb);
		if (ta < 0) {
			ta = M - ta;
			y[ta] = tb;
			z[ta] = y[ta] * x[ta] % MOD;
			while (ta) {
				ta >>= 1;
				tb = ta << 1;
				tc = tb | 1;
				y[ta] = y[tb] + y[tc];
				z[ta] = z[tb] + z[tc];
			}
		} else {
			sum = query(ta, tb);
			sum /= 2;
			if (ta != 1)
				sum += query(1, ta - 1);
			at = 1;
			while (!(at & M)) {
				at <<= 1;
				if (sum >= y[at]) {
					sum -= y[at];
					at |= 1;
				}
			}
			at ^= M;
			if (ta < at)
				sum = dquery(ta, at - 1, x[M | at]);
			else
				sum = 0;
			if (at < tb) {
				sum += MOD - dquery(at + 1, tb, x[M | at]);
				if (sum >= MOD)
					sum -= MOD;
			}
			printf("%lld\n", sum);
		}
	}
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int maxn = (int)2e5 + 5;
const int mod = (int)1e9 + 7;

int n, q;
int a[maxn];
int w[maxn];

long long s[maxn * 4];
int f[maxn * 4], g[maxn * 4];

#define mid (ll + rr >> 1)

inline void unite(int i, int ll, int rr) {
  s[i] = s[i * 2 + 1] + s[i * 2 + 2];
  f[i] = (f[i * 2 + 1] + f[i * 2 + 2] + s[i * 2 + 2] % mod * (a[mid + 1] - a[ll])) % mod;
  g[i] = (g[i * 2 + 2] + g[i * 2 + 1] + s[i * 2 + 1] % mod * (a[rr] - a[mid])) % mod;
}

void build(int i, int ll, int rr) {
  if (ll < rr) {
    build(i * 2 + 1, ll, mid);
    build(i * 2 + 2, mid + 1, rr);
    unite(i, ll, rr);
  } else {
    s[i] = w[ll];
  }
}

void update(int p, int i, int ll, int rr) {
  if (p < ll || rr < p) {
    return;
  }
  if (ll == rr) {
    s[i] = w[p];
    return;
  }
  update(p, i * 2 + 1, ll, mid);
  update(p, i * 2 + 2, mid + 1, rr);
  unite(i, ll, rr);
}

long long sum(int l, int r, int i, int ll, int rr) {
  if (r < ll || rr < l) {
    return 0;
  }
  if (l <= ll && rr <= r) {
    return s[i];
  }
  return sum(l, r, i * 2 + 1, ll, mid) + sum(l, r, i * 2 + 2, mid + 1, rr);
}

int find(long long tot, int i, int ll, int rr) {
  if (ll == rr) {
    return ll;
  }
  if (s[i * 2 + 1] > tot) {
    return find(tot, i * 2 + 1, ll, mid);
  }
  return find(tot - s[i * 2 + 1], i * 2 + 2, mid + 1, rr);
}

int pos;

int query_left(int l, int r, int i, int ll, int rr) {
  if (r < ll || rr < l) {
    return 0;
  }
  if (l <= ll && rr <= r) {
    return (g[i] + s[i] % mod * (a[pos] - a[rr])) % mod;
  }
  return (query_left(l, r, i * 2 + 1, ll, mid) + query_left(l, r, i * 2 + 2, mid + 1, rr)) % mod;
}

int query_right(int l, int r, int i, int ll, int rr) {
  if (r < ll || rr < l) {
    return 0;
  }
  if (l <= ll && rr <= r) {
    return (f[i] + s[i] % mod * (a[ll] - a[pos])) % mod;
  }
  return (query_right(l, r, i * 2 + 1, ll, mid) + query_right(l, r, i * 2 + 2, mid + 1, rr)) % mod;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> q;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    a[i] -= i;
  }
  for (int i = 1; i <= n; ++i) {
    cin >> w[i];
  }
  build(0, 1, n);
  while (q--) {
    int x, y;
    cin >> x >> y;
    if (x < 0) {
      w[-x] = y;
      update(-x, 0, 1, n);
    } else {
      long long tot = (x > 1 ? sum(1, x - 1, 0, 1, n) : 0) + sum(x, y, 0, 1, n) / 2;
      pos = find(tot, 0, 1, n);
      cout << (query_left(x, pos, 0, 1, n) + query_right(pos, y, 0, 1, n)) % mod << '\n';
    }
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
bool ka;
void setIO(string s) {
    ios_base::sync_with_stdio(0); cin.tie(0);
    freopen((s+".in").c_str(),"r",stdin);
    freopen((s+".out").c_str(),"w",stdout);
}
ll seg[1800001],seg1[1800001];
ll seg2[1800001],seg3[1800001];
ll cura[200001];
ve initial,fat,nowi,nowi1;
ll n;
ll BIT[1800001];
ll curi[1800001],casi[1800001];
void build(ll p,ll l,ll r,ll yo)
{
    if(l==r)
    {
        if(!yo)
        {
            if(!l)seg[p]=0;
            else seg[p]=(nowi[l]*((fat[l]-(fat[l-1]+1)+MOD)%MOD))%MOD;
        }
        else
        {
            if(l==(n-1))seg1[p]=0;
            else seg1[p]=(nowi1[l]*((fat[l+1]-(fat[l]+1)+MOD)%MOD))%MOD;
        }
        return;
    }
    ll med=(l+r)/2;
    build(p*2,l,med,yo);
    build(p*2+1,med+1,r,yo);
    if(!yo)
    {
        seg[p]=(seg[p*2]+seg[p*2+1])%MOD;

    }
    else seg1[p]=(seg1[p*2]+seg1[p*2+1])%MOD;
}

void build3(ll p,ll l,ll r)
{
    if(l==r)
    {
        if(!l)seg2[p]=0;
        else seg2[p]=(fat[l]-(fat[l-1]+1)+MOD)%MOD;
        if(l==(n-1))seg3[p]=0;
        else seg3[p]=(fat[l+1]-(fat[l]+1)+MOD)%MOD;
        cura[l]=seg2[p];
        casi[l]=seg3[p];
        return;
    }
    ll med=(l+r)/2;
    build3(p*2,l,med);
    build3(p*2+1,med+1,r);
    seg2[p]=(seg2[p*2]+seg2[p*2+1]);
    seg3[p]=(seg3[p*2]+seg3[p*2+1]);
}

dos queri(ll p,ll l,ll r,ll l1,ll r1)
{
    if(l>r1 || l1>r)return {0,0};
    if(l>=l1 && r<=r1)return{seg2[p],seg3[p]};
    ll med=(l+r)/2;
    auto u = queri(p*2,l,med,l1,r1);
    auto v = queri(p*2+1,med+1,r,l1,r1);
    return {(u.first+v.first),(u.second+v.second)};
}
ve bos,fos;
ll lazy[1800001],lazy1[1800001];
ll l;
void prop(ll node,ll l,ll r,ll in)
{
    if(l!=r)
    {
        ll med=(l+r)/2;

        auto u = 0;
        auto v = 0;
        if(!in)
        {
        if(!l)u=fos[med];
        else u=(fos[med]-fos[l-1]+MOD)%MOD;
        if(!(med+1))v=fos[r];
        else v=(fos[r]-fos[med]+MOD)%MOD;
        ll soli = (((u)*lazy[node])%MOD);
        ll koli = (((v)*lazy[node])%MOD);
        seg[node*2]=(seg[node*2]+soli+MOD)%MOD;
        seg[node*2+1]=(seg[node*2+1]+koli+MOD)%MOD;
        //debugs(seg[node*2],seg[node*2+1])
        lazy[node*2]=(lazy[node*2]+lazy[node])%MOD;
        lazy[node*2+1]=(lazy[node]+lazy[node*2+1])%MOD;
        lazy[node]=0;
        }
        else
        {
        if(!l)u=bos[med];
        else u=(bos[med]-bos[l-1]+MOD)%MOD;
        if(!(med+1))v=bos[r];
        else v=(bos[r]-bos[med]+MOD)%MOD;
        ll soli = (((u)*lazy1[node])%MOD);
        ll koli = (((v)*lazy1[node])%MOD);
        seg1[node*2]=(seg1[node*2]+soli+MOD)%MOD;
        seg1[node*2+1]=(seg1[node*2+1]+koli+MOD)%MOD;
        lazy1[node*2]=(lazy1[node*2]+lazy1[node])%MOD;
        lazy1[node*2+1]=(lazy1[node*2+1]+lazy1[node])%MOD;
        lazy1[node]=0;
        }
    }
}
void badel(ll p,ll l,ll r,ll l1,ll r1,ll val,ll sasy)
{
    if(l1>r1)return;
    if(l>r1||r<l1)return;
    if(l>=l1 && r<=r1)
    {
        auto cur = 0;
        if(!sasy)
        {
            if(!l)cur=fos[r];
            else cur=(fos[r]-fos[l-1]+MOD)%MOD;
            ll dal = (cur*val)%MOD;
            seg[p]=(seg[p]+dal+MOD)%MOD;
            lazy[p]=(lazy[p]+val)%MOD;
        }
        else
        {
            if(!l)cur=bos[r];
            else cur=(bos[r]-bos[l-1]+MOD)%MOD;
            ll dal = (cur*val)%MOD;
            seg1[p]=(seg1[p]+dal+MOD)%MOD;
            lazy1[p]=(lazy1[p]+val)%MOD;
        }
        prop(p,l,r,sasy);
        return;
    }
    prop(p,l,r,sasy);
    ll med=(l+r)/2;
    badel(p*2,l,med,l1,r1,val,sasy);
    badel(p*2+1,med+1,r,l1,r1,val,sasy);
    if(!sasy)
    {
        seg[p]=(seg[p*2]+seg[p*2+1]+MOD)%MOD;
    }
    else seg1[p]=(seg1[p*2]+seg1[p*2+1]+MOD)%MOD;
}
ll lawej(ll p,ll l,ll r,ll l1,ll r1,ll sasy)
{
    if(l1>r1)return 0;
    if(l>r1||r<l1)return 0;
    if(l>=l1 && r<=r1)
    {
         if(!sasy)return seg[p]%MOD;
         return seg1[p]%MOD;
    }
    prop(p,l,r,sasy);
    ll med=(l+r)/2;
    return (lawej(p*2,l,med,l1,r1,sasy)+lawej(p*2+1,med+1,r,l1,r1,sasy)+MOD)%MOD;
}
void update(ll index,ll val)
{
    for (index++; index <= n; index+=(index&(-index)))
    {
        BIT[index]+=val;
    }
}
ll query(ll index)
{
    ll result=0;
    for (index++;index>0;index-=(index&(-index)))
    {
        result=(result+BIT[index]);
    }
    return result;
}
ll range(ll l,ll r)
{
    if(l>r)return 0;
    return ((query(r)-query(l-1)));
}
int main()
{
    flash;
    ll q;
    cin>>n>>q;
    if(n==200000)ka=true;
    l=log2(n);
    int index=0;
    for (ll i = 0; i < n; ++i)
    {
        ll xo;
        cin>>xo;
        fat.pb(xo);
    }
    for (ll i = 0; i < n; ++i)
    {
        ll yo;
        cin>>yo;
        initial.pb(yo);
        curi[i]=yo;
        update(i,yo);
    }
    ll cumi=0;
    ve useful;
    for (ll i = 0; i < n; ++i)
    {
       nowi.pb(cumi);
       cumi=(cumi+initial[i])%MOD;
       useful.pb(cumi);
    }
    cumi=0;
    for (ll i = n-1; i >= 0; --i)
    {
       nowi1.pb(cumi);
       cumi=(cumi+initial[i])%MOD;
    }
    reverse(nowi1.begin(),nowi1.end());
    build(1,0,n-1,0);
    build(1,0,n-1,1);
    build3(1,0,n-1);
    cumi=0;
    for (int i = 0; i < n; ++i)
    {
        cumi=(cumi+cura[i])%MOD;
        fos.pb(cumi);
    }
    cumi=0;
    for (int i = 0; i < n; ++i)
    {
        cumi=(cumi+casi[i])%MOD;
        bos.pb(cumi);
    }
    while(q--)
    {
        ll x;
        cin>>x;
        index++;
        if(x<0)
        {
            x=-x-1;
            ll newi;
            ll lasti=curi[x];
            cin>>newi;
            update(x,newi-lasti);
            //debug(newi-lasti)
            badel(1,0,n-1,x+1,n-1,newi-lasti,0);
            badel(1,0,n-1,0,x-1,newi-lasti,1);
            curi[x]=newi;
        }
        else
        {
            ll r;
            cin>>r;
            ll l=x;
            l--,r--;
            ll low=l;
            ll high=r;
            ll besti=l;
            while(low<=high)
            {
                ll med=(low+high)/2;
                ll k = range(l,med-1);
                ll f = range(med,r);
                if((k-f)<0)
                {
                    besti=med;
                    low=med+1;
                }
                else
                {
                    high=med-1;
                }
            }
            ll fol=0;
            if(!l)fol=fos[besti]%MOD;
            else fol = (fos[besti]-fos[l-1]+MOD)%MOD;
            ll sol=0;
            if(!besti)sol=bos[r]%MOD;
            else sol = (bos[r]-bos[besti-1]+MOD)%MOD;
            auto kal = range(0,l-1)%MOD;
            auto nal = range(r+1,n-1)%MOD;
            //debugs(kal,nal)
            auto fin1 = lawej(1,0,n-1,l,besti,0)%MOD;
            auto fin2 = lawej(1,0,n-1,besti,r,1)%MOD;
            fin1 = ((fin1-((fol*kal)%MOD))+MOD)%MOD;
            fin2 = ((fin2-((sol*nal)%MOD))+MOD)%MOD;
            cout<<(fin1+fin2)%MOD<<'\n';
        }
    }
  return 0;
}
//code the AC sol !
// BS/queue/map

#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
const lli N=200009, mod=1e9+7;
int n, q, a[N], low[4*N], high[4*N], leaf[N];
lli b[N], w[N], aw[N], sw[4*N], saw[4*N], sb[4*N];
void Built(int v, int l, int h)
{
	low[v]=l;
	high[v]=h;
	if(l==h)
	{
		sw[v]=w[l];
		saw[v]=aw[l];
		leaf[l]=v;
		sb[v]=b[l];
	}
	else
	{
		lli m=(l+h)/2;
		Built(v*2, l, m);
		Built(v*2+1, m+1, h);
		sw[v]=(sw[v*2]+sw[v*2+1]);
		saw[v]=(saw[v*2]+saw[v*2+1]);
		sb[v]=(sb[v*2]+sb[v*2+1]);
	}
}
lli Next()
{
	register char ch=getchar();
	bool neg=0;
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')
		{
			neg=1;
		}
		ch=getchar();
	}
	lli l=0;
	while(ch>='0'&&ch<='9')
	{
		l=l*10+ch-'0';
		ch=getchar();
	}
	if(neg)
	{
		return -l;
	}
	return l;
}
void Inp()
{
	n=Next();
	q=Next();
	for(int i=1;i<=n;i++)
	{
		a[i]=Next();
	}
	for(int i=1;i<=n;i++)
	{
		w[i]=Next();
		aw[i]=(w[i]*i)%mod;
		b[i]=(w[i]*a[i])%mod;
	}
	Built(1, 1, n);
}
lli Update(int k)
{
	lli v=leaf[k];
	sw[v]=w[k];
	saw[v]=aw[k];
	sb[v]=b[k];
	v=v/2;
	while(v!=0)
	{
		sw[v]=(sw[v*2]+sw[v*2+1]);
		saw[v]=(saw[v*2]+saw[v*2+1]);
		sb[v]=(sb[v*2]+sb[v*2+1]);
		v=v/2;
	}
}
lli Sumw(int v, int l, int h)
{
	if(low[v]>h||high[v]<l)
	{
		return 0;
	}
	if(low[v]>=l&&high[v]<=h)
	{
		return sw[v];
	}
	return Sumw(v*2, l, h)+Sumw(v*2+1, l, h);
}
lli Sumb(int v, int l, int h)
{
	if(low[v]>h||high[v]<l)
	{
		return 0;
	}
	if(low[v]>=l&&high[v]<=h)
	{
		return sb[v];
	}
	return (Sumb(v*2, l, h)+Sumb(v*2+1, l, h));
}
lli Sumaw(int v, int l, int h)
{
	if(low[v]>h||high[v]<l)
	{
		return 0;
	}
	if(low[v]>=l&&high[v]<=h)
	{
		return saw[v];
	}
	return (Sumaw(v*2, l, h)+Sumaw(v*2+1, l, h));
}
lli Tinhaw(int l, int r, int k)
{
	return (Sumaw(1, l, r)+(k-l)*Sumw(1, l, r));
}
lli Calc1(int l, int r, int k)
{
	lli cnt=(r-l+1);
	return ((Sumw(1, l, r)%mod)*k-Sumb(1, l, r)+Tinhaw(l, r, 0));
}
lli Calc2(int l, int r, int k, int ol)
{
	if(r<l)
	{
		return 0;
	}
	return (-Sumb(1, l, r)+(Sumw(1, l, r)%mod)*k+Tinhaw(l, r, l-ol));
}
lli Calc3(int l, int r, int k, int ol)
{
	return (Sumb(1, l, r)-(Sumw(1, l, r)%mod)*k-Tinhaw(l, r, l-ol));
}
lli Calc(int l, int r, int k)
{
	int v=upper_bound(a+l, a+r+1, k)-a-1, low=v+1, high=r;
	while(low<=high)
	{
		lli mid=(low+high)/2;
		if(a[mid]<=k+mid-l)
		{
			low=mid+1;
		}
		else
		{
			high=mid-1;
		}
	}
	return (Calc1(l, v, k)+Calc2(v+1, high, k, l)+Calc3(high+1, r, k, l))%mod;
}
void Query(int p, int q)
{
	int l=p, h=q;
	lli s=Sumw(1, p, q);
	while(l<=h)
	{
		lli m=(l+h)/2;
		if(Sumw(1, p, m)<=s/2)
		{
			l=m+1;
		}
		else
		{
			h=m-1;
		}
	}
	cout<<(Calc(p, q, a[l]-(l-p))+mod)%mod<<'\n';
}
void Solve()
{
	for(int i=1;i<=q;i++)
	{
		int x, y;
		x=Next();
		y=Next();
		if(x<0)
		{
			x=-x;
			w[x]=y;
			b[x]=(a[x]*w[x])%mod;
			aw[x]=(w[x]*x)%mod;
			Update(x);

		}
		else
		{
			Query(x, y);
		}
	}
}
int main()
{
	//freopen("test.inp","r",stdin);
	Inp();
	Solve();
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7, nax = 2e5 + 10;
///clean code

void plusle(int &a, int b){
    if( (a += b) >= mod) a -= mod;
}
void minun(int  &a, int b){
    if(( a -= b) < 0) a += mod;
}
int add(int a, int b){
    return ((a += b) >= mod) ? a - mod : a;
}
int sub(int a, int b){
    return ( (a -= b) < 0 ) ? a + mod : a;
}
int mul(int a, int b){
    return (1LL * a * b) % mod;
}

template<class T = ll> struct fenwick{
    T bit[nax];
    T get(int idx){
        T res = 0;
        for(; idx > 0 ; idx -= idx & - idx )
            res += bit[idx];
        return res;
    }
    void update(int idx, int val){
        for(; idx < nax ; idx += idx & - idx)
            bit[idx] += val;
    }
    T get(int l,int r){
        if(l > r) return 0;
        return get(r) - get(l - 1);
    }
};
struct modfenwick{
    int bit[nax];
    modfenwick(){
        memset(bit, 0, sizeof(bit));
    }
    int get(int idx){
        int res = 0;
        for(; idx > 0 ; idx -= idx & - idx )
            plusle(res, bit[idx]);
        return res;
    }
    void update(int idx, int val){
        for(; idx < nax ; idx += idx & - idx)
            plusle(bit[idx], val);
    }
    int get(int l,int r){
        if(l > r) return 0 ;
        return sub(get(r), get(l - 1));
    }
};
int n, q, a[nax], w[nax];
modfenwick fm;
fenwick<ll> f1;

int main(){
    scanf("%d %d", &n, &q);
    for(int i = 1 ;i <= n ;i ++){
        scanf("%d", a + i);
        a[i] -= i;
    }
    for(int i = 1 ;i <= n ; i ++){
        scanf("%d", w + i);
        f1.update(i, w[i]);
        fm.update(i, mul(a[i], w[i]));
    }
    while(q -- ){
        int x, y;
        scanf("%d %d", &x, &y);
        if(x < 0){
            x = -x ;
            int res = ((-mul(a[x], w[x]) ) + mod);
            if(res == mod) res = 0;
            fm.update(x, res);
            f1.update(x, -w[x]);
            w[x] = y;
            f1.update(x, y);
            fm.update(x, mul(a[x], y));
        }
        else{
            int l  = x, r =  y, ans = x;
            /*while(l <= r){
                int mid = l + r >> 1;
                if(f1.get(x, mid) * 2 >= sum){
                    ans = mid;
                    r = mid - 1;
                }
                else l = mid + 1;
            }*/
            ///let's try binary lifting
            ///sum[1, x - 1] * 2  + sum[x, i] * 2 < sum[x, y] +  sum[1, x - 1] * 2
            ll sum = f1.get(x,  y) + f1.get(1, x - 1) * 2;

            int lim = y;
            int pos = 0; ll cur = 0;
            for(int  i = __lg(lim) ; i >=0 ; i --){
                if( pos + (1 << i) <= lim && (cur + f1.bit[pos + (1 << i)]) * 2 < sum ){
                    pos += (1 << i);
                    cur += f1.bit[pos];
                }
            }
            ll res = 0;
            int c = min(y, pos + 1);
            //printf("sum = %lld pos = %d\n",sum, c);
            if(x < c){
            res += (1LL * a[c] *(f1.get(x, c) % mod));
            res -= fm.get(x, c);
            }
            if(y > c){
            res -= (1LL * a[c] *(f1.get(c + 1, y) % mod)) ;
            res += fm.get(c + 1 , /*r*/ y ); // ok funny enough
            }
            res %= mod;
            if(res < 0)res += mod;
            printf("%lld\n", res);
        }
    }
    /**
    sum[1, x - 1] * 2 sum[x, i] * 2 < sum[x, y] +
    */
}

#pragma GCC optimize(3)
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define MID ((l+r)>>1)
#define LEFT (index<<1)
#define RIGHT (index<<1|1)
#define MAX_SIZE 524292
typedef long long ll;
using namespace std;

const ll mod = 1e9 + 7;

struct segt {
    // for a leaf node d = wt_i * (x_i - i)
    ll wt, d;
    segt operator + (segt other) const {
        segt ret;
        ret.wt = this->wt + other.wt;
        ret.d = (this->d + other.d) % mod;
        return ret;
    }
};

segt tree[MAX_SIZE];
ll x[MAX_SIZE], w[MAX_SIZE];
int n, q;

void build(int l, int r, int index) {
    if (l > r) return;
    if (l == r) {
        tree[index].wt = w[l];
        tree[index].d = w[l] * (x[l] - l);
        return;
    }

    build(l, MID, LEFT);
    build(MID + 1, r, RIGHT);
    tree[index] = tree[LEFT] + tree[RIGHT];
}
// update w[pt] to val
void update(int pt, int l, int r, int index, ll val) {
    if (l > r || pt < l || pt > r) return;
    if (l == r) {
        w[pt] = val;
        tree[index].wt = w[pt];
        tree[index].d = w[pt] * (x[pt] - l);
        return;
    }

    if (pt <= MID) {
        update(pt, l, MID, LEFT, val);
    } else {
        update(pt, MID + 1, r, RIGHT, val);
    }

    tree[index] = tree[LEFT] + tree[RIGHT];
}

segt query(int start, int end, int l, int r, int index) {
    if (start > end || l > r || start > r || l > end) return tree[0];
    if (start <= l && r <= end) return tree[index];
    if (end <= MID) {
        return query(start, end, l, MID, LEFT);
    }

    if (start >= MID + 1) {
        return query(start, end, MID + 1, r, RIGHT);
    }

    return query(start, end, l, MID, LEFT) + query(start, end, MID + 1, r, RIGHT);
}

int main() {
    int i;
    scanf("%d%d", &n, &q);
    for (i = 1; i <= n; ++i) {
        scanf("%I64d", &x[i]);
    }

    for (i = 1; i <= n; ++i) {
        scanf("%I64d", &w[i]);
    }

    build(1, n, 1);

    while (q-- > 0) {
        ll L, R;
        scanf("%I64d%I64d", &L, &R);
        if (L < 0) {
            update(-L, 1, n, 1, R);
        } else {
            if (L == R) {
                printf("0\n");
                continue;
            }
            // query [x, y] moving cost
            int low = L, high = R;
            int pivot = low;
            auto W = query(L, R, 1, n, 1).wt;
            while (low <= high) {
                int mid = (low + high) >> 1;
                auto ret1 = query(L, mid, 1, n, 1);
                if (ret1.wt >= W - ret1.wt) {
                    pivot = mid;
                    high = mid - 1;
                } else {
                    low = mid + 1;
                }
            }

            // moving all [x, pivot] to pivot
            auto ret1 = query(L, pivot, 1, n, 1);
            auto ret2 = query(pivot + 1, R, 1, n, 1);
            // moving all [pivot + 1, y] to pivot
            ll cost1 = (x[pivot] - pivot) * (ret1.wt % mod) - ret1.d;
            ll cost2 = ret2.d + (ret2.wt % mod) * (pivot - x[pivot]);
            ll ans = (cost1 + cost2) % mod;
            if (ans < 0) ans += mod;
            printf("%I64d\n", ans);
        }
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7, nax = 2e5 + 10;
//#define LOCAL
#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif // LOCAL
void plusle(int &a, int b){
    if( (a += b) >= mod) a -= mod;
}
void minun(int  &a, int b){
    if(( a -= b) < 0) a += mod;
}
int add(int a, int b){
    return ((a += b) >= mod) ? a - mod : a;
}
int sub(int a, int b){
    return ( (a -= b) < 0 ) ? a + mod : a;
}
int mul(int a, int b){
    return (1LL * a * b) % mod;
}

template<class T = ll> struct fenwick{
    T bit[nax];
    T get(int idx){
        T res = 0;
        for(; idx > 0 ; idx -= idx & - idx )
            res += bit[idx];
        return res;
    }
    void update(int idx, int val){
        for(; idx < nax ; idx += idx & - idx)
            bit[idx] += val;
    }
    T get(int l,int r){
        if(l > r) return 0 ;
        return get(r) - get(l - 1);
    }
};
struct modfenwick{
    int bit[nax];
    modfenwick(){
        memset(bit, 0, sizeof(bit));
    }
    int get(int idx){
        int res = 0;
        for(; idx > 0 ; idx -= idx & - idx )
            plusle(res, bit[idx]);
        return res;
    }
    void update(int idx, int val){
        for(; idx < nax ; idx += idx & - idx)
            plusle(bit[idx], val);
    }
    int get(int l,int r){
        if(l > r) return 0;
        return sub(get(r), get(l - 1));
    }
};
int n, q, a[nax], w[nax];
modfenwick fm;
fenwick<ll> f1;

int main(){
    scanf("%d %d", &n, &q);
    for(int i = 1 ;i <= n ;i ++){
        scanf("%d", a + i);
        a[i] -= i;
        ///became s[i]
    }
    for(int i = 1 ;i <= n ; i ++){
        scanf("%d", w + i);
        f1.update(i, w[i]);
        fm.update(i, mul(a[i], w[i]));
        ///fenwick mod have sum of i * w[i]
    }
    eprintf("%d\n", fm.get(4 ,  5));
    while(q -- ){
        int x, y;
        scanf("%d %d", &x, &y);
        if(x < 0){
            ///update box i-th to be y = new weight
            x = -x ;
            int res = ((-mul(a[x], w[x]) ) + mod ) % mod;
            fm.update(x, res);
            f1.update(x, -w[x]);
            w[x] = y;
            f1.update(x, y);
            fm.update(x, mul(a[x], y));
        }
        else{
            ///query x, y
            ///important step
            ///find right most index such that sum[l, x] <= sum[x + 1, r]
            int l  = x, r =  y, ans = x;
            ll sum = f1.get(l, r);
            while(l <= r){
                int mid = l + r >> 1;
                if(f1.get(x, mid) * 2 >= sum){
                    ans = mid;
                    r = mid - 1;
                }
                else l = mid + 1;
            }
            eprintf("target = %d\n", ans);
            ///calculate ....
            ll res = 0;
            int c = ans;
            if(x < c){
            res = (1LL * a[c] *(f1.get(x, c) % mod)) % mod;
            eprintf("debug 1 %lld\n", (1LL * a[c] *(f1.get(x, c) % mod)) % mod);
            res -= fm.get(x, c);
            eprintf("debug 2 %lld\n", fm.get(x, c));
            ///wrong formula going to check...
            }
            if(y > c){
            res -= (1LL * a[c] *(f1.get(c + 1, y) % mod)) % mod;
            eprintf("debug 3 %lld\n", (1LL * a[c] *(f1.get(x, c) % mod)) % mod);
            res += fm.get(c + 1 , /*r*/ y ); // ok funny enough
            eprintf("debug 4 %lld\n", fm.get(c + 1 , y));
            ///should get 18 15 9 13
            res %= mod;
            }
            if(res < 0)res += mod;
            eprintf("ANS = ");
            printf("%lld\n", res);
        }
    }

}

 #include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define LL long long
#define pb push_back
int a[(int)1e6],w[(int)1e6];
const int maxn = 100100;
const int mod = 1e9+7;
int tree[maxn<<2],tree2[maxn<<2],tree3[maxn<<2];
int n;
inline void add(int r,int v){
    while(r<=n)tree[r]+=v,r+=r&-r;
}
inline int query(int r){
    int ans=0;
    while(r)ans+=tree[r],r&=r-1;
    return ans;
}
inline int query(int l,int r){
    return query(r)-query(l-1);
}
inline void add1(int r,int v){
    while(r<=n)(tree2[r]+=v)%=mod,r+=r&-r;
}
inline int query1(int r){
    int ans=0;
    while(r)(ans+=tree2[r])%=mod,r&=r-1;
    return ans;
}
inline int query1(int l,int r){
    return query1(r)-query1(l-1);
}

inline void add2(int r,int v){
    while(r<=n)(tree3[r]+=v)%=mod,r+=r&-r;
}
inline int query2(int r){
    int ans=0;
    while(r)(ans+=tree3[r])%=mod,r&=r-1;
    return ans;
}
inline int query2(int l,int r){
    return query2(r)-query2(l-1);
}
inline int move_1(int l,int r,int pos){
    int len=r-l+1;
    return pos*(query(l,r)%mod)%mod+query2(l,r)-query(l,r)*l%mod  - query1(l,r);
}
inline int move_2(int l,int r,int pos){
    int len=r-l+1;
    return -pos*(query(l,r)%mod)%mod-query2(l,r)+query(l,r)%mod*l%mod + query1(l,r);
}
signed main(){
    ios::sync_with_stdio(false);
    int q;
    cin >>n >>q;
    for(int i=1;i<=n;++i){
        cin >> a[i];
    }
    for(int i=1;i<=n;++i){
        cin >> w[i];
        add(i,w[i]);
        add1(i,a[i]*w[i]%mod);
        add2(i,(i)*w[i]%mod);
    }
    while(q--){
        int x,y;
        cin >>x >>y;
        if(x<0){
            x=-x;
            add(x,-w[x]);
            add1(x,mod-a[x]*w[x]%mod);
            add2(x,mod-(x)*w[x]%mod);
            w[x]=y;
            add(x,w[x]);
            add1(x,a[x]*w[x]%mod);
            add2(x,(x)*w[x]%mod);
        }else{
            int l = x, r=y;
            while(l!=r){
                int mid=l+r>>1;
                if(query(x,mid) < query(mid+1,y))l=mid+1;
                else r=mid;
            }
            cout << ((move_1(x,r,a[r]-(r-x+1)+1)+move_2(r+1,y,a[r]+1))%mod+mod)%mod<<endl;
        }
    }
}
/**/

#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long,long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,j,k)  for(register int i=(int)(j);i<=(int)(k);i++)
#define rrep(i,j,k) for(register int i=(int)(j);i>=(int)(k);i--)

ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}

const int mod=1e9+7;
const int maxn=200200;
int n,q,a[maxn];
struct Node{
	int l,r;
	ll val;
} tr[maxn*4];
ll w[maxn];
#define lowbit(x) (x&-x)
struct BIT{
	ll a[maxn*2];
	void add(int x,ll k){
		while(x<=400000){
			a[x]+=k;
			x+=lowbit(x);
		}
	}
	ll ask(int x){
		ll ret=0;
		while(x){
			ret+=a[x];
			x-=lowbit(x);
		}
		return ret;
	}
	ll sum(int l,int r){
		return ask(r)-ask(l-1);
	}
} lzt1,lzt2;

#define lc (i<<1)
#define rc (i<<1|1)
void build(int i,int l,int r){
	tr[i].l=l,tr[i].r=r;
	if(l==r){
		tr[i].val=w[tr[i].l];
		return;
	}
	int md=(l+r)>>1;
	build(lc,l,md);build(rc,md+1,r);
	tr[i].val=tr[lc].val+tr[rc].val;
}

void update(int i,int l,int r){
	if(tr[i].l==tr[i].r){
		tr[i].val=r;
		return;
	}
	int md=(tr[i].l+tr[i].r)>>1;
	if(md>=l) update(lc,l,r);
	else update(rc,l,r);
	tr[i].val=tr[lc].val+tr[rc].val;
}

int fnd(int i,ll o){
	if(tr[i].l==tr[i].r){
		return tr[i].l;
	}
	if(tr[lc].val>=o) return fnd(lc,o);
	else return fnd(rc,o-tr[lc].val);
}

int main(){
	n=read(),q=read();
	rep(i,1,n) a[i]=read()-i+1;
	rep(i,1,n){
		w[i]=read();
		lzt1.add(i,w[i]);
		lzt2.add(i,w[i]*1ll*a[i]%mod);
	}
	build(1,1,n);
	while(q--){
		int l=read(),r=read();
		if(l<0){
			l=-l;
			lzt1.add(l,-w[l]);
			lzt2.add(l,-(w[l]*1ll*a[l])%mod);
			w[l]=r;
			lzt1.add(l,w[l]);
			lzt2.add(l,w[l]*1ll*a[l]%mod);
			update(1,l,r);
		}
		else{
			ll L=lzt1.ask(l-1),R=lzt1.ask(r);
			int k=fnd(1,(L+R+1)>>1ll);
			ll ans=a[k]*1ll*(lzt1.sum(l,k-1)%mod)%mod-lzt2.sum(l,k-1)%mod+lzt2.sum(k+1,r)%mod-a[k]*1ll*(lzt1.sum(k+1,r)%mod)%mod;
			ans=(ans%mod+mod)%mod;
			printf("%I64d\n",ans);
		}
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7, nax = 2e5 + 10;
///clean code

void plusle(int &a, int b){
    if( (a += b) >= mod) a -= mod;
}
void minun(int  &a, int b){
    if(( a -= b) < 0) a += mod;
}
int add(int a, int b){
    return ((a += b) >= mod) ? a - mod : a;
}
int sub(int a, int b){
    return ( (a -= b) < 0 ) ? a + mod : a;
}
int mul(int a, int b){
    return (1LL * a * b) % mod;
}

template<class T = ll> struct fenwick{
    T bit[nax];
    T get(int idx){
        T res = 0;
        for(; idx > 0 ; idx -= idx & - idx )
            res += bit[idx];
        return res;
    }
    void update(int idx, int val){
        for(; idx < nax ; idx += idx & - idx)
            bit[idx] += val;
    }
    T get(int l,int r){
        return get(r) - get(l - 1);
    }
};
struct modfenwick{
    int bit[nax];
    modfenwick(){
        memset(bit, 0, sizeof(bit));
    }
    int get(int idx){
        int res = 0;
        for(; idx > 0 ; idx -= idx & - idx )
            plusle(res, bit[idx]);
        return res;
    }
    void update(int idx, int val){
        for(; idx < nax ; idx += idx & - idx)
            plusle(bit[idx], val);
    }
    int get(int l,int r){
        return sub(get(r), get(l - 1));
    }
};
int n, q, a[nax], w[nax];
modfenwick fm;
fenwick<ll> f1;

int main(){
    scanf("%d %d", &n, &q);
    for(int i = 1 ;i <= n ;i ++){
        scanf("%d", a + i);
        a[i] -= i;
    }
    for(int i = 1 ;i <= n ; i ++){
        scanf("%d", w + i);
        f1.update(i, w[i]);
        fm.update(i, mul(a[i], w[i]));
    }
    while(q -- ){
        int x, y;
        scanf("%d %d", &x, &y);
        if(x < 0){
            x = -x ;
            int res = ((-mul(a[x], w[x]) ) + mod);
            if(res == mod) res = 0;
            fm.update(x, res);
            f1.update(x, -w[x]);
            w[x] = y;
            f1.update(x, y);
            fm.update(x, mul(a[x], y));
        }
        else{
            int l  = x, r =  y, ans = x;
            ll sum = f1.get(l, r);
            while(l <= r){
                int mid = l + r >> 1;
                if(f1.get(x, mid) * 2 >= sum){
                    ans = mid;
                    r = mid - 1;
                }
                else l = mid + 1;
            }
            ll res = 0;
            int c = ans;
            if(x < c){
            res += (1LL * a[c] *(f1.get(x, c) % mod));
            res -= fm.get(x, c);
            }
            if(y > c){
            res -= (1LL * a[c] *(f1.get(c + 1, y) % mod)) ;
            res += fm.get(c + 1 , /*r*/ y ); // ok funny enough
            }
            res %= mod;
            if(res < 0)res += mod;
            printf("%lld\n", res);
        }
    }

}

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;
template <class T> using Tree = tree<T, null_type, less<T>,
    rb_tree_tag, tree_order_statistics_node_update>;

using ll = long long;
using ld = long double;
using db = double;
using str = string; // yay python!

using pi = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;

using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;

#define tcT template<class T
// ^ lol this makes everything look weird but I'll try it
tcT> using V = vector<T>;
tcT, size_t SZ> using AR = array<T,SZ>;

// pairs
#define mp make_pair
#define f first
#define s second

// vectors
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound

// loops
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18; // not too close to LLONG_MAX
const int IINF = 1e9;
const ld PI = acos((ld)-1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1}; // for every grid problem!!
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

// helper funcs
constexpr int pct(int x) { return __builtin_popcount(x); } // # of bits set
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x))
ll cdiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up
ll fdiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down

tcT> bool ckmin(T& a, const T& b) {
	return b < a ? a = b, 1 : 0; } // set a = min(a,b)
tcT> bool ckmax(T& a, const T& b) {
	return a < b ? a = b, 1 : 0; }

#define tcTU tcT, class U
tcTU> T fstTrue(T lo, T hi, U f) {
	hi ++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true
		T mid = lo+(hi-lo)/2;
		f(mid) ? hi = mid : lo = mid+1;
	}
	return lo;
}
tcTU> T lstTrue(T lo, T hi, U f) {
	lo --; assert(lo <= hi); // assuming f is decreasing
	while (lo < hi) { // find first index such that f is true
		T mid = lo+(hi-lo+1)/2;
		f(mid) ? lo = mid : hi = mid-1;
	}
	return lo;
}
tcT> void remDup(vector<T>& v) { // sort and remove duplicates
	sort(all(v)); v.erase(unique(all(v)),end(v)); }
tcTU> void erase(T& t, const U& u) { // don't erase
	auto it = t.find(u); assert(it != end(t));
	t.erase(u); } // element that doesn't exist from (multi)set

// INPUT
#define tcTUU tcT, class ...U
tcT> void re(complex<T>& c);
tcTU> void re(pair<T,U>& p);
tcT> void re(vector<T>& v);
tcT, size_t SZ> void re(AR<T,SZ>& a);

tcT> void re(T& x) { cin >> x; }
void re(db& d) { str t; re(t); d = stod(t); }
void re(ld& d) { str t; re(t); d = stold(t); }
tcTUU> void re(T& t, U&... u) { re(t); re(u...); }

tcT> void re(complex<T>& c) { T a,b; re(a,b); c = {a,b}; }
tcTU> void re(pair<T,U>& p) { re(p.f,p.s); }
tcT> void re(vector<T>& x) { trav(a,x) re(a); }
tcT, size_t SZ> void re(AR<T,SZ>& x) { trav(a,x) re(a); }

// TO_STRING
#define ts to_string
str ts(char c) { return str(1,c); }
str ts(const char* s) { return (str)s; }
str ts(str s) { return s; }
str ts(bool b) {
	#ifdef LOCAL
		return b ? "true" : "false";
	#else
		return ts((int)b);
	#endif
}
tcT> str ts(complex<T> c) {
	stringstream ss; ss << c; return ss.str(); }
str ts(vector<bool> v) {
	str res = "{"; F0R(i,sz(v)) res += char('0'+v[i]);
	res += "}"; return res; }
template<size_t SZ> str ts(bitset<SZ> b) {
	str res = ""; F0R(i,SZ) res += char('0'+b[i]);
	return res; }
tcTU> str ts(pair<T,U> p);
tcT> str ts(T v) { // containers with begin(), end()
	#ifdef LOCAL
		bool fst = 1; str res = "{";
		for (const auto& x: v) {
			if (!fst) res += ", ";
			fst = 0; res += ts(x);
		}
		res += "}"; return res;
	#else
		bool fst = 1; str res = "";
		for (const auto& x: v) {
			if (!fst) res += " ";
			fst = 0; res += ts(x);
		}
		return res;

	#endif
}
tcTU> str ts(pair<T,U> p) {
	#ifdef LOCAL
		return "("+ts(p.f)+", "+ts(p.s)+")";
	#else
		return ts(p.f)+" "+ts(p.s);
	#endif
}

// OUTPUT
tcT> void pr(T x) { cout << ts(x); }
tcTUU> void pr(const T& t, const U&... u) {
	pr(t); pr(u...); }
void ps() { pr("\n"); } // print w/ spaces
tcTUU> void ps(const T& t, const U&... u) {
	pr(t); if (sizeof...(u)) pr(" "); ps(u...); }

// DEBUG
void DBG() { cerr << "]" << endl; }
tcTUU> void DBG(const T& t, const U&... u) {
	cerr << ts(t); if (sizeof...(u)) cerr << ", ";
	DBG(u...); }
#ifdef LOCAL // compile with -DLOCAL, chk -> fake assert
	#define dbg(...) cerr << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
	#define chk(...) if (!(__VA_ARGS__)) cerr << "Line(" << __LINE__ << ") -> function(" \
		 << __FUNCTION__  << ") -> CHK FAILED: (" << #__VA_ARGS__ << ")" << "\n", exit(0);
#else
	#define dbg(...) 0
	#define chk(...) 0
#endif

// FILE I/O
void setIn(str s) { freopen(s.c_str(),"r",stdin); }
void setOut(str s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { cin.tie(0)->sync_with_stdio(0); }
void setIO(str s = "") {
	unsyncIO();
	// cin.exceptions(cin.failbit);
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template<class T> struct Seg { // comb(ID,b) = b
	const T ID = 0; T comb(T a, T b) { return a+b; }
	int n; vector<T> seg;
	void init(int _n) { n = _n; seg.assign(2*n,ID); }
	void pull(int p) { seg[p] = comb(seg[2*p],seg[2*p+1]); }
	void upd(int p, T val) { // set val at position p
		seg[p += n] = val; for (p /= 2; p; p /= 2) pull(p); }
	T query(int l, int r) {	// sum on interval [l, r]
		T ra = ID, rb = ID;
		for (l += n, r += n+1; l < r; l /= 2, r /= 2) {
			if (l&1) ra = comb(ra,seg[l++]);
			if (r&1) rb = comb(seg[--r],rb);
		}
		return comb(ra,rb);
	}
	int search(ll SUM, int idx = 1){
		if(idx >= n)
			return idx - n;
		if(seg[2 * idx] <= SUM)
			return search(SUM - seg[2 * idx], 2 * idx + 1);
		return search(SUM, 2 * idx);
	}
};

template<class T> struct Seg2 { // comb(ID,b) = b
	const T ID = 0; T comb(T a, T b) { return (a+b) % MOD; }
	int n; vector<T> seg;
	void init(int _n) { n = _n; seg.assign(2*n,ID); }
	void pull(int p) { seg[p] = comb(seg[2*p],seg[2*p+1]); }
	void upd(int p, T val) { // set val at position p
		seg[p += n] = val; for (p /= 2; p; p /= 2) pull(p); }
	T query(int l, int r) {	// sum on interval [l, r]
		T ra = ID, rb = ID;
		for (l += n, r += n+1; l < r; l /= 2, r /= 2) {
			if (l&1) ra = comb(ra,seg[l++]);
			if (r&1) rb = comb(seg[--r],rb);
		}
		return comb(ra,rb);
	}
};

int main(){
	setIO();
	int n, q;
	cin >> n >> q;
	vl A(n);
	F0R(a, n)
		cin >> A[a];
	vl W(n);
	F0R(a, n)
		cin >> W[a];
	Seg<ll> s;
	Seg2<ll> wi, wai;
	s.init(262144), wi.init(262144), wai.init(262144);
	F0R(a, n)
		s.upd(a, W[a]), wi.upd(a, (W[a] * a) % MOD), wai.upd(a, (W[a] * A[a]) % MOD);
	F0R(a, q){
		int X, Y;
		cin >> X >> Y;
		if(X < 0){
			X = -X;
			X--;
			s.upd(X, Y), wi.upd(X, ((ll)Y * X) % MOD), wai.upd(X, ((ll)Y * A[X]) % MOD);
		}
		else{
			X--, Y--;
			ll SUM = s.query(X, Y) / 2;
			if(X)
				SUM += s.query(0, X - 1);
			int idx = s.search(SUM);
			ll ans = 0;
			if(idx > X){
				ll temp = (s.query(X, idx - 1)) % MOD;
				ans = (ans + (temp * A[idx]) % MOD) % MOD;
				ans = (ans - wai.query(X, idx - 1) + MOD) % MOD;
				ans = (ans - (temp * idx) % MOD + MOD) % MOD;
				ans = (ans + wi.query(X, idx - 1)) % MOD;
			}
			if(idx < Y){
				ll temp = (s.query(idx + 1, Y)) % MOD;
				ans = (ans - (temp * A[idx]) % MOD + MOD) % MOD;
				ans = (ans + wai.query(idx + 1, Y)) % MOD;
				ans = (ans + (temp * idx) % MOD) % MOD;
				ans = (ans - wi.query(idx + 1, Y) + MOD) % MOD;
			}
			cout << ans << endl;
		}
	}
	// you should actually read the stuff at the bottom
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* DON'T GET STUCK ON ONE APPROACH
*/

#include<bits/stdc++.h>

using namespace std;

#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
typedef long long li;

const int MOD = int(1e9) + 7;

int norm(int a) {
	if(a >= MOD)
		a -= MOD;
	if(a < 0)
		a += MOD;
	return a;
}

int norm(const li &a) {
	return norm(int(a % MOD));
}

int mul(int a, int b) {
	return int((a * 1ll * b) % MOD);
}

const int N = 200 * 1000 + 555;

int n, q;
int a[N], w[N];

inline bool read() {
	if(!(cin >> n >> q))
		return false;
	fore(i, 0, n)
		assert(scanf("%d", &a[i]) == 1);
	fore(i, 0, n)
		assert(scanf("%d", &w[i]) == 1);
	return true;
}

li fW[N], fAW[N];

void inc(li f[N], int pos, li val) {
	for(; pos < N; pos |= pos + 1)
		f[pos] += val;
}

li sum(li f[N], int pos) {
	li ans = 0;
	for(; pos >= 0; pos = (pos & (pos + 1)) - 1)
		ans += f[pos];
	return ans;
}

li getSum(li f[N], int l, int r) {
	return sum(f, r - 1) - sum(f, l - 1);
}

int getNSum(li f[N], int l, int r) {
	return norm(sum(f, r - 1) - sum(f, l - 1));
}

inline void solve() {
	fore(i, 0, n) {
		a[i] -= i;
		inc(fW, i, w[i]);
		inc(fAW, i, mul(a[i], w[i]));
	}

	fore(_, 0, q) {
		int x, y;
		assert(scanf("%d%d", &x, &y) == 2);
		if(x < 0) {
			x = -x - 1;
			inc(fW, x, -w[x]);
			inc(fAW, x, -mul(a[x], w[x]));

			w[x] = y;
			inc(fW, x, w[x]);
			inc(fAW, x, mul(a[x], w[x]));
		} else {
			x--;
			li sum = getSum(fW, x, y);

			int lf = x, rg = y;
			while(rg - lf > 1) {
				int mid = (lf + rg) >> 1;
				if(2 * getSum(fW, x, mid) > sum)
					rg = mid;
				else
					lf = mid;
			}
			assert(x <= lf && lf < y);

			int ans = norm(mul(a[lf], getNSum(fW, x, lf)) - getNSum(fAW, x, lf));
			ans = norm(ans + norm(getNSum(fAW, lf, y) - mul(a[lf], getNSum(fW, lf, y))) );
			printf("%d\n", ans);
		}
	}
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	int tt = clock();
#endif
	cout << fixed << setprecision(15);

	if(read()) {
		solve();

#ifdef _DEBUG
		cerr << "TIME = " << clock() - tt << endl;
		tt = clock();
#endif
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

#define IO ios::sync_with_stdio(false);cin.tie(0)
#define _rep(i,a,b) for(int i = (a);i<=(b);++i)
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _dep(i,a,b) for(int i = (a);i>=(b);--i)
#define pb push_back
#define fr first
#define sc second
#define all(x) (x).begin(),(x).end()

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;
typedef vector<LL> vl;

const int maxn = 200050;
const LL mod = 1e9+7;

// So,A tricky and beautiful data structure problem,I have closen myself
// for almost 2 hours beacuse I leak a important detail---the moved boxes'
// position should be distinct,FUCK....I even think the tutorial is wrong
// and silly proof,emm...I am a fucking silly boy...
// Now let's have a look at the problem
// Firstly,we can prove there should be at least a unmoved box in
// among the r-l+1 boxes,if all is moved denotes S1 is the left cost and the S2 is the right
// cost, and we can move the "interval" left or right to replace max(S1,S2) with min(S1,S2) until some
// box(es) should be unmoved to form the interval,you can draw a picture to have a look at the condition

// And next,We can prove the unmoved element should statisfy the fact that (let's denote that box's index is k and
// make f(l,r):=w[l]+w[l+1]....+w[r] ) S(l,k-1)<=S(l,r)/2 && S(l,k)>S(l,r)/2
// IF NOT?
// 1--S(l,k-1)>S(l,r)/2 : [l...{...k...}...r] and we denote that the condition is the best ans But we can find
// a new unmoved box---o (it doesn't matter whether it is the a[k-1]) which is left than k exactly bu 1 and
// the cost won't increase so if the k is the best unmoved one the o must not inferior to k
// get contradiction with the fact--k is the best unmoved box,and if S(l,k) still < S(l,r)/2 we can
// let o be the exactly right one also get a contradiction!!!So,now the problem is simply,maintain the
// w[] with Bitree or the Segtree and binary search the k,you can easily get the formular of the unmoved
// k is knowed (TIPS: make relative position between a[i] and i),SO orz...When can I come up with so beautiful
// constructive strategy....

inline int lowbit(int x){return x&(-x);}

LL pos[maxn];
LL we[maxn];
LL val[maxn][3];
LL sum[maxn][3];
// 0--is the sum_w
// 1--is the sum_w[i]*pos[i]
// 2--is the sum_w[i]*i
int n;
int k;
void modify(int p,LL v)
{
	LL vv = v+mod;
	vv = vv%mod;
	for(int i=p;i<=n;i+=lowbit(i))
	{
		_for(j,1,3)
			sum[i][j]=(sum[i][j]+vv*val[p][j])%mod,sum[i][j]+=mod,sum[i][j]%=mod;
		sum[i][0]+=v;
	}
}

LL Aid(int x,int id)
{
	LL ans = 0;
	for(int i = x;i;i-=lowbit(i))
	{
		ans+=sum[i][id];
		if(id)ans%=mod;
	}
	return ans;
}

inline LL qury(int l,int r,int id=0)
{
	if(r<l)return 0LL;
	LL ans = Aid(r,id)-Aid(l-1,id);
	if(id) ans+=mod,ans%=mod;
	return ans;
}

inline void getK(int l,int r)
{
	LL qq = qury(l,r);
	const LL ha = qq/2+qq%2;
	int nl = l;
	while(l<r)
	{
		int mid = r-(r-l+1)/2;
		if(ha<=qury(nl,mid)) r = mid;
		else l = mid+1;
	}
	k = r;
	//cout<<k<<"-----------\n\n";
}

int main(void)
{
	IO;
	int q;
	cin>>n>>q;
	_rep(i,1,n) cin>>pos[i];
	_rep(i,1,n) cin>>we[i],val[i][0] = 1,val[i][1] = pos[i],val[i][2] = i,modify(i,we[i]);
	//cout<<qury(3,3)<<endl;
	while(q--)
	{
		int l,r;
		cin>>l>>r;
		//cout<<l<<" "<<r<<endl;
		if(l<0)
		{

			l = -l;
			modify(l,-we[l]),modify(l,r);
			we[l] = r;
		}
		else
		{
			getK(l,r);
			LL ans1,ans2,ans3;
			ans1 = ans2 = ans3 = 0LL;
			ans1 += qury(l,k-1),ans1-=qury(k+1,r),ans1 = (ans1+mod)%mod,ans1 = ans1*(pos[k]-k)%mod;
			ans2 -=qury(l,k-1,1),ans2+=qury(k+1,r,1),ans2+=mod,ans2%=mod;
			ans3 +=qury(l,k-1,2),ans3-=qury(k+1,r,2),ans3+=mod,ans3%=mod;
			cout<<(ans1+ans2+ans3)%mod<<endl;
		}
	}
	return 0;
}

#include<iostream>
#include<vector>
#include<cstring>
#include<map>
#include<string>
#include<algorithm>
#include<cstdio>

using namespace std;
typedef long long LL;
const int maxn=2e5+5;
const int mod=1e9+7;

int n,l,r;
LL S[maxn<<1],wp[maxn<<1],owp[maxn],os[maxn],ps[maxn];
LL add(LL a,LL b)
{
    if(a+b>mod)return a+b-mod;
    else return a+b;
}
int lowbit(int x){return x&(-x);}
void change1(int p,int x)
{
    while(p<=n)
    {
        S[p]+=x;
        p+=lowbit(p);
    }
}

void change2(int p,int x)
{
    while(p<=n)
    {
        wp[p]=add(x,wp[p]);
        p+=lowbit(p);
    }
}

LL ssum(int k)
{
    LL ans=0;
    while(k>0)
    {
        ans+=S[k];
        k-=lowbit(k);
    }
    //if(ans>mod)
        //return ans%mod;
    //else
        return ans;//error3
}

int wpsum(int k)//LL error3
{
    LL ans=0;
    while(k>0)
    {
        ans=add(ans,wp[k]);
        k-=lowbit(k);
    }
    if(ans>mod||ans<-mod)
        return ans%mod;
    else
        return ans;
}

LL ask(int l,int r,int op)
{
    if(op==1)
        return ssum(r)-ssum(l-1);//with error3
    else
        return wpsum(r)-wpsum(l-1);//with error4
}

int findk(int l,int r)
{
    int L=l,R=r,mid;
    double al=1.0*(ask(l,r,1))/2;
    while(L<R)
    {
        mid=(L+R)>>1;
        if(ask(l,mid,1)>=al)
            R=mid;
        else
            L=mid+1;
    }
    return L;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int q,a,b,pos;
    LL nw,n1,n2;
    scanf("%d%d",&n,&q);
    for (int i=1;i<=n;i++)
        scanf("%lld",&ps[i]);
    for (int i=1;i<=n;i++)
    {
        scanf("%lld",&os[i]);
        owp[i]=(ps[i]-i)*os[i];
        //cout<<i<<" -- "<<owp[i]<<endl;
        if(owp[i]>mod)
            owp[i]%=mod;
        change1(i,os[i]);
        change2(i,owp[i]);
    }
    //cout<<"test    "<<ask(3,4,1)<<" "<<ssum(1)<<" "<<ssum(2)<<endl;
    while(q--)
    {
        scanf("%d%d",&a,&b);
        if(a<0)
        {
            pos=-a,nw=b;
            n1=nw-os[pos],n2=(nw*(ps[pos]-pos)-owp[pos])%mod;
            os[pos]=b;
            owp[pos]=nw*(ps[pos]-pos);//error2
            change1(pos,n1);
            change2(pos,n2);
        }
        else
        {
            int k=findk(a,b);
            l=a,r=b;//error1
            //cout<<"k   "<<k<<endl;
            //cout<<ask(l,k,1)<<" "<<k<<" "<<r<<" "<<ask(k,r,1)<<" "<<(ps[k]-k)<<" "<<ask(l,k,2)<<" "<<ask(k,r,2)<<endl;
            LL ans=((ask(l,k,1)-ask(k,r,1))*(ps[k]-k)-(ask(l,k,2)-ask(k,r,2)))%mod;
            printf("%lld\n",(ans%mod+mod)%mod);
        }
    }
    return 0;
}
/*
10 10
4 6 8 9 10 14 16 21 27 30
24 27 3 14 3 24 6 12 15 28
-4 6
4 10
-2 30
-9 25
1 8
1 3
2 9
-3 16
-2 24
1 10
*/

#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> PII;
#define fi first
#define se second
#define MP make_pair

int read()
{
    int v = 0, f = 1;
    char c = getchar();
    while (c < 48 || 57 < c) {if (c == '-') f = -1; c = getchar();}
    while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
    return v * f;
}

const int N = 201000;
const ll MOD = 1e9 + 7;
int n, q;
ll t1[N << 2], t2[N << 2], a[N], t, w[N];

void modify(int u, int l, int r, int p, ll v)
{
    if (l == r)
    {
        t1[u] = v;
        t2[u] = v * (a[p] - p) % MOD;
        return ;
    }
    int mid = l + r >> 1;
    if (p <= mid)
        modify(u << 1, l, mid, p, v);
    else
        modify(u << 1 | 1, mid + 1, r, p, v);
    t1[u] = t1[u << 1] + t1[u << 1 | 1];
    t2[u] = (t2[u << 1] + t2[u << 1 | 1]) % MOD;
}

ll query(int u, int l, int r, int L, int R)
{
    if (L > R) return 0;
    if (L <= l && r <= R)
        return t1[u];
    int mid = l + r >> 1;
    ll re = 0;
    if (L <= mid)
        re += query(u << 1, l, mid, L, R);
    if (mid < R)
        re += query(u << 1 | 1, mid + 1, r, L, R);
    return re;
}

ll query2(int u, int l, int r, int L, int R)
{
    if (L > R) return 0;
    if (L <= l && r <= R)
        return t2[u];
    int mid = l + r >> 1;
    ll re = 0;
    if (L <= mid)
        re += query2(u << 1, l, mid, L, R);
    if (mid < R)
        re += query2(u << 1 | 1, mid + 1, r, L, R);
    return re % MOD;
}

int find2(int u, int l, int r)
{
    if (l == r)
        return l;
    int mid = l + r >> 1;
    if (t - t1[u << 1] > 0)
    {
        t -= t1[u << 1];
        return find2(u << 1 | 1, mid + 1, r);
    } else
    {
        return find2(u << 1, l, mid);
    }
}

int find(int u, int l, int r, int L, int R)
{
    if (L <= l && r <= R)
    {
        if (t - t1[u] > 0)
            t -= t1[u];
        else
            return find2(u, l, r);
        return 0;
    }
    int mid = l + r >> 1;
    if (L <= mid)
    {
        int tmp = find(u << 1, l, mid, L, R);
        if (tmp) return tmp;
    }
    if (mid < R)
    {
        int tmp = find(u << 1 | 1, mid + 1, r, L, R);
        if (tmp) return tmp;
    }
}

int main()
{
    n = read(), q = read();
    for (int i = 1; i <= n; i++) a[i] = read();
    for (int i = 1; i <= n; i++) w[i] = read();
    for (int i = 1; i <= n; i++)
        modify(1, 1, n, i, w[i]);
    while (q--)
    {
        int u = read(), v = read();
        if (u < 0)
        {
            u = -u;
            modify(1, 1, n, u, v);
        } else
        {
            t = query(1, 1, n, u, v);
            t = (t + 1) / 2;
            int p = find(1, 1, n, u, v);
            ll x = (a[p] - p) % MOD;
            printf("%lld\n", (query(1, 1, n, u, p) % MOD * x % MOD - query2(1, 1, n, u, p) - query(1, 1, n, p + 1, v) % MOD * x % MOD + query2(1, 1, n, p + 1, v) + MOD + MOD) % MOD);
        }
    }
}

#include<iostream>
#include<vector>
#include<cstring>
#include<map>
#include<string>
#include<algorithm>
#include<cstdio>

using namespace std;
typedef long long LL;
const int maxn=2e5+5;
const int mod=1e9+7;

int n,l,r;
LL S[maxn<<1],wp[maxn<<1],owp[maxn],os[maxn],ps[maxn];
LL add(LL a,LL b)
{
    if(a+b>mod)return a+b-mod;
    else return a+b;
}
int lowbit(int x){return x&(-x);}
void change1(int p,int x)
{
    while(p<=n)
    {
        S[p]+=x;
        p+=lowbit(p);
    }
}

void change2(int p,int x)
{
    while(p<=n)
    {
        wp[p]=add(x,wp[p]);
        p+=lowbit(p);
    }
}

LL ssum(int k)
{
    LL ans=0;
    while(k>0)
    {
        ans+=S[k];
        k-=lowbit(k);
    }
    //if(ans>mod)
        //return ans%mod;
    //else
        return ans;//error3
}

LL wpsum(int k)
{
    LL ans=0;
    while(k>0)
    {
        ans=add(ans,wp[k]);
        k-=lowbit(k);
    }
    if(ans>mod)
        return ans%mod;
    else
        return ans;
}

LL ask(int l,int r,int op)
{
    if(op==1)
        return ssum(r)-ssum(l-1);//with error3
    else
        return wpsum(r)-wpsum(l-1);
}

int findk(int l,int r)
{
    int L=l,R=r,mid;
    double al=1.0*(ask(l,r,1))/2;
    while(L<R)
    {
        mid=(L+R)>>1;
        if(ask(l,mid,1)>=al)
            R=mid;
        else
            L=mid+1;
    }
    return L;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int q,a,b,pos;
    LL nw,n1,n2;
    scanf("%d%d",&n,&q);
    for (int i=1;i<=n;i++)
        scanf("%lld",&ps[i]);
    for (int i=1;i<=n;i++)
    {
        scanf("%lld",&os[i]);
        owp[i]=(ps[i]-i)*os[i];
        //cout<<i<<" -- "<<owp[i]<<endl;
        if(owp[i]>mod)
            owp[i]%=mod;
        change1(i,os[i]);
        change2(i,owp[i]);
    }
    //cout<<"test    "<<ask(3,4,1)<<" "<<ssum(1)<<" "<<ssum(2)<<endl;
    while(q--)
    {
        scanf("%d%d",&a,&b);
        if(a<0)
        {
            pos=-a,nw=b;
            n1=nw-os[pos],n2=(nw*(ps[pos]-pos)-owp[pos])%mod;
            os[pos]=b;
            owp[pos]=nw*(ps[pos]-pos);//error2
            change1(pos,n1);
            change2(pos,n2);
        }
        else
        {
            int k=findk(a,b);
            l=a,r=b;//error1
            //cout<<"k   "<<k<<endl;
            //cout<<ask(l,k,1)<<" "<<k<<" "<<r<<" "<<ask(k,r,1)<<" "<<(ps[k]-k)<<" "<<ask(l,k,2)<<" "<<ask(k,r,2)<<endl;
            LL ans=((ask(l,k,1)-ask(k,r,1))*(ps[k]-k)-(ask(l,k,2)-ask(k,r,2)))%mod;
            printf("%lld\n",(ans%mod+mod)%mod);
        }
    }
    return 0;
}
/*
10 10
4 6 8 9 10 14 16 21 27 30
24 27 3 14 3 24 6 12 15 28
-4 6
4 10
-2 30
-9 25
1 8
1 3
2 9
-3 16
-2 24
1 10
*/

#include <iostream>
#include <fstream>
#include <algorithm>
#include <chrono>
#include <random>
#include <vector>
#include <string>
#include <cmath>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cassert>

#define sq(x) ((x) * (x))
#define err(x) cerr << "["#x"]  " << (x) << "\n";
#define errp(x) cerr << "["#x"]  {" << ((x).first) << ", " << ((x).second) << "}\n";
#define errv(x) {cerr << "["#x"]  [";for(const auto& ___ : (x)) cerr << ___ << ", "; cerr << "]\n";}
#define errvn(x, n) {cerr << "["#x"]  [";for(auto ___ = 0; ___ < (n); ++___) cerr << (x)[___] << ", "; cerr << "]\n";}
#define errf() cerr << "\n\n";

#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast, unroll-loops", "omit-frame-pointer","inline")
//#pragma GCC option("arch=native","tune=native","no-zero-upper")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2")

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getrnd(int l, int r) {
    return uniform_int_distribution<int>(l, r)(rng);
}

template <typename T1, typename T2>
bool relax(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

template <typename T1, typename T2>
bool strain(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

// :::::::::::::::::::::::::::::::

const int MOD = 1e9 + 7;

int add(int a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
    if (a < 0) a += MOD;
    return a;
}

int mul(int a, int b) {
    return 1LL * a * b % MOD;
}

const int N = 2e5 + 3;

int n;
ll tree[4 * N], mtree[4 * N];

void build(int v, int tl, int tr, vector<ll>& a, vector<ll>& b) {
    if (tl == tr) {
        tree[v] = a[tl];
        mtree[v] = mul(a[tl], b[tl]);
    }
    else {
        int tm = (tl + tr) / 2;
        build(2 * v, tl, tm, a, b);
        build(2 * v + 1, tm + 1, tr, a, b);

        tree[v] = tree[2 * v] + tree[2 * v + 1];
        mtree[v] = add(mtree[2 * v], mtree[2 * v + 1]);
    }
}

void update(int v, int tl, int tr, int pos, ll x, vector<ll>& b) {
    if (tl == tr) {
        tree[v] = x;
        mtree[v] = mul(b[tl], x);
    }
    else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(2 * v, tl, tm, pos, x, b);
        else
            update(2 * v + 1, tm + 1, tr, pos, x, b);

        tree[v] = tree[2 * v] + tree[2 * v + 1];
        mtree[v] = add(mtree[2 * v], mtree[2 * v + 1]);
    }
}

ll get(int v, int tl, int tr, int l, int r) {
    if (l > r) return 0;
    if (tl == l && tr == r)
        return tree[v];
    else {
        int tm = (tl + tr) / 2;
        return get(2 * v, tl, tm, l, min(r, tm)) + get(2 * v + 1, tm + 1, tr, max(l, tm + 1), r);
    }
}

ll getm(int v, int tl, int tr, int l, int r) {
    if (l > r) return 0;
    if (tl == l && tr == r)
        return mtree[v];
    else {
        int tm = (tl + tr) / 2;
        return add(getm(2 * v, tl, tm, l, min(r, tm)), getm(2 * v + 1, tm + 1, tr, max(tm + 1, l), r));
    }
}

int find(int v, int tl, int tr, int l, int r, ll x) {
    if (l > r) return -1;
    if (tl == tr)
        return tl;
    else {
        int tm = (tl + tr) / 2;
        ll s = get(1, 0, n - 1, l, tm);
        if (s >= x)
            return find(2 * v, tl, tm, l, min(r, tm), x);
        else
            return find(2 * v + 1, tm + 1, tr, max(tm + 1, l), r, x - s);
    }
}

void solve() {
    int q;
    cin >> n >> q;

    vector<ll> a(n), w(n), y(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i], y[i] = add(a[i], -i);
    for (int i = 0; i < n; ++i)
        cin >> w[i];

    build(1, 0, n - 1, w, y);
//    errv(y);
    while (q--) {
        int l, r;
        cin >> l >> r;

        if (l < 0) {
            update(1, 0, n - 1, -l - 1, r, y);
        }
        else {
            --l; --r;
            ll s = get(1, 0, n - 1, l, r);
            int pos = find(1, 0, n - 1, l, r, (s + 1) / 2);
            assert(pos != -1);
//            err(pos);

            ll x = y[pos];
//            err(x);

//            ll res = add(-sum(l, pos - 1), sum(pos + 1, r));
//            res = add(res, mul(add(sumw(l, pos - 1), -sumw(pos + 1, r)), x));
            ll res = add(-getm(1, 0, n - 1, l, pos - 1), getm(1, 0, n - 1, pos + 1, r));
            res = add(res, mul(add(get(1, 0, n - 1, l, pos - 1) % MOD, -(get(1, 0, n - 1, pos + 1, r) % MOD)), x));
            cout << res << '\n';
        }
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    srand(time(0));

    int t = 1;
//    cin >> t;
    while (t--)
        solve();

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

template<typename T>
struct Segtree {
    int n;
    T e;
    vector<T> dat;
    function<T(T a, T b)> f;

    Segtree(int n_input, function<T(T a, T b)> func, T e_input):f(func), e(e_input){
        n = 1;
        while(n < n_input)n <<= 1;
        dat.resize(2*n-1);
        for(int i = 0; i<2*n-1; i++) dat[i] = e;
    }

    void update(int k, T a){
        k += n - 1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1)/2;
            dat[k] = f(dat[2*k+1], dat[2*k+2]);
        }
    }

    T between(int a, int b){
        return query(a, b+1, 0, 0, n);
    }

    T query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l)return e;
        if(a<=l && r<=b)return dat[k];
        long long vl = query(a, b, 2*k+1, l, (l+r)/2);
        long long vr = query(a, b, 2*k+2, (l+r)/2, r);
        return f(vl, vr);
    }
};

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b+MOD) % MOD;
}

int main(){
    int64_t i, j, k;
    const int MAX = 200000;
    int64_t N, Q, A[MAX], W[MAX];
    cin >> N >> Q;
    for(i=0; i<N; i++) scanf("%lld", &A[i]);
    for(i=0; i<N; i++) scanf("%lld", &W[i]);
    Segtree<int64_t> st(N, [](int64_t a, int64_t b){return a+b;}, 0);
    Segtree<int64_t> stdist(N, [](int64_t a, int64_t b){return (a+b) % MOD;}, 0);

    for(i=0; i<N; i++){
        st.update(i, W[i]);
        stdist.update(i, (A[i]-i) * W[i] % MOD);
    }

    for(int q=0; q<Q; q++){
        int64_t x, y;
        scanf("%lld %lld", &x, &y);
        if(x < 0){
            i = -x-1;
            W[i] = y;
            st.update(i, W[i]);
            stdist.update(i, (A[i]-i) * W[i] % MOD);
        }else{
            int l = x-1, r = y-1;
            int lb = l-1, ub = r;
            int64_t s = st.between(l, r);
            while(ub-lb>1){
                int mid = (ub+lb)/2;
                int64_t s1 = st.between(l, mid);
                (2*s1<=s ? lb : ub) = mid;
            }
            int64_t ans = 0, sr = st.between(ub, r);
            add(ans, stdist.between(ub, r));
            add(ans, -sr % MOD * (A[ub]-ub) % MOD);
            if(l <= lb){
                add(ans, -stdist.between(l, lb));
                add(ans, (s-sr) % MOD * (A[ub]-1-lb) % MOD);
            }
            printf("%lld\n", ans);
        }
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
#define SZ(a) ((int)a.size())
typedef long long ll;

void add (ll &a, ll b) {
	a += b;
	if (a > MOD) a -= MOD;
}

int N, Q, a[200200];
ll w[200200];

struct modtree {
	ll t[200200];
	void u (int i, ll v) {
		i++;
		v %= MOD;
		for (; i <= N; i += (i&-i)) add(t[i], v);
	}

	ll gtv (int i) {
		i++;
		ll res = 0;
		for (; i > 0; i -= (i&-i)) add(res, t[i]);
		return res;
	}

	ll q (int l, int r) {
		// inclusive inclusive query
		// coud make faster
		return (gtv(r) - gtv(l-1) + MOD) % MOD;
	}
} awt, wit;

struct tree {
	//NO MODS
	ll t[200200];
	void u (int i, ll v) {
		i++;
		for (; i <= N; i += (i&-i)) t[i] += v;
	}

	ll gtv (int i) {
		i++;
		ll res = 0;
		for (; i > 0; i -= (i&-i)) res += t[i];
		return res;
	}

	ll q (int l, int r) {
		// inclusive inclusive query
		// coud make faster
		return gtv(r) - gtv(l-1);
	}
} wt;

ll dif (int l, int r, int s) {
	if (l > r) return 0ll;
	// moving boxes [l,r] to [s+l,s+r-l]
	// add up wi of s+l, s+r-l
	ll wi_tot = wit.q(l, r);
	// careful as wt does not mod
	ll wt_tot = wt.q(l, r) % MOD;
	wi_tot = (wi_tot + wt_tot * s) % MOD;
	// subtract aw
	ll aw_tot = awt.q(l, r);
	// printf("dif %d %d %d is %lld, wi_tot is %lld and aw_tot is %lld\n", l, r, s, (wi_tot - aw_tot + MOD) % MOD, wi_tot, aw_tot);
	return (wi_tot - aw_tot + MOD) % MOD;
}

ll delta (int l, int r, int s) {
	// this should return the delta to s+1
	// it is sum of weights of left - sum of weights of right
	int lo = l, hi = r, split = l-1;
	while (lo <= hi) {
		int mid = (lo + hi) / 2;
		if (a[mid] <= s+mid) lo = mid+1, split = mid;
		else hi = mid-1;
	}

	// printf("bin search split %d\n", split);
	// printf("%lld %lld\n", wt.q(l,split), wt.q(split+1, r));
	// printf("%d %d %d asking\n", l, split, r);

	ll d = 0;
	if (l <= split) d += wt.q(l, split);
	if (split+1 <= r) d -= wt.q(split+1, r);
	return d;
}

ll dis (int l, int r, int s) {
	// go from s to s+r-l inclusive
	// need to find max position where it is still moved to right
	// this happens from s to s+1 up to s+r-l-1 to s+r-l
	int lo = l, hi = r, split = l-1;
	while (lo <= hi) {
		int mid = (lo + hi) / 2;
		if (a[mid] <= s+mid) lo = mid+1, split = mid;
		else hi = mid-1;
	}

	ll lft = dif(l, split, s);
	ll rgt = dif(split+1, r, s);

	// printf("%lld %lld\n", lft, rgt);

	return (lft - rgt + MOD) % MOD;
}

int main () {
	scanf("%d %d", &N, &Q);
	fo(i, 0, N) scanf("%d", &a[i]);
	fo(i, 0, N) {
		scanf("%lld", &w[i]);
		wt.u(i, w[i]);
		awt.u(i, w[i] * a[i] % MOD);
		wit.u(i, w[i] * i % MOD);
	}

	fo(i, 0, Q) {
		int x, y; scanf("%d %d", &x, &y);
		if (x < 0) {
			x = -x-1;

			//NO MODS!!!
			wt.u(x, y - w[x]);

			ll dif = ((ll) y - w[x] + MOD) % MOD;
			w[x] = (ll) y;
			awt.u(x, dif * a[x] % MOD);
			wit.u(x, dif * x % MOD);
		} else {
			x--, y--;
			// printf("query %d %d\n", x, y);
			int lo = 1, hi = (int) 1e9, ans = -1;
			while (lo <= hi) {
				int mid = (lo + hi) / 2;
				ll res = delta(x, y, mid);
				// printf("mid %d res %lld\n", mid, res);
				if (res >= 0) {
					hi = mid-1;
					ans = mid;
				} else lo = mid+1;
			}

			// printf("ans %d\n", ans);

			ll u = dis(x, y, ans);
			printf("%lld\n", u);
		}
	}
	return 0;
}

#include <cstdio>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);++i)
#define FORE(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
typedef long long ll;

const int N = 200100, B=1<<18, MOD = 1000000007;
int n,q,a[N],w[N];

int BASE;
ll tree[2*B];
ll treeW[2*B];

void set(int x, int val, int a) {
  tree[x += BASE] = val;
  treeW[x] = ll(val) * a % MOD;
  while (x > 1) {
    x /= 2;
    tree[x] = tree[2*x] + tree[2*x+1];
    treeW[x] = (treeW[2*x] + treeW[2*x+1]) % MOD;
  }
}

ll query(int x) {
  if (x==0) return 0;
  --x;
  ll ans = tree[x += BASE];
  while (x > 1) {
    if (x & 1) ans += tree[x-1];
    x /= 2;
  }
  return ans;
}

ll queryW(int x) {
  if (x==0) return 0;
  --x;
  ll ans = treeW[x += BASE];
  while (x > 1) {
    if (x & 1) ans = (ans + treeW[x-1]) % MOD;
    x /= 2;
  }
  return ans;
}

int find(ll sum) {
  int x = 1;
  while (x < BASE) {
    if (tree[2*x] > sum) { x = 2*x; }
    else { sum -= tree[2*x]; x = 2*x+1; }
  }
  return x - BASE;
}

int main() {
  scanf("%d%d",&n,&q);

  BASE=1; while (BASE < n) { BASE *= 2; }

  REP(i,n) { scanf("%d",&a[i]); a[i] -= i; }
  REP(i,n) { scanf("%d",&w[i]); set(i, w[i], a[i]); }
  REP(i,q) {
    int x,y; scanf("%d%d",&x,&y);
    if (x < 0) {
      w[-x-1] = y; set(-x-1, y, a[-x-1]);
    } else {
      --x;
      ll sum = 0, sum2 = 0;
//      for(int j=x;j<y;++j) sum += w[j];
      sum = query(y) - query(x);
//      int xy;

//      for(xy=x; xy<y; ++xy) {
//        sum2 += w[xy];
//        if (sum2*2 > sum) break;
//      }

      ll needed = query(x) + sum/2;
      int xy = find(needed);

      ll cost = 0;
//      for(int j=x;j<y;++j) {
//        cost = (cost + ll(w[j]) * abs(a[j] - a[xy])) % MOD;
//      }

//      for(int j=x;j<xy;++j) cost = (cost + w[j] * (a[xy] - a[j])) % MOD;
//      for(int j=xy;j<y;++j) cost = (cost + w[j] * (a[j] - a[xy])) % MOD;

      cost = (cost + queryW(y) + MOD - queryW(xy) + MOD - (query(y) - query(xy)) % MOD * a[xy] % MOD) % MOD;
      cost = (cost + (query(xy) - query(x)) % MOD * a[xy] % MOD + MOD - queryW(xy) + queryW(x)) % MOD;

      printf("%d\n", (int)cost);
    }
  }
}

#include <bits/stdc++.h>
using namespace std;

const int N = 2e5 + 1;
const int M = 1e9 + 7;

int a[N];
int w[N];

int add(int a, int b) {
  return (a += b) < M ? a : a - M;
}

int sub(int a, int b) {
  return (a -= b) < 0 ? a + M : a;
}

int mul(int a, int b) {
  return 1LL * a * b % M;
}

template <class T>
struct fenwick_tree {

  T tree[N];

  void update(int a, T val) {
    for ( ; a < N; a += a & -a) {
      tree[a] += val;
    }
  }

  T query(int a) {
    T res = 0;
    for ( ; a > 0; a -= a & -a) {
      res += tree[a];
    }
    return res;
  }

  T query(int a, int b) {
    return query(b) - query(a - 1);
  }

};

struct mint {
  int val;

  mint() {}
  mint(int _val) : val(_val) {}

  void operator+=(mint oth) {
    val = add(val, oth.val);
  }

  int operator-(mint oth) {
    return sub(val, oth.val);
  }
};

fenwick_tree<long long> ft_cnt;
fenwick_tree<mint> ft_sum;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, q;
  cin >> n >> q;

  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    a[i] -= i;
  }

  for (int i = 1; i <= n; ++i) {
    cin >> w[i];
    ft_cnt.update(i, w[i]);
    ft_sum.update(i, mul(w[i], a[i]));
  }

  while (q--) {
    int x, y;
    cin >> x >> y;
    if (x < 0) {
      x = -x;
      ft_cnt.update(x, y - w[x]);
      ft_sum.update(x, mul(sub(y, w[x]), a[x]));
      w[x] = y;
    } else {
      long long target = (ft_cnt.query(x, y) + 1) / 2;

      int lo = x;
      int hi = y;
      while (lo <= hi) {
        int mid = (lo + hi) / 2;
        if (ft_cnt.query(x, mid) < target) {
          lo = mid + 1;
        } else {
          hi = mid - 1;
        }
      }

      cout << add(sub(mul(a[lo], ft_cnt.query(x, lo) % M), ft_sum.query(x, lo).val),
          sub(ft_sum.query(lo + 1, y).val, mul(a[lo], ft_cnt.query(lo + 1, y) % M))) << "\n";
    }
  }
}

#include<bits/stdc++.h>
#define LL long long
#define LD long double
#define ull unsigned long long
#define fi first
#define se second
#define mk make_pair
#define PLL pair<LL, LL>
#define PLI pair<LL, int>
#define PII pair<int, int>
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(), (x).end()
#define fio ios::sync_with_stdio(false); cin.tie(0);

using namespace std;

const int N = 2e5 + 7;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-8;
const double PI = acos(-1);

template<class T, class S> inline void add(T& a, S b) {a += b; if(a >= mod) a -= mod;}
template<class T, class S> inline void sub(T& a, S b) {a -= b; if(a < 0) a += mod;}
template<class T, class S> inline bool chkmax(T& a, S b) {return a < b ? a = b, true : false;}
template<class T, class S> inline bool chkmin(T& a, S b) {return a > b ? a = b, true : false;}

int n, q, a[N], w[N];

struct Bit {
    LL a[N];
    void modify(int x, int v) {
        for(int i = x; i <= n; i += i & -i) a[i] += v;
    }
    LL sum(int x) {
        LL ans = 0;
        for(int i = x; i; i -= i & -i) ans += a[i];
        return ans;
    }
    LL query(int L, int R) {
        if(L > R) return 0;
        return sum(R) - sum(L - 1);
    }
} bit;

struct Bit2 {
    int a[N];
    void modify(int x, int v) {
        for(int i = x; i <= n; i += i & -i) add(a[i], v);
    }
    int sum(int x) {
        LL ans = 0;
        for(int i = x; i; i -= i & -i) add(ans, a[i]);
        return ans;
    }
    int query(int L, int R) {
        if(L > R) return 0;
        return (sum(R) - sum(L - 1) + mod) % mod;
    }
} prefix, suffix;

int main() {
    LL ret = 0;
    scanf("%d%d", &n, &q);
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for(int i = 1; i <= n; i++) scanf("%d", &w[i]);
    for(int i = 1; i <= n; i++) {
        bit.modify(i, w[i]);
        prefix.modify(i, 1LL * abs(a[i] - a[1] - i + 1) * w[i] % mod);
    }
    for(int i = n; i >= 1; i--)
        suffix.modify(i, 1LL * abs(a[n] - a[i] - n + i) * w[i] % mod);
    while(q--) {
        int x, y;
        scanf("%d%d", &x, &y);
        if(x < 0) {
            x = -x;
            bit.modify(x, -w[x]);
            prefix.modify(x, mod - (1LL * abs(a[x] - a[1] - x + 1) * w[x] % mod));
            suffix.modify(x, mod - (1LL * abs(a[n] - a[x] - n + x) * w[x] % mod));
            w[x] = y;
            bit.modify(x, w[x]);
            prefix.modify(x, 1LL * abs(a[x] - a[1] - x + 1) * w[x] % mod);
            suffix.modify(x, 1LL * abs(a[n] - a[x] - n + x) * w[x] % mod);
        } else {
            int len = y - x + 1;
            int low = a[x], high = a[y], p = low, low2, high2, p2, fen;
            while(low <= high) {
                int mid = low + high >> 1;
                low2 = x, high2 = y, p2 = y + 1;
                while(low2 <= high2) {
                    int mid2 = low2 + high2 >> 1;
                    if(a[mid2] > mid + mid2 - x) p2 = mid2, high2 = mid2 - 1;
                    else low2 = mid2 + 1;
                }
                LL valL = bit.query(x, p2 - 1);
                LL valR = bit.query(p2, y);
                if(valL > valR) p = mid, high = mid - 1, fen = p2;
                else low = mid + 1;
            }
            LL ans = 0;
            if(fen <= y) {
                add(ans, prefix.query(fen, y));
                sub(ans, bit.query(fen, y) % mod * (p - (a[1] + x - 1)) % mod);
            }
            if(fen - 1 >= x) {
                add(ans, suffix.query(x, fen - 1));
                sub(ans, bit.query(x, fen - 1) % mod * (a[n] - (n - x) - p) % mod);
            }
            printf("%lld\n", ans);
        }
    }
    return 0;
}

/*
*/

/*************************************************************************
    > File Name: C.cpp
    > Author: Roundgod
    > Mail: wcysai@foxmail.com
    > Created Time: 2018-09-23 22:03:04
 ************************************************************************/

#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll n,q,a[MAXN],p[MAXN];
ll _mod(ll x) {return x>=MOD?x-MOD:x;}
struct segtree
{
    ll sum[4*MAXN];
    ll sum2[4*MAXN],sum3[4*MAXN];
    void pushup(ll k)
    {
        sum[k]=sum[k*2]+sum[k*2+1];
        sum2[k]=_mod(sum2[k*2]+sum2[k*2+1]);
        sum3[k]=_mod(sum3[k*2]+sum3[k*2+1]);
    }
    void build(ll k,ll l,ll r)
    {
        if(l==r) {sum[k]=a[l]; sum2[k]=1LL*a[l]*p[l]%MOD; sum3[k]=1LL*l*a[l]%MOD; return;}
        ll mid=(l+r)/2;
        build(k*2,l,mid);build(k*2+1,mid+1,r);
        pushup(k);
    }
    void update(ll k,ll l,ll r,ll pos,ll v)
    {
        if(l==r)
        {
            sum[k]=v;
            sum2[k]=1LL*v*p[l]%MOD;
            sum3[k]=1LL*v*l%MOD;
            return;
        }
        ll mid=(l+r)/2;
        if(pos<=mid) update(k*2,l,mid,pos,v); else update(k*2+1,mid+1,r,pos,v);
        pushup(k);
    }
    ll query1(ll k,ll l,ll r,ll x,ll y)
    {
        if(x>r||l>y) return 0;
        if(l>=x&&r<=y) return sum[k];
        ll mid=(l+r)/2;
        return query1(k*2,l,mid,x,y)+query1(k*2+1,mid+1,r,x,y);
    }
    ll find(ll k,ll l,ll r,ll s)
    {
        if(l==r) return l;
        ll mid=(l+r)/2;
        if(sum[k*2]<=s) return find(k*2+1,mid+1,r,s-sum[k*2]);
        return find(k*2,l,mid,s);
    }
    ll query2(ll k,ll l,ll r,ll x,ll y)
    {
        if(x>r||l>y) return 0;
        if(l>=x&&r<=y) return sum2[k];
        ll mid=(l+r)/2;
        return _mod(query2(k*2,l,mid,x,y)+query2(k*2+1,mid+1,r,x,y));
    }
    ll query3(ll k,ll l,ll r,ll x,ll y)
    {
        if(x>r||l>y) return 0;
        if(l>=x&&r<=y) return sum3[k];
        ll mid=(l+r)/2;
        return _mod(query3(k*2,l,mid,x,y)+query3(k*2+1,mid+1,r,x,y));
    }
}seg;
int main()
{
    scanf("%lld%lld",&n,&q);
    for(ll i=1;i<=n;i++) scanf("%lld",&p[i]);
    for(ll i=1;i<=n;i++) scanf("%lld",&a[i]);
    seg.build(1,1,n);
    ll l,r;
    for(ll i=0;i<q;i++)
    {
        scanf("%lld%lld",&l,&r);
        if(l<0) seg.update(1,1,n,-l,r);
        else
        {
            ll A=seg.query1(1,1,n,1,l-1),B=seg.query1(1,1,n,l,r),s=A+B/2;
            ll pos=seg.find(1,1,n,s);
            ll ans=0;
            ans=(1LL*(p[pos]-pos)*(seg.query1(1,1,n,l,pos-1)%MOD)+seg.query3(1,1,n,l,pos-1)-seg.query2(1,1,n,l,pos-1)+MOD)%MOD;
            ans=(ans+seg.query2(1,1,n,pos+1,r)+1LL*(pos-p[pos])*(seg.query1(1,1,n,pos+1,r)%MOD)%MOD-seg.query3(1,1,n,pos+1,r)+MOD)%MOD;
            if(ans<0) ans+=MOD;
            printf("%lld\n",ans);
        }
    }
    return 0;
}

#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

struct Fenwick{

      vector<int> bit;
      int size;

      void modify(int j, int v){
            j++;
            for(; j < size; j += j & -j)bit[j] += v;
      }

      int query(int j){
            j++;
            int v = 0;
            for(; j > 0; j -= j & -j)v += bit[j];
            return v;
      }

      int rangequery(int a, int b){
      	if(b < a) return 0;
            return query(b) - query(a - 1);
      }

      void rangeupdate(int a, int b, int v){
            modify(a, v);
            modify(b + 1, -v);
      }

      Fenwick(int s){
            s += 3;
            size = s;
            bit = vector<int>(s, 0);
      }

};
struct FenwickM{

      vector<int> bit;
      int size;

      void modify(int j, int v){
      	v %= modulo;
      	v = (v + modulo) % modulo;
            j++;
            for(; j < size; j += j & -j)bit[j] = (bit[j] + v) % modulo;
      }

      int query(int j){
            j++;
            int v = 0;
            for(; j > 0; j -= j & -j)v = (bit[j] + v) % modulo;
            return v;
      }

      int rangequery(int a, int b){
            return (query(b) - query(a - 1) + modulo) % modulo;
      }

      void rangeupdate(int a, int b, int v){
            modify(a, v);
            modify(b + 1, -v);
      }

      FenwickM(int s){
            s += 3;
            size = s;
            bit = vector<int>(s, 0);
      }

};

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

//	freopen("q.gir", "r", stdin);
//	freopen("q.cik", "w", stdout);

	int n, q;
	cin >> n >> q;

	vector<int> X(n + 1);
	vector<int> W(n + 1);
	vector<ii> Q(q);
	vector<int> beg;
	Fenwick pref(200005);
	FenwickM data(200005);

	for(int i = 1; i <= n; i++) cin >> X[i];
	for(int i = 1; i <= n; i++) cin >> W[i];

	beg = W;

	for(int i = 0; i < q; i++){
		cin >> Q[i].first >> Q[i].second;
	}

	for(int i = 1; i <= n; i++){
		pref.modify(i, W[i]);
		data.modify(i, (i - X[i]) * W[i]);
	}

	for(int k = 0; k < q; k++){
		if(Q[k].first < 0){
			int i = -Q[k].first;
			pref.modify(i, Q[k].second - W[i]);
			data.modify(i, -(i - X[i]) * W[i]);
			data.modify(i, (i - X[i]) * Q[k].second);
			W[i] = Q[k].second;
		}
		else{
			int L = Q[k].first, R = Q[k].second;
			int l = L, r = R;
			int med = L - 1;
			if(L == R) {
				cout << "0\n";
				continue;
			}
			while(l <= r){
				int mid = (l + r) / 2;

				if(pref.rangequery(L, mid) <= pref.rangequery(mid + 1, R)){
					med = mid;
					l = mid + 1;
				}
				else r = mid - 1;
			}

			int ans = 0;
			if(med >= L)
			ans = (pref.rangequery(L, med) % modulo * (X[med + 1] - med - 1) % modulo + data.rangequery(L, med)) % modulo;
			med += 2;
			if(med <= R)
			ans = (ans - pref.rangequery(med, R) % modulo * (X[med - 1] - med + 1) % modulo - data.rangequery(med, R)) % modulo;

			cout << (ans % modulo + modulo) % modulo << "\n";

		}
	}

}

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define For(i,j,k)	for(int i=j;i<=k;++i)
#define Dow(i,j,k)	for(int i=k;i>=j;--i)
#define ll long long
#define pb push_back

using namespace std;

inline ll read()
{
	ll t=0,dp=1;char c=getchar();
	while(!isdigit(c))	{if(c=='-')	dp=-1;c=getchar();}
	while(isdigit(c))	t=t*10+c-48,c=getchar();
	return t*dp;
}
inline void write(ll x){if(x<0)	{putchar('-');x=-x;}	if(x>=10)	write(x/10);putchar(x%10+48);}
inline void writeln(ll x){write(x);puts("");}
inline void write_p(ll x){write(x);putchar(' ');}

ll mo=1e9+7;
const int N=200005;
ll n,que,a[N],w[N],tr1[N],tr2[N];
inline ll Ask1(ll x)
{
	ll sum=0;for(;x;x-=x&-x)	sum=(sum+tr1[x]+mo)%mo;
	return sum;
}
inline ll Ask2(ll x)
{
	ll sum=0;for(;x;x-=x&-x)	sum+=tr2[x];
	return sum;
}
inline void Insert1(ll x,ll v){for(;x<=n;x+=x&-x)	tr1[x]=(tr1[x]+v%mo+mo)%mo;}
inline void Insert2(ll x,ll v){for(;x<=n;x+=x&-x)	tr2[x]+=v;}
inline ll Query1(ll l,ll r){return (Ask1(r)-Ask1(l-1)+mo)%mo;}
inline ll Query2(ll l,ll r){return Ask2(r)-Ask2(l-1);}

inline bool check(ll l,ll r,ll mid)
{
	ll t1=Query2(l,mid),t2=Query2(mid+1,r);
	return t1>=t2;
}
int main()
{
	n=read();que=read();
	For(i,1,n)	a[i]=read()-i+1;
	For(i,1,n)	w[i]=read();
	For(i,1,n)	Insert1(i,a[i]*w[i]%mo),Insert2(i,w[i]);
	For(i,1,que)
	{
		ll ql=read(),qr=read();
		if(ql>0)
		{
			ll l=ql,r=qr,ans=r;
			while(l<=r)
			{
				ll mid=l+r>>1;
				if(check(ql,qr,mid))	ans=mid,r=mid-1;else	l=mid+1;
			}
			ll ANS=(Query2(ql,ans)%mo*a[ans]%mo-Query1(ql,ans))%mo;
			ANS+=(-Query2(ans+1,qr)%mo*a[ans]%mo+Query1(ans+1,qr)%mo)%mo;
			ANS=(ANS%mo+mo)%mo;
			writeln(ANS);
		}
		else
		{
			ql=-ql;
			Insert1(ql,a[ql]*(qr-w[ql])%mo);
			Insert2(ql,(qr-w[ql]));
			w[ql]=qr;
		}
	}
}

#define problem "1030F"
#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5 + 11, mol = 1e9 + 7;
typedef long long ll;
typedef int i_N[maxN];
typedef ll l_N[maxN];
int N, Q;
i_N A, W;
l_N sum, fwi, bwi, wa;

void update(int x, int v){
    for(int i = x; i <= N; i |= i + 1) sum[i] += v;
}

ll get_bit(int x){
    ll res = 0;
    for(int i = x; i >= 1; i = (i & (i + 1)) - 1) res += sum[i];
    return res;
}

ll get_bit(int l, int r){
    return get_bit(r) - get_bit(l - 1);
}

void update(ll * bit, int x, int v){
    for(int i = x; i <= N; i |= i + 1) bit[i] = (bit[i] + v) % mol;
}

ll get_bit(ll * bit, int x){
    ll res = 0;
    for(int i = x; i >= 1; i = (i & (i + 1)) - 1) res = (res + bit[i]) % mol;
    return res;
}

ll get_bit(ll * bit, int l, int r){
    return (get_bit(bit, r) - get_bit(bit, l - 1)) % mol;
}

ll cal(int l, int r, int x){
    ll t1 = get_bit(sum, l, x) * A[x] - get_bit(wa, l, x);
    t1 %= mol;
    t1 -= get_bit(bwi, l, x) - get_bit(sum, l, x) * (N - x + 1);
    t1 %= mol;
    if(x < r){
        ll t2 = get_bit(wa, x + 1, r) - get_bit(sum, x + 1, r) * A[x + 1];
        t2 %= mol;
        t2 -= get_bit(fwi, x + 1, r) - get_bit(sum, x + 1, r) * (x + 1);
        t2 %= mol;
        return (t1 + t2 + get_bit(sum, x + 1, r) * (A[x + 1] - A[x] - 1)) % mol;
    }
    return t1;
}

int main(){
    ios_base::sync_with_stdio(0);

    cin >> N >> Q;
    for(int i = 1; i <= N; i++) cin >> A[i];
    for(int i = 1; i <= N; i++) cin >> W[i];
    for(int i = 1; i <= N; i++){
        update(i, W[i]);
        update(fwi, i, ll(i) * W[i] % mol);
        update(bwi, i, ll(N - i + 1) * W[i] % mol);
        update(wa, i, ll(A[i]) * W[i] % mol);
    }
    for(int i = 1; i <= Q; i++){
        int l, r;
        cin >> l >> r;
        if(l < 0){
            l *= -1;
            update(l, -W[l] + r);
            update(fwi, l, ll(l) * (-W[l] + r) % mol);
            update(bwi, l, ll(N - l + 1) * (-W[l] + r) % mol);
            update(wa, l, ll(-W[l] + r) * A[l] % mol);
            W[l] = r;
        }else{
            ll S = get_bit(l, r);
            int a = l, b = r;
            do{
                int mid = (a + b) / 2;
                if(get_bit(l, mid) * 2 >= S) b = mid; else a = mid + 1;
            }while(a < b);
            ll ans = cal(l, r, a);
            if(ans < 0) ans += mol;
            cout << ans << '\n';
        }
    }
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <map>
#include <set>
using namespace std;
#define LL long long
const int N=200005;
const LL mod=1000000007;
int n;
LL a[N],w[N];

//__int128
struct BIT{
    LL b[N];
    int lowbit(int x){return x&-x;}
    void modify(int x,LL val){while (x<=n) b[x]+=val,x+=lowbit(x);}
    LL que(int x){LL ans=0;while (x) ans+=b[x],x-=lowbit(x);return ans;}
    LL query(int l,int r){return que(r)-que(l-1);}
};
BIT B1,B2;
LL qm(LL x){
	if (x<0) x+=((-x)/mod+1)*mod;
	return x%mod;
}
LL cal(int i,int l,int r){
    LL A=a[i]-i;
    LL ans1=B1.query(l,i)*A-B2.query(l,i);
    LL ans2=B2.query(i,r)-B1.query(i,r)*A;
    return qm(ans1+ans2);
}
LL query(int ll,int rr){
    int l=ll-1,r=rr;
    while (r-l>1){
		int mid=((l+r)>>1);
        if (B1.query(ll,mid)<B1.query(mid+1,rr)) l=mid; else r=mid;
    }

	return cal(r,ll,rr);
}
int main(){
 //   freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
    int i,Q;
    cin>>n>>Q;
    for (i=1;i<=n;i++){
        scanf("%lld",&a[i]);
    }
    for (i=1;i<=n;i++){
        scanf("%lld",&w[i]);
        B1.modify(i,w[i]);
        B2.modify(i,w[i]*(mod+a[i]-i)%mod);
    }

    while (Q--){
        int op;scanf("%d",&op);
        if (op<0){
            LL ww;i=-op;
            scanf("%lld",&ww);
            B1.modify(i,ww-w[i]);
            B2.modify(i,(mod+ww-w[i])*(mod+a[i]-i)%mod);
            w[i]=ww;
        } else{
            int l,r;l=op;scanf("%d",&r);
            printf("%lld\n",query(l,r));
        }
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

const int MAXN = 200010;

// Modular operations
const int MOD = 1E9 + 7;

int Add(int a, int b, int m = MOD){
  a += b;
  if(a >= m) a -= m;
  return a;
}

int Sub(int a, int b, int m = MOD){
  a -= b;
  if(a < 0) a += m;
  return a;
}

int AddTo(int& to, int w, int m = MOD){
  to += w;
  if(to >= m) to -= m;
  return to;
}

int SubTo(int& to, int w, int m = MOD){
  to -= w;
  if(to < 0) to += m;
  return to;
}

int Mult(int a, int b, int m = MOD){
  return (a * 1LL * b) % m;
}

// Bit
struct Bit {
  vi sum;

  Bit(){
    sum.resize(MAXN, 0);
  }

  void BitAdd(int pos, int w){
    for(++pos;pos < MAXN;pos += (pos & (-pos)))
      AddTo(sum[pos], w);
  }

  void BitSub(int pos, int w){
    for(++pos;pos < MAXN;pos += (pos & (-pos)))
      SubTo(sum[pos], w);
  }

  int BitGet(int l, int r){
    int res = 0;
    for(++r;r > 0;r -= (r & (-r)))
      AddTo(res, sum[r]);
    for(;l > 0;l -= (l & (-l)))
      SubTo(res, sum[l]);
    return res;
  }
};

struct BitReg {
  vector<ll> sum;

  BitReg(){
    sum.resize(MAXN, 0);
  }

  void BitAdd(int pos, int w){
    for(++pos;pos < MAXN;pos += (pos & (-pos)))
      sum[pos] += w;
  }

  void BitSub(int pos, int w){
    for(++pos;pos < MAXN;pos += (pos & (-pos)))
      sum[pos] -= w;
  }

  ll BitGet(int l, int r){
    ll res = 0;
    for(++r;r > 0;r -= (r & (-r)))
      res += sum[r];
    for(;l > 0;l -= (l & (-l)))
      res -= sum[l];
    return res;
  }
};

// Solution
int n, q;
int a_[MAXN], w_[MAXN];
int a[MAXN], w[MAXN];

Bit lr, rl;
BitReg sumw;

void Update(int i, int na, int nw){
  sumw.BitSub(i, w[i]);
  lr.BitSub(i, Mult(Sub(i, a[i]), w[i]));
  rl.BitSub(i, Mult(Sub(a[i], i), w[i]));

  a[i] = na;
  w[i] = nw;

  sumw.BitAdd(i, w[i]);
  lr.BitAdd(i, Mult(Sub(i, a[i]), w[i]));
  rl.BitAdd(i, Mult(Sub(a[i], i), w[i]));
}

int Eval(int l, int r, int mid, int start){
  int ans = 0;

  if(l <= mid){
    int koef = Sub(start, l);
    AddTo(ans, lr.BitGet(l, mid));
    AddTo(ans, Mult(koef, sumw.BitGet(l, mid) % MOD));
  }

  if(mid + 1 <= r){
    int pos = start + mid + 1 - l;
    int koef = Sub(mid + 1, pos);
    AddTo(ans, rl.BitGet(mid + 1, r));
    AddTo(ans, Mult(koef, sumw.BitGet(mid + 1, r) % MOD));
  }

  return ans;
}

int GetMid(int l, int r, int start){
  if(a[l] > start) return l - 1;
  int lo = l, hi = r, mid;
  for(;;){
    if(lo + 1 >= hi){
      if(a[hi] <= start + hi - l) return hi;
      else return lo;
    }
    mid = (lo + hi) >> 1;
    if(a[mid] <= start + mid - l)
      lo = mid;
    else
      hi = mid;
  }
}

int EvalAtStart(int l, int r, int start){
  int mid = GetMid(l, r, start);
  return Eval(l, r, mid, start);
}

int Solve(int l, int r){
  ll total = sumw.BitGet(l, r);
  int lo = l, hi = r, mid;
  for(;;){
    if(lo + 1 >= hi){
      if(2 * sumw.BitGet(l, lo) >= total) mid = lo;
      else mid = hi;
      break;
    }
    mid = (lo + hi) >> 1;
    if(2 * sumw.BitGet(l, mid) <= total) lo = mid;
    else hi = mid;
  }

  return EvalAtStart(l, r, a[mid] - (mid - l));
}

int main(){
  scanf("%d%d", &n, &q);
  for(int i = 0;i < n;++i) scanf("%d", &a_[i]);
  for(int i = 0;i < n;++i) scanf("%d", &w_[i]);

  for(int i = 0;i < n;++i)
    Update(i, a_[i], w_[i]);

  for(int i = 0;i < q;++i){
    int x, y;
    scanf("%d%d", &x, &y);
    if(x > 0){
      --x, --y;
      printf("%d\n", Solve(x, y));
    } else {
      x = -x - 1;
      Update(x, a[x], y);
    }
  }

  return 0;
}

// Create your own template by modifying this file!
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cassert>
#include <deque>
#include <stack>
#include <functional>
#define X first
#define Y second
#define MAX(x, a) x = max(x, a)
#define MIN(x, a) x = min(x, a)
#define CASET int ___T; scanf("%d ", &___T); while (___T-- > 0)
#define SZ(X) ((int)(X).size())
#define LEN(X) strlen(X)
#define FOR(i,c) for(auto &i: c)
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=(b);i++)
#define REPL(i,x) for(int i=0;x[i];i++)
#define PER(i,n) for(int i=(n)-1;i>=0;i--)
#define PER1(i,a,b) for(int i=(a);i>=(b);i--)
#define RI1(x) scanf("%d",&x)
#define RI2(x,y) RI1(x), RI1(y)
#define RI3(x,y...) RI1(x), RI2(y)
#define RI4(x,y...) RI1(x), RI3(y)
#define RI5(x,y...) RI1(x), RI4(y)
#define RI6(x,y...) RI1(x), RI5(y)
#define GET_MACRO(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define RI(argv...) GET_MACRO(argv, RI6, RI5, RI4, RI3, RI2, RI1)(argv)
#define DRI(argv...) int argv;RI(argv)
#define RS(x) scanf("%s",x)
#define PI(x) printf("%d\n",x)
#define PIS(x) printf("%d ",x)
#define DRL(x) LL x; RL(x)
#ifdef ONLINE_JUDGE
    #define PL(x) printf("%I64d\n",x)
    #define RL(x) scanf("%I64d\n",&x)
#else
    #define PL(x) printf("%lld\n",x)
    #define RL(x) scanf("%lld\n",&x)
#endif
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define BG begin()
#define ED end()
#define PQ priority_queue
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define SEP(x) ((x)?'\n':' ')
#define DRA(A, N) VI A(N); REP(i, N) RI(A[i])
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;
const int INF = 1000000000;
template<typename T>
using V = std::vector<T>;

#ifdef DEBUG
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {
        cerr<<v<<" ";
        return *this;
    }
} dbg;
#define PZ(x) PI((x).i);

template<class Short, class Long>
struct ZZ {
    static Short MOD;
    Short i;
    ZZ():i(0) {}
    ZZ(Short _i): i(_i >= 0 ? _i : _i + MOD) {}
    ZZ(Long _i): i(_i % MOD) {}
    void operator +=(const ZZ& z) { i += z.i; if(i >= MOD) i -= MOD; }
    void operator -=(const ZZ& z) { i -= z.i; if(i < 0) i += MOD; }
    void operator *=(const ZZ& z) { i = (Long) i * z.i % MOD; }
    void operator /=(const ZZ& z) { (*this) *= z.inverse(); }
    ZZ operator +(const ZZ& z) const { ZZ ret(i); ret += z; return ret; }
    ZZ operator -(const ZZ& z) const { ZZ ret(i); ret -= z; return ret; }
    ZZ operator *(const ZZ& z) const { ZZ ret(i); ret *= z; return ret; }
    ZZ operator /(const ZZ& z) const { return (*this) * z.inverse(); }
    // ZZ operator -() const { return ZZ(-i); }
    ZZ inverse() const {
        return pow(MOD - 2);
    }
    ZZ pow(long long b) const {
        ZZ x=Short(1),y=*this;
        while(b > 0){
            if(b%2 == 1)
                x *= y;
            y *= y; // squaring the base
            b /= 2;
        }
        return x;
    }

    static vector<ZZ> factorial, inv_factorial;

    static ZZ fact(int n) {
        while(factorial.size() <= n)
            factorial.push_back(factorial.back() * SZ(factorial));
        return factorial.at(n);
    }

    static ZZ inv_fact(int n) {
        if (n < inv_factorial.size())
            return inv_factorial.at(n);
        int old_size = inv_factorial.size();
        inv_factorial.resize(n+1);
        inv_factorial.at(n) = fact(n).inverse();
        for (int i = n-1; i >= old_size; i--) {
            inv_factorial[i] = inv_factorial.at(i+1) * (i+1);
        }
        return inv_factorial.at(n);
    }

    static ZZ choose0(int n, int k) {
        assert(n < 1e7);
        if(n < k) return 0;
        return fact(n) * (inv_fact(k) * inv_fact(n-k));
    }

    static ZZ choose1(int n, int k) {
        assert(k < 1e7);
        if (n < k) return 0;
        if (k == 0) return 1;
        return choose1(n-1, k-1) * n / k;
    }

    static pair<ZZ,int> factModExp(int n) {
            if (n == 0) return MP(1, 0);
            int e = n / MOD;
            pair<ZZ,int> pr = factModExp(e);
            if (e % 2) {
                    return MP(ZZ(0) - pr.first * fact(n % MOD), pr.second + e);
            } else {
                    return MP(pr.first * fact(n % MOD), pr.second + e);
            }
    }

    static ZZ choose2(int n, int k) {
        assert(MOD < 1e7);
        pair<ZZ,int> p1 = factModExp(n), p2 = factModExp(k), p3 = factModExp(n-k);
        if (p1.second > p2.second + p3.second) return 0;
        assert(p1.second == p2.second + p3.second);
        return p1.first / (p2.first * p3.first);
    }
};

typedef ZZ<int, long long> Z;
template<> int Z::MOD = 1000000007;
template<> vector<Z> Z::factorial(1, 1);
template<> vector<Z> Z::inv_factorial(1, 1);

long long mul(long long a,long long b,long long mod=Z::MOD){
  long long x = 0,y=a%mod;
  while(b > 0){
    if(b%2 == 1){
      x = x+y;
      if(x >= mod) x -= mod;
    }
    y = y*2;
    if(y >= mod) y -= mod;
    b /= 2;
  }
  return x%mod;
}

long long pow(long long a, long long b, long long c=Z::MOD){
  long long x=1,y=a; // ll is taken to avoid overflow of intermediate results
  while(b > 0){
    if(b%2 == 1){
      x=mul(x, y, c);
    }
    y = mul(y, y, c); // squaring the base
    b /= 2;
  }
  return x%c;
}

// index starts with 1
template<class T>
class BIT {
  vector<T> bit;
public:
  BIT() {}
  BIT(int n): bit(n+1) {}
  T sum(int i, int j) {
      return sum(j) - sum(i-1);
  }
  T sum(int i) {
    assert(i>=0);
    i = min(i, (int)bit.size()-1);
    T s = 0;
    while(i > 0) {
      s += bit.at(i);
      i &= i - 1;
    }
    return s;
  }
  void add(int i, T x) {
    while(i < bit.size()) {
      bit.at(i) += x;
      i += i & -i;
    }
  }
  void resize(int n) {
    bit.resize(n+1);
  }
};

int main()
{
    DRI(n, q);
    V<Z> a(n+1);
    VI w(n+1);
    REP1(i, 1, n) {
        RI(a[i].i);
        a[i] -= i;
    }
    BIT<LL> ww(n);
    BIT<Z> wa(n);
    REP1(i, 1, n) {
        RI(w[i]);
        ww.add(i, w[i]);
        wa.add(i, a[i] * w[i]);
    }
    while (q--) {
        DRI(x, y);
        if (x < 0) {
            int i = -x, nw = y;
            ww.add(i, nw - w[i]);
            wa.add(i, a[i] * (nw - w[i]));
            w[i] = nw;
        } else {
            LL p1 = ww.sum(x-1), p2 = ww.sum(y);
            int lb = x-1, ub = y+1;
            while (ub - lb > 1) {
                int m = (ub - lb) / 2 + lb;
                LL s = ww.sum(m);
                if (s - p1 >= p2 - s) {
                    ub = m;
                } else {
                    lb = m;
                }
            }
            PZ(a[ub] * ww.sum(x, ub - 1) - wa.sum(x, ub - 1)
               + wa.sum(ub + 1, y) - a[ub] * ww.sum(ub + 1, y));
        }
    }
}

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <set>
#include <cmath>

using namespace std;
typedef long long ll;
const int MAXN = 200100;
const int P = (1 << 18);
const int MAXP = 2 * P + 10;
const int MOD = 1e9 + 7;

int N, Q;
ll a[MAXN];
ll w[MAXN];

ll wseg[MAXP], wiseg[MAXP], waseg[MAXP];

void upd (ll* seg, int cloc, ll cdiff, bool mmod)
{
    cloc += P;
    while (cloc)
    {
        seg[cloc] += cdiff;
        if (mmod && seg[cloc] >= MOD) seg[cloc] -= MOD;
        cloc /= 2;
    }
}

ll add (ll* seg, int cloc, bool mmod)
{
    ll res = 0;
    cloc += P;
    while (cloc > 1)
    {
        if (cloc & 1)
            res += seg[cloc-1];
        cloc /= 2;
    }
    if (mmod) res %= MOD;
    return res;
}

int wsearch (ll sgoal)
{
    //cout << "search " << sgoal << "\n";
    int cloc = 1;
    while (cloc < P)
    {
        if (wseg[2*cloc] >= sgoal)
            cloc *= 2;
        else
        {
            sgoal -= wseg[2*cloc];
            cloc *= 2;
            cloc++;
        }
    }
    return cloc - P;
}

int findm (int lo, int hi)
{
    ll sleft = add (wseg, lo, 0), sright = add (wseg, hi+1, 0);
    ll sgoal = (sleft + sright + 1) / 2;
    return wsearch (sgoal);
}

int main()
{
    scanf("%d %d", &N, &Q);
    for (int i = 0; i < N; i++)
    {
        int x;
        scanf("%d", &x);
        a[i] = x;
    }
    for (int i = 0; i < N; i++)
    {
        int x;
        scanf("%d", &x);
        w[i] = x;
    }

    for (int i = 0; i < N; i++)
    {
        upd (wseg, i, w[i], 0);
        upd (wiseg, i, (i * w[i]) % MOD, 1);
        upd (waseg, i, (a[i] * w[i]) % MOD, 1);
    }

    for (int i = 0; i < Q; i++)
    {
        int l, r;
        scanf ("%d %d", &l, &r);
        if (l < 0)
        {
            int cloc = -l - 1;
            ll cdiff = r - w[cloc];

            upd (wseg, cloc, cdiff, 0);
            upd (wiseg, cloc, (cloc * cdiff) % MOD, 1);
            upd (waseg, cloc, (a[cloc] * cdiff) % MOD, 1);
            w[cloc] = r;
        }
        else
        {
            l--, r--;
            int mm = findm (l, r);
            //cout << l << " " << mm << " " << r << "\n";
            ll ws = add (wseg, mm, 1) - add (wseg, l, 1);
            ll wis = add (wiseg, mm, 1) - add (wiseg, l, 1);
            ll was = add (waseg, mm, 1) - add (waseg, l, 1);

            ll res = ws * (a[mm] - mm) + wis - was;
            //cout << ws << " " << wis << " " << was << " " << res << "\n";

            r++;
            ws = add (wseg, r, 1) - add (wseg, mm, 1);
            wis = add (wiseg, r, 1) - add (wiseg, mm, 1);
            was = add (waseg, r, 1) - add (waseg, mm, 1);
            ll bres = ws * (mm - a[mm]) - wis + was;
            //cout << ws << " " << wis << " " << was << " " << bres << "\n";
            res = ((res + bres) % MOD + MOD) % MOD;
            printf("%d\n", (int) res);
        }
    }
}

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <set>
#include <cmath>

using namespace std;
typedef long long ll;
const int MAXN = 200100;
const int P = (1 << 18);
const int MAXP = 2 * P + 10;
const int MOD = 1e9 + 7;

int N, Q;
ll a[MAXN];
ll w[MAXN];

ll wseg[MAXP], wiseg[MAXP], waseg[MAXP];

void upd (ll* seg, int cloc, ll cdiff, bool mmod)
{
    cloc += P;
    while (cloc)
    {
        seg[cloc] += cdiff;
        if (mmod)
            seg[cloc] %= MOD;
        cloc /= 2;
    }
}

ll add (ll* seg, int cloc, bool mmod)
{
    ll res = 0;
    cloc += P;
    while (cloc > 1)
    {
        if (cloc & 1)
        {
            res += seg[cloc-1];
            if (mmod)
                res %= MOD;
        }
        cloc /= 2;
    }
    return res;
}

int wsearch (ll sgoal)
{
    //cout << "search " << sgoal << "\n";
    int cloc = 1;
    while (cloc < P)
    {
        if (wseg[2*cloc] >= sgoal)
            cloc *= 2;
        else
        {
            sgoal -= wseg[2*cloc];
            cloc *= 2;
            cloc++;
        }
    }
    return cloc - P;
}

int findm (int lo, int hi)
{
    ll sleft = add (wseg, lo, 0), sright = add (wseg, hi+1, 0);
    ll sgoal = (sleft + sright + 1) / 2;
    return wsearch (sgoal);
}

int main()
{
    scanf("%d %d", &N, &Q);
    for (int i = 0; i < N; i++)
    {
        int x;
        scanf("%d", &x);
        a[i] = x;
    }
    for (int i = 0; i < N; i++)
    {
        int x;
        scanf("%d", &x);
        w[i] = x;
    }

    for (int i = 0; i < N; i++)
    {
        upd (wseg, i, w[i], 0);
        upd (wiseg, i, i * w[i], 1);
        upd (waseg, i, a[i] * w[i], 1);
    }

    for (int i = 0; i < Q; i++)
    {
        int l, r;
        scanf ("%d %d", &l, &r);
        if (l < 0)
        {
            int cloc = -l - 1;
            ll cdiff = r - w[cloc];

            upd (wseg, cloc, cdiff, 0);
            upd (wiseg, cloc, cloc * cdiff, 1);
            upd (waseg, cloc, a[cloc] * cdiff, 1);
            w[cloc] = r;
        }
        else
        {
            l--, r--;
            int mm = findm (l, r);
            //cout << l << " " << mm << " " << r << "\n";
            ll ws = ((add (wseg, mm, 1) - add (wseg, l, 1)) % MOD + MOD) % MOD;
            ll wis = ((add (wiseg, mm, 1) - add (wiseg, l, 1)) % MOD + MOD) % MOD;
            ll was = ((add (waseg, mm, 1) - add (waseg, l, 1)) % MOD + MOD) % MOD;

            ll res = ws * (a[mm] - mm) + wis - was;
            //cout << ws << " " << wis << " " << was << " " << res << "\n";

            r++;
            ws = ((add (wseg, r, 1) - add (wseg, mm, 1)) % MOD + MOD) % MOD;
            wis = ((add (wiseg, r, 1) - add (wiseg, mm, 1)) % MOD + MOD) % MOD;
            was = ((add (waseg, r, 1) - add (waseg, mm, 1)) % MOD + MOD) % MOD;
            ll bres = ws * (mm - a[mm]) - wis + was;
            //cout << ws << " " << wis << " " << was << " " << bres << "\n";
            res = ((res + bres) % MOD + MOD) % MOD;
            printf("%d\n", (int) res);
        }
    }
}

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int mm=1000000007;
struct data{
	ll s,v,w;
	void st(ll x,ll y,ll z){
		s=x;v=y;w=z;
	}
};
struct tnode{
	int l,r,ls,rs;
	ll s,v,w;
}t[810001];
int tot,i,j,k,n,m,a[210001],b[210001],ans;
void mt(int l,int r){
	int p=++tot,m=(l+r)>>1;
	t[p].l=l;t[p].r=r;
	if (l<r){
		t[p].ls=tot+1;mt(l,m);
		t[p].rs=tot+1;mt(m+1,r);
		t[p].s=t[t[p].ls].s+t[t[p].rs].s;
		t[p].v=(t[t[p].ls].v+t[t[p].rs].v)%mm;
		t[p].w=(t[t[p].ls].w+t[t[p].rs].w)%mm;
	}else t[p].ls=t[p].rs=0,t[p].s=b[l],t[p].v=(ll)a[l]*(ll)b[l]%mm,t[p].w=(ll)l*(ll)b[l]%mm;
}
void change(int p,int x,int v){
	if (!t[p].ls){
		t[p].s=v;t[p].v=(ll)v*(ll)a[t[p].l]%mm;t[p].w=(ll)t[p].l*(ll)v%mm;
		return;
	}
	int m=(t[p].l+t[p].r)>>1;
	change((x<=m)?t[p].ls:t[p].rs,x,v);
	t[p].s=t[t[p].ls].s+t[t[p].rs].s;
	t[p].v=(t[t[p].ls].v+t[t[p].rs].v)%mm;
	t[p].w=(t[t[p].ls].w+t[t[p].rs].w)%mm;
}
data add(data a,data b){
	data res;
	res.s=a.s+b.s;res.v=(a.v+b.v)%mm;res.w=(a.w+b.w)%mm;
	return res;
}
data query(int p,int l,int r){
	data res;
	if (l<=t[p].l&&t[p].r<=r){
		res.st(t[p].s,t[p].v,t[p].w);return res;
	}
	int m=(t[p].l+t[p].r)>>1;
	res.st(0,0,0);
	if (l<=m) res=query(t[p].ls,l,r);
	if (r>m) res=add(res,query(t[p].rs,l,r));
	return res;
}
int solve(int p,int l,int r,ll v){
	data w;
	int m;
	while (t[p].ls){
		m=(t[p].l+t[p].r)>>1;
		if (r<=m){
			p=t[p].ls;continue;
		}
		if (l>m){
			p=t[p].rs;continue;
		}
		w=query(t[p].ls,l,r);
		if (w.s>=v) p=t[p].ls;else v-=w.s,p=t[p].rs;
	}
	return t[p].l;
}
int work(int l,int r){
	ll i,j,k,res;
	data w,p,q;
	w=query(1,l,r);k=(w.s+1)/2;
	j=solve(1,l,r,k);
	p=query(1,l,j);
	if (j<r){
		q=query(1,j+1,r);
		res=(ll)a[j]*(p.s%mm)-p.v;
		res=(res%mm+mm)%mm;
		res+=q.v-(ll)a[j]*(q.s%mm);res=(res%mm+mm)%mm;
		res-=((p.s%mm)*(ll)j-p.w)%mm+(q.w-(q.s%mm)*(ll)j)%mm;res=(res%mm+mm)%mm;
	}else{
		res=(ll)a[j]*p.s-p.v;res=(res%mm+mm)%mm;
		res-=(p.s*(ll)j-p.w)%mm;res=(res%mm+mm)%mm;
	}
	return res;
}
int main(){
//	freopen("C.in","r",stdin);//freopen("C.out","w",stdout);
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	for (i=1;i<=n;i++) scanf("%d",&b[i]);
	tot=0;mt(1,n);
	while (m--){
		scanf("%d%d",&j,&k);
		if (j<0){
			change(1,-j,k);b[-j]=k;
		}else{
			ans=work(j,k);
			printf("%d\n",ans);
		}
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef pair< int, int > pii;
typedef pair< long long, long long > pll;
typedef long long ll;
typedef vector< int > vi;
typedef vector< ll > vll;
typedef vector< pii > vpii;
typedef long double ld;

const ll MOD = 1e9 + 7;
ll lgput(ll a, ll b, ll mod) {
    ll ret = 1;
    while( b ){
        if(b & 1) ret = (ret * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }

    return ret;
}

int binarySearch(vector< int > &v, int value) {
    int best = 0;
    for(int step = 29; step >= 0; --step) {
        if(best + (1<<step) < v.size() && v[best + (1<<step)] <= value) best += (1<<step);
    }

    return best;
}

inline ll inv(ll x) {
    return lgput(x, MOD - 2, MOD);
}

const int MAXN = 2e5 + 10;

long long suma[MAXN<<2];
long long sumaSpecialaStanga[MAXN<<2];
long long sumaSpecialaDreapta[MAXN<<2];
long long sumaProdus[MAXN<<2];
long long coord[MAXN];

int n = 0;

void update(int node, int st, int dr, int poz, long long val) {
    if(st == dr) {
        suma[node] = val;
        sumaProdus[node] = (val * coord[poz]) % MOD;
        sumaSpecialaDreapta[node] = (val * poz) % MOD;
        sumaSpecialaStanga[node] = (val * (n - poz + 1)) % MOD;
        return;
    }

    int mid = st+dr>>1;
    if(poz <= mid) update(node<<1, st, mid, poz, val);
    else update(node<<1|1, mid + 1, dr, poz, val);

    suma[node] = suma[node<<1] + suma[node<<1|1];
    sumaProdus[node] = (sumaProdus[node<<1] + sumaProdus[node<<1|1]) % MOD;
    sumaSpecialaDreapta[node] = (sumaSpecialaDreapta[node<<1] + sumaSpecialaDreapta[node<<1|1]) % MOD;
    sumaSpecialaStanga[node] = (sumaSpecialaStanga[node<<1] + sumaSpecialaStanga[node<<1|1]) % MOD;
}

ll query(long long (&aint)[MAXN<<2], int node, int st, int dr, int a, int b) {
    if(a <= st && dr <= b) {
        return aint[node];
    }

    int mij = st + dr >> 1;
    ll ret = 0;
    if(a <= mij) ret += query(aint, node<<1, st, mij, a, b);
    if(b > mij) ret += query(aint, node<<1|1, mij + 1, dr, a,  b);

    return ret;
}

ll solve(int st, int dr) {
    int mij = st;
    int lft = st, rght = dr;
    long long medie = query(suma, 1, 1, n, st, dr);
    while(lft <= rght) {
        int mid = (lft + rght) / 2;
        if(query(suma, 1, 1, n, st, mid) - query(suma, 1, 1, n, mid, mid) <= medie / 2) {
            lft = mid + 1;
            mij = mid;
        } else {
            rght = mid - 1;
        }
    }

    long long ans = 0;
    if(st < mij) {
        /// Rezolv intai partea stanga
        /// Adun g * x mijloc
        ans = ((query(suma, 1, 1, n, st, mij - 1) % MOD) * coord[mij]) % MOD;

        /// Scad produsele gi * xi
        ans = ((ans - query(sumaProdus, 1, 1, n, st, mij - 1))%MOD + MOD) % MOD;

        ans = (ans - (query(sumaSpecialaStanga, 1, 1, n, st, mij - 1)%MOD) + MOD)%MOD;
        ans = (ans + ((query(suma, 1, 1, n, st, mij - 1)%MOD)*(n - mij + 1))%MOD)%MOD;
    }
    if(mij < dr) {
        /// Rezolv partea dreapta

        /// Adun produsele gi * xi
        ans = ((ans + query(sumaProdus, 1, 1, n, mij + 1, dr)%MOD)) % MOD;
        /// Scad g * x mijloc
        ans = (ans - (((query(suma, 1, 1, n, mij + 1, dr) % MOD) * coord[mij])%MOD) + MOD) % MOD;

        ans = (ans - (query(sumaSpecialaDreapta, 1, 1, n, mij + 1, dr)%MOD) + MOD)%MOD;
        ans = (ans + (((query(suma, 1, 1, n, mij + 1, dr)%MOD)*(mij))%MOD))%MOD;
    }

    return ans;
}
int main() {
//    freopen("input", "r", stdin); freopen("output", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    cout << fixed;

    int q;
    cin >> n >> q;

    for(int i = 1; i <= n; ++i) {
        cin >> coord[i];
    }

    for(int i = 1; i <= n; ++i) {
        long long x;
        cin >> x;
        update(1, 1, n, i, x);
    }

    while(q--) {
        long long a, b;
        cin >> a >> b;
        if(a < 0) {
            update(1, 1, n, -a, b);
        } else {
            cout << solve(a, b) << '\n';
        }
    }

    return 0;
}

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <regex> //for __gcd
#include <assert.h>

#define ul unsigned long long
#define ll long long
#define fastio ios_base :: sync_with_stdio(false), cin.tie(0), cout.tie(0)

using namespace std;

void println(vector<int> v) {
    for (int c: v) {
        cout << c << " ";
    }
    cout << endl;
}

void println(vector<ll> v) {
    for (ll c: v) {
        cout << c << " ";
    }
    cout << endl;
}

//fenvick start
const int mod = 1000000007;

class FenvickSum {
    vector<ll> tree;

public:
    explicit FenvickSum(unsigned int n) {
        tree = vector<ll>(n);
    }

    ll get(int x) {
        ll res = 0;
        for (; x >= 0; x = (x & (x + 1)) - 1) {
            res += tree[x];
        }
        return res;
    }

    ll get(int L, int R) {
        return get(R) - get(L - 1);
    }

    void update(int x, int delta) {
        for (; x < tree.size(); x = (x | (x + 1))) {
            tree[x] += delta;
        }
    }
};

class FenvickSumMod {

    vector<ll> tree;

public:
    ll get(int x) {
        ll res = 0;
        for (; x >= 0; x = (x & (x + 1)) - 1) {
            res += tree[x];
            if (res >= mod) res -= mod;
        }
        return res;
    }

    ll get(int L, int R) {
        ll res = get(R) - get(L - 1);
        if (res < 0) res += mod;
        return res;
    }

    void update(int x, ll delta) {
        delta %= mod;
        if (delta < 0) delta += mod;
        assert(delta >= 0);
        for (; x < tree.size(); x = (x | (x + 1))) {
            tree[x] += delta;
            if (tree[x] >= mod) tree[x] -= mod;
        }
    }

    explicit FenvickSumMod(unsigned int n) {
        tree = vector<ll>(n);
    }
};
//fenvick end

int main() {
//#ifndef NDEBUG
//    freopen("input.txt", "r", stdin);
//#endif // DEBUG
    fastio;
    unsigned n, q;
    cin >> n >> q;

    vector<int> weight(n);
    vector<int> position(n);
    for (int i = 0; i < n; ++i) {
        cin >> position[i];
        position[i] -= i;
    }
    FenvickSum t = FenvickSum(n);
    FenvickSumMod tMod = FenvickSumMod(n);
    for (int i = 0; i < n; ++i) {
        cin >> weight[i];
        t.update(i, weight[i]);
        tMod.update(i, position[i] * (ll) weight[i]);
    }

    function solveSlow = [&](int left, int right) {
        ll total = 0;
        ll leftWeigth = 0;
        ll rightWeigth = t.get(left, right);
        for (int x = left; x < right; x++) {
            leftWeigth += weight[x];
            rightWeigth -= weight[x];
            if (position[x + 1] - position[x] == 0) continue;
            ll delta = min(leftWeigth, rightWeigth) * (position[x + 1] - position[x]);
            total += delta % mod;
        }
        return total % mod;
    };

    function solveFast = [&](int x, int y) {
        const int M = mod;
        assert(M == 1e9 + 7);
        ll sum = t.get(x, y);
        ll need = sum / 2 + t.get(x - 1);
        int l = x - 1;
        int r = y;
        while (l < r - 1) {
            int m = (l + r) / 2;
            if (t.get(m) <= need) {
                l = m;
            } else {
                r = m;
            }
        }
        int p = l + 1;
        ll ans = -tMod.get(x, p) + tMod.get(p + 1, y);
        if (ans < 0) ans += M;
        ans += (t.get(x, p) % M * (ll) position[p]) % M;
        if (ans >= M) ans -= M;
        ans -= (t.get(p + 1, y) % M * (ll) position[p]) % M;
        if (ans < 0) ans += M;
        return ans;
    };

    for (int j = 0; j < q; ++j) {
        int x, y;
        cin >> x;
        cin >> y;
        if (x < 0) {
            x = abs(x);
            x--;
            int delta = y - weight[x];
            t.update(x, delta);
            tMod.update(x, position[x] * (ll) delta);
//            t.update(x, -weight[x]);
//            tMod.update(x, -(position[x] * (ll) weight[x]));
            weight[x] = y;
//            t.update(x, weight[x]);
//            tMod.update(x, position[x] * (ll) weight[x]);
        } else {
            cout << solveFast(x - 1, y - 1) << endl;
        }
    }
}

#include <bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define loop(i,a,b) for(int i=a;i>=b;i--)
#define forr(x,arr) for(auto& x:arr)
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-7
#define sz(x) ((lli)(x).size())

using   lli     =   long long;
using   lld     =   long double;
using   ulli    =   unsigned long long int;
using   pll     =   pair<lli, lli>;
using   ttt     =   pair<lli, pll>;
using   vttt    =   vector<ttt>;
using   vll     =   vector<pll>;
using   vl      =   vector<lli>;
using   vi      =   vector<int>;
using   vvi     =   vector<vector<int>>;
using   cd      =   complex<lld>;
const double PI = acos(-1);

#ifndef tejasp
#define trace(...) {}
#define cotra(...) {}
#define end_routine() {}
#define localsys 0
#define endl '\n'
#endif

#define MAXN 200010
lli pref[MAXN], lcol[MAXN], rcol[MAXN];
lli arr[MAXN], wrr[MAXN];

void add(lli tre[], int x, lli val, bool fl) {
    for (x+=2 ; x < MAXN; x += (x & -x))
    {
        tre[x] += val;
        if(fl) tre[x]%=mod;
    }
}

lli get(lli tre[], int x, bool fl)
{
    lli res=0;
    for(x+=2; x>0;  x -= (x & -x)) res += tre[x];
    if(fl) res%=mod;
    return res;
}

lli get(lli tre[], int l, int r, bool fl)   {
    if (!fl) return get(tre,r,fl)-get(tre,l-1,fl);
    else return (get(tre,r,fl)-get(tre,l-1,fl)+mod)%mod;
}

lli fin(int pos, int l, int r)
{
    lli move=(get(rcol,pos+1,r,1)-get(rcol,l,pos,1))%mod;
    lli del1=((arr[pos]-pos)*get(pref,pos+1,r,1))%mod;
    lli add1=((arr[pos]-pos)*get(pref,l,pos,1))%mod;
    return ((move-del1+add1)%mod+mod)%mod;
}

int tejas_919(int kkkk)
{
    lli n, m, k, q, u, v, temp=0, ans=0;
    cin>>n>>q;
    fol(i,0,n) cin>>arr[i];
    fol(i,0,n) {
        cin>>wrr[i];
        add(pref,i,wrr[i],0);
    }
    fol(i,0,n)  add(rcol,i,wrr[i]*(arr[i]-i),1);
    fol(i,1,q+1)
    {
        cin>>u>>v;
        if(u<0)
        {
            u=-u-1;
            temp=v-wrr[u];
            add(pref,u,temp,0);
            add(rcol,u,temp*(arr[u]-u),1);
            wrr[u]=v;
        }
        else
        {
            if(u==v)
            {
                cout<<0<<endl;
                continue;
            }
            else
            {
                u--; v--;
                lli f=get(pref,u,u,0);
                lli s=get(pref,u+1,v,0);
                if(f>=s)
                {
                    cout<<fin(u,u,v)<<endl;
                    continue;
                }
                int l=u, r=v;
                f+=s; f/=2;
                while(r-l>1)
                {
                    int mid=(l+r)/2;
                    if(get(pref,u,mid,0)<=f) l=mid;
                    else r=mid;
                }
                cout<<fin(l+1,u,v)<<endl;
            }
        }
        // trace(lind,n)
        // trace(arr,n)
        // trace(rind,n)
        // trace(wrr,n)
        // fol(i,0,n) trace(i,get(lcol,i,i,1));
        // fol(i,0,n) trace(i,get(rcol,i,i,1));
    }
    return 0;
}

signed main()
{
    #ifdef tejasp
            freopen("input.txt", "rt", stdin);
            freopen("output.txt", "wt", stdout);
    #endif
    if(!localsys) { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); }
    cout << fixed << setprecision(10);
    int t=1;
    //cin>>t;
    fol(i,0,t) { tejas_919(i+1); }
    end_routine();
    if(localsys) system("pause");
}

#include <cstdio>
#include <utility>
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <numeric>
#include <cassert>
#include <cstring>
#include <functional>
#include <sstream>
#include <map>

using namespace std;

typedef long long Long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;

typedef long double Double;

struct Box {
    Long w, x;
};

struct Fenwick {
    vector<Long> V;
    Fenwick(int N) : V(N+10) {}

    void add(int x, Long v) {
        for (int i = x + 1; i < V.size(); i += (i & -i)) {
            V[i] += v;
        }
    }
    Long get(int x) {
        Long r = 0;
        for (int i = x + 1; i > 0; i -= (i & -i)) {
            r += V[i];
        }
        return r;
    }
    Long segSum(int i, int j) {
        return get(j) - get(i-1);
    }
};

template<class T, class U>
struct SegmentTree {
    struct Node {
        bool hasCarry = 0;
        int b = 0,e = 0;
        U carry = U(); T val = T();
        Node(){ }
        void join(const Node &l, const Node &r){
            val = l.val + r.val;
            b = l.b;
            e = r.e;
        }
        void update(const U &u){
            carry += u;
            u(val);
            hasCarry = 1;
        }
        void pushDown(Node &l, Node &r){
            if(!hasCarry)return;
            l.update(carry.trim(0,r.e-r.b+1));
            r.update(carry.trim(l.e-l.b+1,0));
            carry = U();
            hasCarry = 0;
        }
    };
    vector<Node> V;
#define idx(b, e) (((b)+(e))|((b)!=(e))) // memory optimized index
    int N;
    SegmentTree(int N) : V(2*N), N(N){ }
    template<class I>
    void create(const vector<I> &VEC, int b = 0, int e = -1) {
        if(e == -1) e = N-1;
        int n = idx(b, e);
        if (b == e) {
            V[n].val = T(VEC[b]), V[n].b = b, V[n].e = e;
        } else {
            int m = (b + e) / 2;
            create(VEC, b, m);
            create(VEC, m + 1, e);
            V[n].join(V[idx(b, m)], V[idx(m+1, e)]);
        }
    }
    T query(int i, int j, int b = 0, int e = -1) {
        if(e == -1) e = N-1;
        int n = idx(b, e);
        if (i <= b && e <= j){
            return V[n].val;
        } else {
            int m = (b + e) / 2;
            V[n].pushDown(V[idx(b, m)], V[idx(m+1, e)]);
            if (i >  m) return query(i, j, m+1, e);
            if (j <= m) return query(i, j, b, m);
            return query(i, j, b, m) + query(i, j, m+1, e);
        }
    }
    int findOkPrefix(int i, const function<bool(T)> &isOk){
        vector<int> stk;
        stk.reserve(20);
        stk.push_back(idx(0, N-1));
        T acum; int sz = 0;
        while(stk.size()) {
            int t = stk.back(); stk.pop_back();
            Node &n = V[t];
            int m = (n.b + n.e) / 2;
            if(n.e < i) continue;
            T newAcum = sz == 0 ? n.val : (acum + n.val);
            if (i <= n.b) {
                if (isOk(newAcum)) {
                    sz += n.e - n.b + 1;
                    acum = newAcum;
                } else {
                    if(n.b == n.e) return sz;
                    stk.push_back(idx(m+1, n.e));
                    stk.push_back(idx(n.b, m));
                }
            } else {
                if(n.b == n.e) continue;
                stk.push_back(idx(m+1, n.e));
                stk.push_back(idx(n.b, m));
            }
        }
        return sz;
    }
    void update(int i, int j, const U &v, int b = 0, int e = -1) {
        if(e == -1) e = N-1;
        int n = idx(b, e);
        if (i <= b && e <= j) {
            V[n].update(v.trim(max(b-i,0), max(j-e,0)));
        } else if (i > e || j < b)
            return;
        else {
            int m = (b + e) / 2;
            int l = idx(b, m), r = idx(m+1, e);
            V[n].pushDown(V[l], V[r]);
            update(i, j, v, b, m);
            update(i, j, v, m + 1, e);
            V[n].join(V[l], V[r]);
        }
    }
};
typedef long long Long;

#define MOD 1000000007
struct Sum {
    Long s;
    Sum(Long w) {
        s = w;
    }
    Sum operator+(const Sum &o) const {
        return Sum(s + o.s);
    }
};
struct ToSides {
    int toL, toR, pl, pr, w;
    ToSides(Box b = (Box){0, 0}){
        toL = 0;
        toR = 0;
        pl = b.x;
        pr = b.x;
        w = b.w;
    }
    ToSides operator+(const ToSides &a)const{
        ToSides r = a;
        r.toL = (toL + a.toL + (1LL * (a.pl - pl) * a.w)) % MOD;
        r.toR = (toR + a.toR + (1LL * (a.pr - pr) *   w)) % MOD;
        r.pl =   pl;
        r.pr = a.pr;
        r.w  = (a.w + w) % MOD;
        return r;
    }
};
struct Replace {
    Long w;
    Replace(Long w = 0){
        this->w = w;
    }
    Replace trim(int l, int r)const{ return *this; }
    void operator+=(const Replace &a){
        w = a.w;
    }
    void operator()(ToSides &a)const{
        a.w = w;
    }
};

int main() {

    int N, Q;
    cin >> N >> Q;
    vector<Box> V(N);
    Fenwick FX(N);
    for (int i = 0; i < N; ++i) {
        scanf("%lld", &V[i].x);
        V[i].x -= i;
        FX.add(i, V[i].x);
    }
    Fenwick F(N);
    for (int i = 0; i < N; ++i) {
        scanf("%lld", &V[i].w);
        F.add(i, V[i].w);
    }
    SegmentTree<ToSides, Replace> ST(N);
    ST.create(V);
    for (int i = 0; i < Q; ++i) {
        Long l, r;
        scanf("%lld%lld", &l, &r);
        if (l < 0) {
            Long id = (-l)-1, nw = r;
            F.add(id, -V[id].w + nw);
            ST.update(id, id, Replace(nw));
            V[id].w = nw;
        } else {
            l--;r--;
            Long tots = F.segSum(l, r);
            int m = -1, lo = l, hi = r;
            while (lo <= hi) {
                int mi = (lo+hi)/2;
                Long t = F.segSum(l, mi);
                if (t * 2 < tots) {
                    lo = mi+1;
                } else {
                    m = mi;
                    hi = mi-1;
                }
            }
            Long a = ST.query(l, m).toR;
            Long b = ST.query(m, r).toL;
            cout << (a+b) % MOD << endl;
        }
    }

}

/*

5 8
1 2 6 7 10
1 1 1 1 2
1 1
1 5
1 3
3 5
-3 5
-1 10
1 4
2 5

 */

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<functional>
#include<cmath>
#include<vector>
//using namespace std;
using std::min;
using std::max;
using std::swap;
using std::sort;
using std::reverse;
using std::random_shuffle;
using std::lower_bound;
using std::upper_bound;
using std::unique;
using std::vector;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
void open(const char *s){
#ifndef ONLINE_JUDGE
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
void open2(const char *s){
#ifdef DEBUG
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
int rd(){int s=0,c,b=0;while(((c=getchar())<'0'||c>'9')&&c!='-');if(c=='-'){c=getchar();b=1;}do{s=s*10+c-'0';}while((c=getchar())>='0'&&c<='9');return b?-s:s;}
void put(int x){if(!x){putchar('0');return;}static int c[20];int t=0;while(x){c[++t]=x%10;x/=10;}while(t)putchar(c[t--]+'0');}
int upmin(int &a,int b){if(b<a){a=b;return 1;}return 0;}
int upmax(int &a,int b){if(b>a){a=b;return 1;}return 0;}
const int N=200010;
int n;
const ll p=1000000007;
namespace T1
{
	ll a[N];
	void add(int x,ll v)
	{
		for(;x<=n;x+=x&-x)
			a[x]+=v;
	}
	ll query(int x)
	{
		ll s=0;
		for(;x;x-=x&-x)
			s+=a[x];
		return s%p;
	}
	ll query2(int x)
	{
		ll s=0;
		for(;x;x-=x&-x)
			s+=a[x];
		return s;
	}
	int gao(ll v)
	{
		int x=1<<18;
		for(int i=17;i>=0;i--)
		{
			if(x-(1<<i)>=n)
				x-=1<<i;
			else if(a[x-(1<<i)]>=v)
				x-=1<<i;
			else
				v-=a[x-(1<<i)];
		}
		return x;
	}
}
namespace T2
{
	ll a[N];
	void add(int x,ll v)
	{
		v%=p;
		for(;x<=n;x+=x&-x)
			(a[x]+=v)%=p;
	}
	ll query(int x)
	{
		ll s=0;
		for(;x;x-=x&-x)
			(s+=a[x])%=p;
		return s;
	}
}
namespace T3
{
	ll a[N];
	void add(int x,ll v)
	{
		v%=p;
		for(;x<=n;x+=x&-x)
			(a[x]+=v)%=p;
	}
	ll query(int x)
	{
		ll s=0;
		for(;x;x-=x&-x)
			(s+=a[x])%=p;
		return s;
	}
}
namespace T4
{
	ll a[N];
	void add(int x,ll v)
	{
		v%=p;
		for(;x<=n;x+=x&-x)
			(a[x]+=v)%=p;
	}
	ll query(int x)
	{
		ll s=0;
		for(;x;x-=x&-x)
			(s+=a[x])%=p;
		return s;
	}
}
int q;
ll a[N],w[N];
int main()
{
	open("c");
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)
		scanf("%I64d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		scanf("%I64d",&w[i]);
		T1::add(i,w[i]);
		T2::add(i,w[i]*a[i]);
		T3::add(i,w[i]*i);
		T4::add(i,w[i]*(n-i+1));
	}
	int l,r;
	for(int i=1;i<=q;i++)
	{
		scanf("%d%d",&l,&r);
		if(l<0)
		{
			l=-l;
			T1::add(l,r-w[l]);
			T2::add(l,(r-w[l])*a[l]);
			T3::add(l,(r-w[l])*l);
			T4::add(l,(r-w[l])*(n-l+1));
			w[l]=r;
		}
		else
		{
			ll s2=T1::query2(r);
			ll s1=T1::query2(l-1);
			ll s=s1+(s2-s1+1)/2;
			int pos=T1::gao(s);
			if(pos<l)
				pos=l;
			if(pos>r)
				pos=r;
			ll ans=(a[pos]*(T1::query(pos)-T1::query(l-1))%p-(T2::query(pos)-T2::query(l-1))+(T2::query(r)-T2::query(pos))-a[pos]*(T1::query(r)-T1::query(pos)))%p;
			ans-=(T4::query(pos-1)-T4::query(l-1))-(T1::query(pos-1)-T1::query(l-1))*(n-(pos-1)+1-1);
			ans%=p;
			ans-=(T3::query(r)-T3::query(pos))-(T1::query(r)-T1::query(pos))*(pos+1-1);
			ans=(ans%p+p)%p;
			printf("%I64d\n",ans);
		}
	}
	return 0;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=2e5+10;
typedef long long ll;
const int mod=1e9+7;
struct node
{
	int cnt;
	ll l,r,s,sl,sr;
}tree[maxn*4];
int pos[maxn],a[maxn];
ll c[maxn];
node operator+(node p1,node p2)
{
	node p;
	p.cnt=p1.cnt+p2.cnt;
	p.l=p1.l,p.r=p2.r,p.s=p1.s+p2.s;
	p.sl=(p1.sl+p2.sl+(p2.l-p1.l-p1.cnt)*(p2.s%mod))%mod;
	p.sr=(p1.sr+p2.sr+(p2.r-p1.r-p2.cnt)*(p1.s%mod))%mod;
	return p;
}
node init(ll l,ll r,ll s)
{
	node p;
	p.l=l,p.r=r,p.s=s;
	p.cnt=1,p.sl=p.sr=0;
	return p;
}
void build(int l,int r,int o)
{
	if(l==r)
	{
		tree[o]=init(pos[l],pos[l],a[l]);
		return;
	}
	int ls=o*2,rs=o*2+1,m=(l+r)/2;
	build(l,m,ls);
	build(m+1,r,rs);
	tree[o]=tree[ls]+tree[rs];
}
void update(int l,int r,int o,int k,int v)
{
	if(l==r)
	{
		tree[o].s=v;
		return;
	}
	int ls=o*2,rs=o*2+1,m=(l+r)/2;
	if(k<=m)update(l,m,ls,k,v);
	else update(m+1,r,rs,k,v);
	tree[o]=tree[ls]+tree[rs];
}
ll query(int l,int r,int o,int ql,int qr)
{
	if(ql>qr)return 0;
	if(l>=ql&&r<=qr)return tree[o].s;
	int ls=o*2,rs=o*2+1,m=(l+r)/2;
	ll res=0;
	if(ql<=m)res+=query(l,m,ls,ql,qr);
	if(qr>m)res+=query(m+1,r,rs,ql,qr);
	return res;
}
node ask(int l,int r,int o,int ql,int qr)
{
	if(l>=ql&&r<=qr)return tree[o];
	int ls=o*2,rs=o*2+1,m=(l+r)/2;
	if(qr<=m)return ask(l,m,ls,ql,qr);
	else if(ql>m)return ask(m+1,r,rs,ql,qr);
	else return ask(l,m,ls,ql,qr)+ask(m+1,r,rs,ql,qr);
}
int low(int x)
{
	return x&(-x);
}
void up(int n,int x,ll v)
{
	while(x<=n)
	{
		c[x]+=v;
		x+=low(x);
	}
}
ll qu(int x2,int x1)
{
	ll res=0;
	while(x1)
	{
		res+=c[x1];
		x1-=low(x1);
	}
	while(x2)
	{
		res-=c[x2];
		x2-=low(x2);
	}
	return res;
}
int main()
{
	int n,q,l,r;
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)scanf("%d",&pos[i]);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		up(n,i,a[i]);
	}
	build(1,n,1);
	while(q--)
	{
		scanf("%d%d",&l,&r);
		if(l<0)
		{
			update(1,n,1,-l,r);
			up(n,-l,-a[-l]);
			a[-l]=r;
			up(n,-l,a[-l]);
		}
		else if(l==r) puts("0");
		else
		{
			int L=l,R=r+1,m,ans=1;
			while(L<=R)
			{
				m=(L+R)/2;
				if(qu(l-1,m)>=qu(m,r))
				{
					ans=m;
					if(R==m)break;
					R=m;
				}
				else
				{
					if(L==m)break;
					L=m;
				}
			}
			printf("%I64d\n",(ask(1,n,1,l,ans).sr+ask(1,n,1,ans,r).sl)%mod);
		}
	}
}

/*
 * Author: ylx
 * Lang: c++
 * Prog: 1030f
 */
#include<bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;
void qmax(int &x,int y) {if (x<y) x=y;}
void qmin(int &x,int y) {if (x>y) x=y;}
inline int read()
{
	char s;
	int k=0,base=1;
	while ((s=getchar())!='-'&&s!=EOF&&!(isdigit(s)));
	if (s==EOF) exit(0);
	if (s=='-') base=-1,s=getchar();
	while (isdigit(s)) k=k*10+(s^'0'),s=getchar();
	return k*base;
}
inline void write(int x)
{
	static char cnt,num[15];cnt=0;
	if (!x)
	{
		putchar('0');
		return;
	}
	for (;x;x/=10) num[++cnt]=x%10;
	for (;cnt;putchar(num[cnt--]+48));
}
const ll mod=1e9+7;
const int maxn=4e5+100;
ll a[maxn],w[maxn];//a:dis
int n,q;
ll h[maxn<<2];
ll dis[2][maxn<<2];
void Mod(ll &x)
{
	x%=mod;
}
void bt(int x,int y,int d)
{
	if (x==y)
	{
		dis[0][d]=w[x]*(a[x]-x)%mod;
		dis[1][d]=w[x]*(a[n]-(n-x)-a[x])%mod;
		h[d]=w[x];
		return;
	}
	int mid=(x+y)/2;
	bt(x,mid,d*2);
	bt(mid+1,y,d*2+1);
	h[d]=h[d*2]+h[d*2+1];
	dis[0][d]=dis[0][d*2]+dis[0][d*2+1];Mod(dis[0][d]);
	dis[1][d]=dis[1][d*2]+dis[1][d*2+1];Mod(dis[1][d]);
}
ll qsum(int x,int y,int d,int l,int r)
{
	if (x==l&&y==r) return h[d];
	int mid=(x+y)/2;
	if (r<=mid) return qsum(x,mid,d*2,l,r);
	if (l>mid) return qsum(mid+1,y,d*2+1,l,r);
	return qsum(x,mid,d*2,l,mid)+qsum(mid+1,y,d*2+1,mid+1,r);
}
ll kth(int x,int y,int d,ll k)
{
	if (x==y) return x;
	int mid=(x+y)/2;
	if (h[d*2]>=k) return kth(x,mid,d*2,k);
	return kth(mid+1,y,d*2+1,k-h[d*2]);
}
ll qdis(int x,int y,int d,int l,int r,int flag)
{
	if (l==x&&y==r) return dis[flag][d];
	int mid=(x+y)/2;
	if (r<=mid) return qdis(x,mid,d*2,l,r,flag);
	if (l>mid) return qdis(mid+1,y,d*2+1,l,r,flag);
	return (qdis(x,mid,d*2,l,mid,flag)+qdis(mid+1,y,d*2+1,mid+1,r,flag))%mod;
}
void xg(int x,int y,int d,int p)
{
	if (x==y)
	{
		dis[0][d]=w[x]*(a[x]-x)%mod;
		dis[1][d]=w[x]*(a[n]-(n-x)-a[x])%mod;
		h[d]=w[x];
		return;
	}
	int mid=(x+y)/2;
	if (p<=mid) xg(x,mid,d*2,p); else
	xg(mid+1,y,d*2+1,p);
	h[d]=h[d*2]+h[d*2+1];
	dis[0][d]=dis[0][d*2]+dis[0][d*2+1];Mod(dis[0][d]);
	dis[1][d]=dis[1][d*2]+dis[1][d*2+1];Mod(dis[1][d]);
}
signed main()
{
#ifdef ylx
	freopen("1030f.in","r",stdin);
	freopen("1030f.out","w",stdout);
#endif
	n=read(),q=read();
	for (int i=1;i<=n;i++) a[i]=read();
	for (int i=1;i<=n;i++) w[i]=read();
	bt(1,n,1);
	ll x,y,p;
	ll s,s1;
	ll ans;
	while (q--)
	{
		x=read(),y=read();
		if (x<0)
		{
			x=-x;
			w[x]=y;
			xg(1,n,1,x);
		} else
		{
			if (x==y) {printf("0\n");continue;}
			s=qsum(1,n,1,x,y);
			s=(s+1)/2;
			if (x==1) s1=0; else s1=qsum(1,n,1,1,x-1);
			p=kth(1,n,1,s1+s);
			ans=0;
			if (p!=x)
			{
				ans=qdis(1,n,1,x,p-1,1);
				ans-=(ll)(qsum(1,n,1,x,p-1))%mod*(a[n]-(n-p)-a[p])%mod;
				ans%=mod;
			}
			if (p!=y)
			{
				ans+=qdis(1,n,1,p+1,y,0);
				ans-=(ll)(qsum(1,n,1,p+1,y))%mod*(a[p]-p)%mod;
				ans%=mod;
			}
			ans=(ans%mod+mod)%mod;
			printf("%lld\n",ans);
		}
	}
	return 0;
}
//2018年 09月 26日 星期三 19:45:09 CST

#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define red(i,r,l) for(int i=r;i>=l;i--)
#define re(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MXN = 2e5 + 10; ll MOD = 1e9 + 7;
int N, Q;
ll a[MXN], w[MXN];

template <typename T>
struct fenwick {
    T f[MXN] = {};
    void update(int x, T val) {
        for (; x <= N; x += x & -x)
            (f[x] = f[x] + val);
    }

    T get(int x) {
        T res = 0;
        for (; x; x -= x & -x) {
            (res = res + f[x]);
        }
        return res;
    }

    T get(int x1, int x2) {
        x1 = max(x1 - 1, 0);
        x2 = min(x2, N);
        return get(x2) - get(x1);
    }

    T lower_bound(T s) {
        int x = 0;
        for (int k = 20; k >= 0; --k) {
            if (x + (1 << k) <= N)
                if (f[x + (1 << k)] < s) {
                    s -= f[x + (1 << k)];
                    x += 1 << k;
                }
        }
        return x + 1;
    }

    T get_median(int x1, int x2) {
        T s1, s2, goal;
        int x = 0;
        x1 = max(x1 - 1, 0);
        x2 = min(x2, N);
        s1 = get(x1);
        s2 = get(x2);
        goal = (s1 + s2 + 1) >> 1;
        return lower_bound(goal);
    }
};

fenwick<ll> F, F2;

void upd(int x, int y) {
    ll d = y - w[x];
    F.update(x, d);
    F2.update(x, (a[x] - x) * d % MOD);
    w[x] = y;
}

void init()
{
    cin >> N >> Q;
    rep(i, 1, N)
    {
        cin >> a[i];
    }
    rep(i, 1, N)
    {
        int x;
        cin >> x;
        upd(i, x);
    }
}

namespace solve
{
    void solve()
    {
        re(t, Q) {
            int x, y;
            cin >> x >> y;
            if (x > 0) {
                ll ans = 1e18;
                int m = F.get_median(x, y);
                ll t = (F.get(x, m - 1) - F.get(m + 1, y)) % MOD * (a[m] - m) % MOD;
                ll t2 = F2.get(m + 1, y) - F2.get(x, m - 1);
                ans = t + t2;
                cout << (ans % MOD + MOD) % MOD << endl;
            }
            else {
                upd(-x, y);
            }
        }
    }
}

int main()
{
    init();
    solve::solve();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

//------------------------- DEBUGGING -----------------------------------------------------------------------
#ifdef DEBUG
#define debug( args... ) { vector<string> _v = split( #args, ','); err( _v.begin(), args); cerr << endl; }
vector<string> split( const string& s, char c) {
    vector<string> v;
    stringstream ss( s);
    string x;
    while ( getline( ss, x, c))
        v.emplace_back( x);
    return move( v);
}
void err( vector<string>::iterator it) { }
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t';
    err( ++it, args...);
}
#else
#define debug(...)
#endif
//------------------------ MACROS ----------------------------------------------------------------------------

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define fr(i,j,k) for(i = j; i < (k); i++)
#define bck(i,j,k) for(i = j; i > (k); i--)
#define all(x) x.begin(), x.end()
#define el '\n'

typedef long long int ll;
typedef long double DO;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
//---------------------------  TEMPLATE ENDS, MAKE CHANGES FROM HERE ----------------------------------------

const int mod = 1e9+7;
const ll inf = 2e18;
const DO eps = 1e-9;
const int NN = 2e5 + 2;

vvi adj;
ll ar[NN], dot[NN], bit_w[NN], bit_dot[NN], w[NN];

void update(bool b, int x, ll del, int n){

    ll *bit = b ? bit_dot : bit_w;
    for(; x <= n; x += (x & (-x))){
        bit[x] += del;
        if(b) bit[x] %= mod;
    }
}

ll query(bool b, int l, int r){
    if(l > r) return 0;
    ll v = 0;
    ll *bit = b ? bit_dot : bit_w;
    int x = l-1;
    for(; x > 0; x -= (x & (-x))){
        v += bit[x];
        if(b) v %= mod;
    }
    ll ans = v;
    v = 0;
    x = r;
    for(; x > 0; x -= (x & (-x))){
        v += bit[x];
        if(b) v %= mod;
    }
    if(!b) {
        return v-ans;
    }
    ans = (-ans + v + mod)%mod;
    return ans;
}

void solve(){
    ll i = 0, j = 0, k = 0, n = 0, m = 0, q;
    cin >> n >> q;
    fr(i, 1, n+1) {
        cin >> ar[i];
        ar[i] -= i;
        debug(i, ar[i]);
    }
    fr(i, 1, n+1) {
        cin >> w[i];
        update(0, i, w[i], n);
        dot[i] = (ar[i]) * w[i];
        dot[i] %= mod;
        update(1, i, dot[i], n);
        debug(i, w[i], dot[i]);
    }
    int x, y;
    while(q--) {
        cin >> x >> y;
        debug(x, y);
        if(x < 0) {
            x = -x;
            ll del = y - w[x];
            update(0, x, del, n);
            w[x] = y;
            del = (del * ar[x]) % mod;
            if(del < 0) del += mod;
            update(1, x, del, n);

            ll SW = query(0, 1, n), SD = query(1, 1, n);
            debug(SW, SD);
        }
        else {
            int hi = y, lo = x, mid;
            ll S = query(0, x, y);
            debug(S);
            while(hi - lo > 1) {
                mid = (hi + lo)/2;
                ll A = query(0, x, mid);
                if(A > S/2) {
                    hi = mid;
                }
                else
                    lo = mid + 1;
            }
            if(query(0, x, lo) > S/2)
                k = lo;
            else
                k = hi;
            debug(k);

            ll v1 = (ar[k] * ((query(0, x, k-1) - query(0, k+1, y))%mod)) % mod;
            ll v2 = query(1, x, k-1) - query(1, k+1, y);
            v1 = (v1 - v2) % mod;
            if(v1 < 0) v1 += mod;
            cout << v1 << el;
            debug(v1);
        }
    }
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int T = 1, tc;
    for(tc = 1; tc <= T; tc++){
        solve();
    }
    return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * an easier and alternate approach
 * * if concept is corret and still WA, try with a different implementation
 * * special cases (n=1?)
 * * overflow (ll vs int?)
 * * array bounds, maximal size of global arrays is sufficient ?
 * * if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
 */

#include <algorithm>
#include <cassert>
#include <fstream>
#include <utility>
#include <cstdio>
#include <vector>
#include <bitset>
#include <string>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <set>
#include <map>

#define f first
#define s second

#pragma warning(disable:4996)

using namespace std;

template<class T> inline void chkmin(T &a, T b) {
	if (a > b) a = b;
}

template<class T> inline void chkmax(T &a, T b) {
	if (a < b) a = b;
}

typedef long long ll;
typedef long double ld;

#include <iostream>
//const string FILENAME = "test";
//ifstream cin(FILENAME + ".in");
//ofstream cout(FILENAME + ".out");

const int MOD = 1e9 + 7;
const int MAXN = 1 << 18;

int a[MAXN];
ll w[MAXN + MAXN];
int wa[MAXN + MAXN];

void add(int& a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
}

int sum(int a, int b) {
	return a + b >= MOD ? a + b - MOD : a + b;
}

int mul(ll a, ll b) {
	return (a * b) % (ll)MOD;
}

void Init() {
	for (int i = MAXN - 1; i; --i) {
		wa[i] = sum(wa[2 * i], wa[2 * i + 1]);
		w[i] = w[2 * i] + w[2 * i + 1];
	}
}

void ChWA(int v, int d) {
	wa[v] = d;
	for (v /= 2; v; v /= 2)
		wa[v] = sum(wa[2 * v], wa[2 * v + 1]);
}

int GetWA(int v, int l, int r, int L, int R) {
	if (r <= L || R <= l) return 0;
	if (L <= l && r <= R)
		return wa[v];
	int m = (l + r) / 2;
	return sum(GetWA(2 * v, l, m, L, R), GetWA(2 * v + 1, m, r, L, R));
}

void ChW(int v, ll d) {
	w[v] = d;
	for (v /= 2; v; v /= 2)
		w[v] = w[2 * v] + w[2 * v + 1];
}

ll GetW(int v, int l, int r, int L, int R) {
	if (r <= L || R <= l) return 0;
	if (L <= l && r <= R)
		return w[v];
	int m = (l + r) / 2;
	return GetW(2 * v, l, m, L, R) + GetW(2 * v + 1, m, r, L, R);
}

int CalcRes(int i, int L, int R) {
	int res = mul(a[i], GetW(1, 0, MAXN, L, i) % (ll)MOD);
	add(res, -GetWA(1, 0, MAXN, L, i) + MOD);
	add(res, GetWA(1, 0, MAXN, i + 1, R));
	add(res, -mul(a[i], GetW(1, 0, MAXN, i + 1, R) % (ll)MOD) + MOD);
	return res;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		a[i] -= i;
	}
	for (int i = 0; i < n; ++i) {
		cin >> w[MAXN + i];
		wa[MAXN + i] = mul(a[i], w[MAXN + i]);
	}
	Init();
	for (int qq = 0; qq < q; ++qq) {
		int L;
		cin >> L;
		if (L > 0) {
			--L;
			int R;
			cin >> R;
			int l = L, r = R;
			while (r - l > 1) {
				int m = (l + r) / 2;
				if (GetW(1, 0, MAXN, L, m + 1) <= GetW(1, 0, MAXN, m + 1, R))
					l = m;
				else
					r = m;
			}
			if (GetW(1, 0, MAXN, L, r) < GetW(1, 0, MAXN, r, R))
				cout << CalcRes(r, L, R) << '\n';
			else
				cout << CalcRes(l, L, R) << '\n';
		} else {
			L = -L;
			--L;
			int nw;
			cin >> nw;
			ChW(MAXN + L, nw);
			ChWA(MAXN + L, mul(nw, a[L]));
		}
	}
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;
#define inf 1000000007
#define INF 10000000000000000
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(x) int(x.size())
#define F first
#define S second
#define N 300005
#define ld long double

using namespace __gnu_pbds;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> howle;

ll tree1[N] = {0}, tree2[N] = {0}, w[N], a[N];
int n;

void upd1(int ind, ll val) {
    while(ind <= n) {
        tree1[ind] += val;
        ind += ind&-ind;
    }
}

ll query1(int ind) {
    ll sum = 0;
    while(ind > 0) {
        sum += tree1[ind];
        ind -= ind&-ind;
    }
    return sum;
}

void upd2(int ind, ll val) {
    val = val%inf;
    // cout << "upd2 : " << ind << " " << val << "\n";
    while (ind <= n) {
        tree2[ind] = (tree2[ind] + val + inf)%inf;
        while (tree2[ind] < 0) tree2[ind] += inf;
        ind += ind&-ind;
    }
}

ll query2(int ind) {
    ll sum = 0;
    // cout << "ind = " << ind << "\n";
    while (ind > 0) {
        sum += tree2[ind];
        ind -= ind&-ind;
    }
    // cout << "query2 : " << sum << "\n";
    return sum;
}

void upd(int ind, ll W) {
    ll prev = w[ind];
    w[ind] = W;
    upd1(ind + 1, W - prev);
    upd2(ind + 1, 1LL*(a[ind] - ind)*(W - prev)%inf);
}

ll get_sum(int l, int r, int i) {
    // cout << "l = " << l << " r = " << r << " i = " << i << "\n";
    ll sum = 0;
    if (i - l > 0) {
        sum += 1LL*(a[i] - i)*((query1(i) - query1(l))%inf) %inf - (query2(i) - query2(l) + inf)%inf;
        sum %= inf;
        while (sum < 0) sum += inf;
    }
    // cout << "sum1 = " << sum << "\n";
    if (r - i > 0) {
        // cout << "q1 = " << (query1(r + 1) - query1(i)) << "q2 = " << query2(r + 1) - query2(i) << "\n";
        sum -= 1LL*(a[i] - i)*((query1(r + 1) - query1(i))%inf)%inf - (query2(r + 1) - query2(i) + inf)%inf;
        sum %= inf;
        while (sum < 0) sum += inf;
    }
    // cout << "sum2 = " << sum << "\n";
    return sum;
}
int main() {
    ios_base::sync_with_stdio(false);
    int q;
    cin >> n >> q;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> w[i];
    for (int i = 0; i < n; i++) {
        upd1(i + 1, w[i]);
        upd2(i + 1, 1LL*(a[i] - i)*w[i]%inf);
    }
    while (q--) {
        ll x, y;
        cin >> x >> y;
        if (x < 0) {
            upd(abs(x + 1), y);
        }
        else {
            x--; y--;
            int lo = x, hi = y;
            int ind = lo;
            while (lo <= hi) {
                int mid = (lo + hi) >> 1;
                // cout << "mid = " << mid << " lo = " << lo << " hi = " << hi << "\n";
                // cout << "q1 = " << query1(mid) - query1(x) << " q2 = " << query1(y + 1) - query1(x) << "\n";
                if (2LL*(query1(mid) - query1(x)) <= (query1(y + 1) - query1(x))) {
                    ind = max(ind, mid);
                    lo = mid + 1;
                }
                else {
                    hi = mid - 1;
                }
            }
            // cout << "ind = " << ind << "\n";
            cout << get_sum(x,y,ind)%inf << "\n";

        }
    }
}

#define Link ""

#include <iostream>
#include <cstdio>

#define TASK "1053C"

using namespace std;

const long long Mod = 1e9 + 7;
const long long maxn = 2e5 + 1;
long long n,q,a[maxn],w[maxn];
struct T_node
{
    long long l,r,cost;
    long long sz;
} node[maxn*6];

void Enter()
{
    cin >> n >> q;
    for (long long i=1;i<=n;++i) {
        cin >> a[i];
        a[i] -= i - 1;
    }
    for (long long i=1;i<=n;++i)
        cin >> w[i];
}

void Init()
{

}

void Combine(long long i)
{
    node[i].sz = node[i*2].sz + node[i*2+1].sz;
    node[i].cost = (node[i*2].cost + node[i*2+1].cost) % Mod;
}

void Build_tree(long long i, long long l, long long r)
{
    node[i].l = l;
    node[i].r = r;
    if (l != r) {
        Build_tree(i*2,l,(l+r)/2);
        Build_tree(i*2+1,(l+r)/2+1,r);
        Combine(i);
    }
    else {
        node[i].sz = w[l];
        node[i].cost = 1ll * a[l] * w[l] % Mod;
    }
}

void Update(long long i, long long id, long long val)
{
    if (node[i].r < id || id < node[i].l)
        return;
    if (node[i].l == node[i].r) {
        w[id] = val;
        node[i].sz = w[id];
        node[i].cost = 1ll * a[id] * w[id] % Mod;
    }
    else {
        Update(i*2,id,val);
        Update(i*2+1,id,val);
        Combine(i);
    }
}

long long QuerySize(long long i, long long l, long long r)
{
    if (node[i].r < l || r < node[i].l)
        return 0;
    if (l <= node[i].l && node[i].r <= r)
        return node[i].sz;
    else
        return QuerySize(i*2,l,r) + QuerySize(i*2+1,l,r);
}

long long FindPos(long long i, long long val)
{
//    cout << node[i].l << ' ' << node[i].r << ' ' << val << '\n';
    if (node[i].l == node[i].r)
        return node[i].l;
    if (val <= node[i*2].sz)
        return FindPos(i*2,val);
    return FindPos(i*2+1,val-node[i*2].sz);
}

long long QueryCost(long long i, long long l, long long r)
{
    if (node[i].r < l || r < node[i].l)
        return 0;
    if (l <= node[i].l && node[i].r <= r)
        return node[i].cost;
    else
        return (QueryCost(i*2,l,r) + QueryCost(i*2+1,l,r)) % Mod;
}

void Solve()
{
    Build_tree(1,1,n);
    for (;q>0;--q) {
        long long x,y;
        cin >> x >> y;
        if (x < 0)
            Update(1,-x,y);
        else {
            long long chose = QuerySize(1,1,x-1) + QuerySize(1,x,y) / 2 + 1;
//            cout << chose << '\n';
            long long med = FindPos(1,chose);
//            cout << med << ' ';
            cout << (1ll * a[med] * (QuerySize(1,x,med-1) % Mod) % Mod - QueryCost(1,x,med-1) + QueryCost(1,med+1,y) - 1ll * a[med] * (QuerySize(1,med+1,y) % Mod) % Mod + 1ll * Mod * Mod) % Mod << '\n';
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

#ifdef LHL
    freopen(".INP","r",stdin);
    freopen(".OUT","w",stdout);
#else
//    freopen(TASK".INP","r",stdin);
//    freopen(TASK".OUT","w",stdout);
#endif // LHL

    Enter();
    Init();
    Solve();
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T>
inline T read(T&x){
	x=0;int f=0;char ch=getchar();
	while (ch<'0' || ch>'9') f|=(ch=='-'),ch=getchar();
	while (ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return x=f?-x:x;
}
const int N=2e5+10;
const int P=1e9+7;
int n,q,i,x,y,a[N],w[N],pres[N],sum2[N];
ll sum[N],prew[N];
inline void up(int&a,int b){a+=b;if(a>=P)a-=P;}
inline int lowbit(int x){return x&(-x);}
void add1(int x,int val){for(;x<=n;x+=lowbit(x))sum[x]+=val;}
void add2(int x,int val){for(;x<=n;x+=lowbit(x))up(sum2[x],val);}
ll get1(int x){
	ll res=0;
	for (;x>0;x-=lowbit(x)) res+=sum[x];
	return res;
}
int get2(int x){
	int res=0;
	for (;x>0;x-=lowbit(x)) up(res,sum2[x]);
	return res;
}
void revise(int pos,int nw){
	add1(pos,nw-w[pos]);
	add2(pos,(1LL*nw*a[pos]%P - 1LL*w[pos]*a[pos]%P+4LL*P)%P);
	w[pos]=nw;
	//add1(pos,w[pos]);
	//add2(pos,(1LL*w[pos]*a[pos]%P+P)%P);
}
void work(int L,int R){
	ll t=get1(L-1);
	ll tot=get1(R)-get1(L-1);
	int l=L,r=R,pos=R;
	while (l<=r){
		int mid=l+((r-l)>>1);
		ll v=get1(mid)-t;
		if (v*2LL>=tot){
			r=mid-1;
			pos=mid;
		}
		else l=mid+1;
	}
	ll A=get2(pos)-get2(L-1);
	ll B=get2(R)-get2(pos);
	ll C=-1LL*a[pos]*((get1(pos)-t)%P)%P;
	ll D=-1LL*a[pos]*((get1(R)-get1(pos))%P)%P;
	ll res=(B+D-A-C)%P;
	if (res<0) res+=P;
	printf("%lld\n",res);
}
int main(){
	read(n),read(q);
	for (i=1;i<=n;++i){
		read(a[i]);
		a[i]-=i;
	}
	for (i=1;i<=n;++i){
		read(w[i]);
		prew[i]=prew[i-1]+w[i];
		sum[i]=prew[i]-prew[i-lowbit(i)];

		pres[i]=(pres[i-1]+1LL*a[i]*w[i]%P)%P;
		if (pres[i]<0) pres[i]+=P;
		sum2[i]=pres[i]-pres[i-lowbit(i)];
		if (sum2[i]<0) sum2[i]+=P;
	}
	for (;q--;){
		read(x),read(y);
		if (x<0) revise(-x,y);
		else work(x,y);
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define LL long long
#define pb push_back
int a[(int)1e6],w[(int)1e6];
const int maxn = 100100;
const int mod = 1e9+7;
int tree[maxn<<2],tree2[maxn<<2],tree3[maxn<<2];
int n;
inline void add(int r,int v){
	while(r<=n)tree[r]+=v,r+=r&-r;
}
inline int query(int r){
	int ans=0;
	while(r)ans+=tree[r],r&=r-1;
	return ans;
}
inline int query(int l,int r){
	return query(r)-query(l-1);
}
inline void add1(int r,int v){
	while(r<=n)(tree2[r]+=v)%=mod,r+=r&-r;
}
inline int query1(int r){
	int ans=0;
	while(r)(ans+=tree2[r])%=mod,r&=r-1;
	return ans;
}
inline int query1(int l,int r){
	return query1(r)-query1(l-1);
}

inline void add2(int r,int v){
	while(r<=n)(tree3[r]+=v)%=mod,r+=r&-r;
}
inline int query2(int r){
	int ans=0;
	while(r)(ans+=tree3[r])%=mod,r&=r-1;
	return ans;
}
inline int query2(int l,int r){
	return query2(r)-query2(l-1);
}
inline int move_1(int l,int r,int pos){
	int len=r-l+1;
	return pos*(query(l,r)%mod)%mod+query2(l,r)-query(l,r)*l%mod  - query1(l,r);
}
inline int move_2(int l,int r,int pos){
	int len=r-l+1;
	return -pos*(query(l,r)%mod)%mod-query2(l,r)+query(l,r)%mod*l%mod + query1(l,r);
}
signed main(){
	ios::sync_with_stdio(false);
	int q;
	cin >>n >>q;
	for(int i=1;i<=n;++i){
		cin >> a[i];
	}
	for(int i=1;i<=n;++i){
		cin >> w[i];
		add(i,w[i]);
		add1(i,a[i]*w[i]%mod);
		add2(i,(i)*w[i]%mod);
	}
	while(q--){
		int x,y;
		cin >>x >>y;
		if(x<0){
			x=-x;
			add(x,-w[x]);
			add1(x,mod-a[x]*w[x]%mod);
			add2(x,mod-(x)*w[x]%mod);
			w[x]=y;
			add(x,w[x]);
			add1(x,a[x]*w[x]%mod);
			add2(x,(x)*w[x]%mod);
		}else{
			int l = x, r=y;
			while(l!=r){
				int mid=l+r>>1;
				if(query(x,mid) < query(mid+1,y))l=mid+1;
				else r=mid;
			}
			cout << ((move_1(x,r,a[r]-(r-x+1)+1)+move_2(r+1,y,a[r]+1))%mod+mod)%mod<<endl;
		}
	}
}

#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)
#define repd(i,x,y) for(int i=x; i>=y; --i)
#define mid (l+r>>1)

using namespace std;
const int N=200005,mod=1000000007;
typedef long long LL;
int n,m;
LL a[N],w[N];
struct bit
{
	LL t[N];

	void insert(int x,LL y)
	{
		for(int i=x; i<=n; i+=i&-i) t[i]+=y;
	}

	LL query(int x)
	{
		LL rt=0;
		for(int i=x; i; i-=i&-i) rt+=t[i];
		return rt;
	}

	LL query(int l,int r)
	{
		return query(r)-query(l-1);
	}
} t1,t2;

int getint()
{
	char ch;
	int f=1;
	while(!isdigit(ch=getchar())) if(ch=='-') f=-1;
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x*f;
}

LL getLL()
{
	char ch;
	int f=1;
	while(!isdigit(ch=getchar())) if(ch=='-') f=-1;
	LL x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x*f;
}

int main()
{
	n=getint(),m=getint();
	rep(i,1,n) a[i]=getint();
	rep(i,1,n) w[i]=getint(),t1.insert(i,w[i]),t2.insert(i,(LL)(a[i]-i)*w[i]%mod);
	while(m--)
	{
		int x=getint(),y=getint();
		if(x<0)
		{
			x=-x;
			t1.insert(x,y-w[x]),t2.insert(x,(LL)(a[x]-x)*(y-w[x])%mod);
			w[x]=y;
		}
		else
		{
			int l=x,r=y;
			int p=l,q=r;
			LL sum=t1.query(l,r);
			while(l<=r)
			{
				LL nw=t1.query(p,mid);
				if(nw>=sum-nw) r=mid-1;
				else l=mid+1;
			}
			LL ans=0;
			++r;
			ans=(-t2.query(p,r)+t1.query(p,r)%mod*(a[r]-r))%mod;
			ans=(ans+t2.query(r+1,q)-t1.query(r+1,q)%mod*(a[r]-r))%mod;
			printf("%lld\n",(ans+mod)%mod);
		}
	}
	return 0;
}

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
struct fenwick_tree {
	vector<int> x;
	fenwick_tree(int n) : x(n, 0) { }
	int sum(int i, int j) {
		if (i == 0) {
			int S = 0;
			for (j; j >= 0; j = (j & (j + 1)) - 1) S += x[j];
			return S;
		}
		else return sum(0, j) - sum(0, i - 1);
	}
	void add(int k, int a) {
		for (; k < x.size(); k |= k + 1) x[k] += a;
	}
};
struct fenwick_tree_mod {
	vector<int> x;
	fenwick_tree_mod(int n) : x(n, 0) { }
	int sum(int i, int j) {
		if (i == 0) {
			int S = 0;
			for (j; j >= 0; j = (j & (j + 1)) - 1) S = (S + x[j]) % MOD;
			return S;
		}
		else {
			int S = sum(0, j) - sum(0, i - 1);
			if (S < 0)S += MOD;
			return S;
		}
	}
	void add(int k, int a) {
		for (; k < x.size(); k |= k + 1) x[k] = (x[k] + a) % MOD;
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, Q;
	cin >> N >> Q;
	vector<int> A(N);
	vector<int> W(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		A[i] -= i;
	}
	fenwick_tree ft(N);
	fenwick_tree_mod aw(N);
	for (int i = 0; i < N; i++) {
		cin >> W[i];
		ft.add(i, W[i]);
		aw.add(i, (W[i] * A[i]) % MOD);
	}
	int a, b;
	for (int i = 0; i < Q; i++) {
		cin >> a >> b;
		if (a < 0) {
			a = -a;
			a--;
			ft.add(a, b - W[a]);
			int t = ((b - W[a])*A[a]) % MOD;
			if (t < 0)t += MOD;
			aw.add(a, t);
			W[a] = b;
		}
		else {
			a--;
			b--;
			if (a == b) {
				cout << 0 << endl;
				continue;
			}
			int l = a;
			int r = b;
			int m;
			int all = ft.sum(a, b);
			while (r - l > 1) {
				m = (r + l) / 2;
				if (2 * ft.sum(a, m) < all) {
					l = m;
				}
				else {
					r = m;
				}
			}
			if (2 * ft.sum(a, l) >= all)r = l;
			res = ((A[r] * (ft.sum(a, r) % MOD)) % MOD) - aw.sum(a, r);
			res = (res - (((A[r] * (ft.sum(r, b) % MOD)) % MOD) - aw.sum(r, b))) % MOD;
			if (res < 0)res += MOD;
			cout << res << endl;
		}
	}
}

// Can U hack it?

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)
#define qqq(a) cerr<<"error "<<a<<endl;
#define FOR(i,a,b) for(int i=int(a);i<=int(b);i++)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll maxn=2e5+10,mod=1e9+7;

pll p[maxn];

struct Fenwick{
    ll sm[maxn];

    void add(int ind,ll x,bool is){
	if(is)
	    x%=mod;
	while(ind<maxn){
	    sm[ind]+=x;
	    if(is)
		sm[ind]%=mod;
	    ind+=(ind & -ind);
	}
    }
    ll ask(int ind,bool is){
	ll ans=0;
	while(ind>0){
	    ans+=sm[ind];
	    if(is)
		ans%=mod;
	    ind-=(ind & -ind);
	}
	return ans;
    }
};
Fenwick fen1,fen2;

int main(){
    int n,q;scanf("%d%d",&n,&q);
    FOR(i,1,n){
	scanf("%lld",&p[i].F);
	p[i].F-=i;
    }
    FOR(i,1,n){
	scanf("%lld",&p[i].S);
    }
    FOR(i,1,n){
	fen1.add(i,p[i].F*p[i].S,1);
	fen2.add(i,p[i].S,0);
    }

    while(q--){
	ll a,b;scanf("%lld%lld",&a,&b);
	if(a<0){
	    a=-a;
	    fen1.add(a,-p[a].F*p[a].S,1);
	    fen2.add(a,-p[a].S,0);
	    p[a].S=b;
	    fen1.add(a,p[a].F*p[a].S,1);
	    fen2.add(a,p[a].S,0);
	}
	else{
	    ll bf=fen2.ask(a-1,0);
	    ll tot=fen2.ask(b,0)-bf;
	    ll l=a,r=b,ans=-1;
	    while(l<=r){
		int mid=(l+r)/2;
		if((2*(fen2.ask(mid,0)-bf))>=tot){
		    ans=mid;
		    r=mid-1;
		}
		else{
		    l=mid+1;
		}
	    }
	    ll BF=fen1.ask(a-1,1);
	    ll ANS=(p[ans].F*((2*(fen2.ask(ans,0)-bf)-tot)%mod)-2*(fen1.ask(ans,1)-BF)+(fen1.ask(b,1)-BF))%mod;
	    if(ANS<0)ANS+=mod;
	    printf("%lld\n",ANS);
	}
    }
}

#include <iostream>
#include <iomanip>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <cassert>
#include <fstream>
#include <algorithm>
#include <list>
#include <random>
#include <ctime>
#include <cmath>
#include <random>
#include <bitset>
#include <complex>
#include <stack>

using namespace std;
// a - b
// a inc b dec
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define mmin(a, b) a = min(a, (b))
#define mmax(a, b) a = max(a, (b))
#define mp(a,b) make_pair(a,b)
#define modsum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define modsubtract(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define modmultiply(a, b) (((a) * (b)) % M)
#define pb(a) push_back(a)
#define ALL(a) a.begin(),a.end()
#define sqr(x) (x) * (x)
#define fori(i, n) for(int i = 0; i < (int)(n); ++i)
#define cint const int &
#define SZ(a) ((int)(a.size()))
#define f(cnt) (((cnt) + 1) * (cnt) / 2)
#define watch(x) cout << (#x) << " = " << x << endl;
//#define log log10

const double PI = 2 * acos(0.0);

template<typename T>
struct edge {
    int from, to;
    T w;
    edge(int from, int to, T w): from(from), to(to), w(w) { }
    edge() { }
};

const ld EPS = 1e-9;

template<class T>
void show(T a) {
    for (auto x : a)
        cout << x << " ";
    cout << endl;
}

const int N = 2e5 + 9;
const ll oo = 1e18;
const ll M = 1e9 + 7;

ld pw_double[N], pa_double[N];

ld tw_double[N], ta_double[N];

inline void upd_double(int i, ld w, ld a) {
    ld tmp = w;
    w -= pw_double[i];
    pw_double[i] = tmp;
    tmp = a;
    a -= pa_double[i];
    pa_double[i] = tmp;
    for (++i; i < N; i += i&-i)
        tw_double[i] += w, ta_double[i] += a;

}

inline void get_double(int l, int r, ld &w, ld &a) {
    if (l > r) return;
    for (++r; r > 0; r -= r&-r)
        w += tw_double[r], a += ta_double[r];
    for (; l > 0; l -= l&-l)
        w -= tw_double[l], a -= ta_double[l];
}

int pw[N], pa[N];
int tw[N], ta[N];

inline void upd(int i, int w, int a) {
    int tmp = w;
    w = modsubtract(w, pw[i]);
    pw[i] = tmp;
    tmp = a;
    a = modsubtract(a, pa[i]);
    pa[i] = tmp;
    for (++i; i < N; i += i&-i)
        tw[i] = modsum(tw[i], w), ta[i] = modsum(ta[i], a);
}

inline void get(int l, int r, int &w, int &a) {
    if (l > r) return;
    for (++r; r > 0; r -= r&-r)
        w = modsum(w, tw[r]), a = modsum(a, ta[r]);
    for (; l > 0; l -= l&-l)
        w = modsubtract(w, tw[l]), a = modsubtract(a, ta[l]);
}

int a[N];
int n, q;

inline int bins(ll xl) {
    int l = -1, r = n;
    while (r - l > 1) {
        int m = (l + r) >> 1;
        if (xl + m - a[m] >= 0)
            l = m;
        else
            r = m;
    }
    return r;
}

inline ld get_double(int xx, int l, int r) {
    int pos = bins(xx - l);
    ld x = xx;
    ld w = 0, a = 0, w1 = 0, a1 = 0;
    get_double(l, min(pos - 1, r), w, a);
    get_double(max(l, pos), r, w1, a1);
    return (w - w1) * (x - l) + a - a1;
}

inline int get(int x, int l, int r) {
    int pos = bins(x - l);
    int w = 0, a = 0, w1 = 0, a1 = 0;
    get(l, min(pos - 1, r), w, a);
    get(max(l, pos), r, w1, a1);
    return modsum(modmultiply(modsubtract(w, w1), modsubtract(x, l)), modsubtract(a, a1));
}

inline bool check(int x, int l, int r) {
    ld a = get_double(x, l, r), b = get_double(x + 1, l, r);
    return  a > b || abs(a - b) < EPS;
}

int solve(int L, int R) {
    int l = -1, r = 1e9 + 9;
    while (r - l > 1) {
        int m = (l + r) >> 1;
        if (check(m, L, R))
            l = m;
        else
            r = m;

    }
    return get(r, L, R);
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

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

    fori (i, n) {
        int w;
        cin >> w;
        upd(i, w, modmultiply((ll)w, modsubtract(i, a[i])));
        upd_double(i, w, (ld)w * (i - a[i]));
    }

    while (q--) {
        int x, y;
        cin >> x >> y;
        if (x < 0) {
            x = -x - 1;
            upd(x, y, modmultiply((ll)y, modsubtract(x, a[x])));
            upd_double(x, y, (ld)y * (x - a[x]));
        } else {
            cout << solve(--x, --y) << "\n";
        }
    }
}

#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define f first
#define s second

using namespace std;

const ll mod=1LL*1000*1000*1000+7;
ll ftree_S[200005];
ll ftree_wa[200005];
ll a[200005],w[200005];

void upd(ll *ftree,ll x,ll d)
{
          for(int i=x;i<200005;i|=i+1)
                    ftree[i]=ftree[i]+d;
}

ll normm(ll a) {
	if(a >= mod)
		a -= mod;
	if(a < 0)
		a += mod;
	return a;
}

ll norm(ll a) {
	return normm((a % mod));
}

ll mul(ll a, ll b) {
	return ((a * 1ll * b) % mod);
}

ll s(ll *ftree,ll x)
{
          ll res=0;
          for(int i=x;i>=0;i=(i&(i+1))-1)
                    res+=ftree[i];
          return res;
}

ll s(ll *ftree,ll l,ll r)
{
          return s(ftree,r-1)-s(ftree,l-1);
}

int n,q;

int main()
{
          ios_base::sync_with_stdio(0);
          cin>>n>>q;
          for(int i=1;i<=n;i++)
          {
                    cin>>a[i];
                    a[i]-=i;
          }
          for(int i=1;i<=n;i++)
          {
                    cin>>w[i];
                    upd(ftree_S,i,w[i]);
                    upd(ftree_wa,i,mul(w[i],a[i]));
          }

          for(int i=0;i<q;i++)
          {
                    ll x,y;
                    cin>>x>>y;
                    if(x<0)
                    {
                              x=-x;

                              upd(ftree_S,x,-w[x]);
                              upd(ftree_wa,x,-mul(w[x],a[x]));

                              w[x]=y;

                              upd(ftree_S,x,w[x]);
                              upd(ftree_wa,x,mul(w[x],a[x]));
                    }
                    else
                    {
                              ll l=x,r=y+1;
                              while(r-l>1)
                              {
                                        ll mid=(r+l)/2;
                                        if(2*s(ftree_S,x,mid)>s(ftree_S,x,y+1))
                                                  r=mid;
                                        else
                                                  l=mid;
                              }
                              ll res=0;
                              res=norm(mul(norm(s(ftree_S,x,l)),a[l])-norm(s(ftree_wa,x,l)));
                              res=norm(res+norm(s(ftree_wa,l,y+1))-mul(norm(s(ftree_S,l,y+1)),a[l]));
                              cout<<res<<endl;
                    }
          }
}

#include<bits/stdc++.h>

using namespace std;
#define taskname ""
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
int n , q , w[maxn] , a[maxn];
ll sw[maxn] , swa[maxn];
void update(int x , int val , int type)
{
    for( ; x <= n ; x += x & -x)
        if(type == 0)
            sw[x] += val;
        else
            swa[x] = (swa[x] + val) % mod;
}
ll getsum(int x , int type)
{
    ll res = 0;
    for( ; x > 0 ; x &= x - 1)
        if(type == 0)
            res += sw[x];
        else
            res = (res + swa[x]) % mod;
    return res;
}
ll getsum(int l , int r , int type)
{
    if(type == 0)return getsum(r , 0) - getsum(l - 1 , 0);
    else return (getsum(r , 1) - getsum(l - 1 , 1) + mod) % mod;
}
int jump(ll t)
{
    int p = 1;
    while((p << 1) <= n)p <<= 1;
    int x = n + 1;int cur = 0;
    for( ; p > 0 ; p >>= 1)
    {
        int newmask = cur | p;
        if(newmask <= n)
        {
            if(sw[newmask] >= t)x = newmask;
            else {
                cur |= p;
                t -= sw[newmask];
            }
        }
    }
    return x;
}
int jump(int l , int r)
{
    ll need = getsum(l , r , 0);
    int L = l , H = r;
    while(L < H)
    {
        int mid = L + H >> 1;
        if(2 * getsum(l , mid , 0) < need)L = mid + 1;
        else H = mid;
    }
    return L + H >> 1;
}
int query(int l , int r)
{
    ll sum = getsum(l , r , 0);
    ll haf = sum / 2 + sum % 2;
    int mid = jump(l , r);
    ll res = ((ll)a[mid] * (getsum(l , mid , 0) % mod) % mod - getsum(l , mid , 1) + getsum(mid+1,r,1) - (ll)a[mid] * (getsum(mid+1,r,0) % mod) % mod) % mod;
    return (res + (ll)mod * mod) % mod;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r"))
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
    cin >> n >> q;
    for(int i = 1 ; i <= n ; ++i){
        cin >> a[i];a[i] -= i;
    }
    for(int i = 1 ; i <= n ; ++i)cin >> w[i];
    for(int i = 1 ; i <= n ; ++i)
        update(i , w[i] , 0) , update(i , (ll)w[i] * a[i] % mod , 1);
    while(q--)
    {
        int x , y;cin >> x >> y;
        if(x < 0)
        {
            x = -x;
            update(x , y - w[x] , 0);
            update(x , ((ll)(y + mod - (ll)w[x]) * a[x]) % mod , 1);
            w[x] = y;
        }
        else
            cout << query(x , y) << '\n';
    }
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,q;
const int maxn=2e5+5;
const ll mod=1e9+7;
ll a[maxn],w[maxn];
ll lowbit(ll x) {return x&-x;}
void add(ll t[],ll x,ll d,int typ)
{
    for(;x<maxn;x+=lowbit(x))
    {
        t[x]+=d;
        if(typ) t[x]=(t[x]+mod)%mod;
    }
}

ll ask(ll t[],ll x,int typ)
{
    ll ret=0;
    for(;x;x-=lowbit(x))
    {
        ret+=t[x];
        if(typ) ret%=mod;
    }
    return ret;
}
ll sum[maxn];
ll t[maxn];
int main()
{
    scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++) {scanf("%lld",a+i);a[i]-=i;}
    for(int i=1;i<=n;i++) {scanf("%lld",w+i);add(t,i,w[i],0);add(sum,i,w[i]*a[i],1);}

    while(q--)
    {
        ll l,r;
        scanf("%lld%lld",&l,&r);
        if(l<0)
        {
            add(t,-l,r-w[-l],0);
            add(sum,-l,a[-l]*(r-w[-l]+mod)%mod,1);
            w[-l]=r;
        }
        else
        {
            ll L=l,R=r;
            ll all=ask(t,r,0)-ask(t,l-1,0);
            while(L<R)
            {
                ll mid=(L+R)/2;
                if(ask(t,mid,0)-ask(t,l-1,0)>all/2) R=mid;
                else L=mid+1;
            }
            ll k=R;
            ll ans=a[k]*(ask(t,k-1,1)-ask(t,l-1,1)+mod)%mod;
            ans-=(ask(sum,k-1,1)-ask(sum,l-1,1)+mod)%mod;
            ans=(ans+mod)%mod;
            (ans+=(ask(sum,r,1)-ask(sum,k,1)+mod))%=mod;
            ans-=a[k]*(ask(t,r,1)-ask(t,k,1)+mod)%mod;
            ans=(ans+mod)%mod;
            printf("%lld\n",ans);
        }
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define N 200005
const int mod = 1e9 + 7;
#define ll long long

int a[N],w[N];
ll pen[N];

int add(int x,int y) {
  return ((x+y)%mod+mod)%mod;
}
int mul(int x,int y) {
  return (ll)x*y%mod;
}
int mypow(int x,int c) {
  int ret = 1;
  while(c>0) {
    if(c&1) {
      ret = mul(ret,x);
    }
    c/=2;
    x = mul(x,x);
  }
  return ret;
}

void update(int ind,ll ad) {
  while(ind<N) {
    pen[ind] += ad;
    ind += ind&(-ind);
  }
}

ll query(int ind) {
  ll ret = 0;
  while(ind>0) {
    ret += pen[ind];
    ind = ind&(ind-1);
  }
  return ret;
}

int seg[N*4];

void init(int pos,int l,int r) {
  if(l==r) {
    seg[pos] = mul(a[l],w[l]);
    return;
  }
  int mid = (l+r)/2;
  init(pos*2,l,mid);
  init(pos*2+1,mid+1,r);
  seg[pos] = add(seg[pos*2],seg[pos*2+1]);
}

void update(int pos,int l,int r,int ind) {
  if(l==r) {
    seg[pos] = mul(a[l],w[l]);
    return;
  }
  int mid = (l+r)/2;
  if(ind<=mid)
    update(pos*2,l,mid,ind);
  else
    update(pos*2+1,mid+1,r,ind);
  seg[pos] = add(seg[pos*2],seg[pos*2+1]);
}

int query(int pos,int l,int r,int ql,int qr) {
  if(r<ql || qr<l) {
    return 0;
  }
  if(ql<=l && r<=qr) {
    return seg[pos];
  }
  int mid = (l+r)/2;
  return add(query(pos*2,l,mid,ql,qr),query(pos*2+1,mid+1,r,ql,qr));
}

ll sum(int x,int y) {
  return query(y) - query(x-1);
}

int pre[N];

void solve() {
  int n,q;
  scanf("%d %d ", &n,&q);
  for(int i=1;i<=n;++i) {
    scanf("%d ", &a[i]);
    a[i] = a[i] - i;
    pre[i] = add(pre[i-1],a[i]);
  }
  for(int i=1;i<=n;++i) {
    scanf("%d ", &w[i]);
    update(i,w[i]);
  }
  init(1,1,n);

  while(q--) {
    int x,y;
    scanf("%d %d ", &x,&y);
    if(x<0) {
      //type 1
      int ind = -x;
      update(ind,-w[ind] + y);
      w[ind] = y;
      update(1,1,n,ind);
    } else {
      if(y-x==0) {
        printf("0\n");
      } else {
        int l = x,r = y,mid;
        ll total = sum(x,y);
        while(l<r) {
          mid = (l+r)/2;
          if(sum(x,mid)*2>total) {
            r = mid;
          } else {
            l = mid + 1;
          }
        }
        assert(sum(x,l-1)*2<=total);
        int ret = ret = add(mul(sum(x,l),a[l]),-query(1,1,n,x,l));
        ret = add(ret, query(1,1,n,l,y));
        ret = add(ret, -mul(sum(l,y),a[l]));

        printf("%d\n",ret);
      }
    }
  }
}

int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}

#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 1000000000
#define MOD 1000000007
#define M 15000007
#define N 200005
#define MAX 5032117
#define LOG 100
#define KOK 333
using namespace std;

struct seg {

	ll ws;
	int as;

	inline seg operator+(seg a) {

		return {ws+a.ws,(as+a.as)%MOD};

    }

} S[N*4];

int n,q,x,t,y;
int l[N];

int get2(int node,int bas,int son,int x,int y,int cas) {

	if(bas>y || son<x) return 0;

	if(bas>=x && son<=y) {

		int pos=(cas?x-1:y+1);

		return (S[node].ws%MOD*(l[pos]-pos)%MOD+S[node].as)%MOD;

	}

	return (get2(node*2,bas,orta,x,y,cas)+get2(node*2+1,orta+1,son,x,y,cas))%MOD;

}

ll get1(int node,int bas,int son,int x,int y) {

	if(bas>y || son<x) return 0;

	if(bas>=x && son<=y) return S[node].ws;

	return get1(node*2,bas,orta,x,y)+get1(node*2+1,orta+1,son,x,y);

}

void up(int node,int bas,int son,int x,int val) {

	if(bas>x || son<x) return ;

	if(bas==x && son==x) {

		S[node]={val,1ll*val*(bas-l[bas]+MOD)%MOD};

		return ;

	}

	up(node*2,bas,orta,x,val);
	up(node*2+1,orta+1,son,x,val);

	S[node]=S[node*2]+S[node*2+1];

}

int main() {

	//freopen("input.txt","r",stdin);

	scanf("%d %d",&n,&q);

	for(int i=1;i<=n;i++) {

		scanf("%d",&l[i]);

	}

	for(int i=1;i<=n;i++) {

		scanf("%d",&x);

		up(1,1,n,i,x);

	}

	while(q--) {

		scanf("%d %d",&x,&y);

		if(x>0) {

			int bas=x,son=y;
			ll alle=get1(1,1,n,x,y);

			while(bas<=son) {

				if(get1(1,1,n,x,orta)>=alle/2) son=orta-1;
				else bas=orta+1;

			}

			printf("%d\n",(get2(1,1,n,x,bas-1,0)-get2(1,1,n,bas+1,y,1)+MOD)%MOD);

		}
		else {

			x=-x;

			up(1,1,n,x,y);

		}

	}

}

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
const LL MAX = 200007;

LL sum(LL a, LL b)
{
    return a+b>=MOD?a+b-MOD:a+b;
}
LL sub(LL a, LL b)
{
    return a-b<0?a-b+MOD:a-b;
}
LL mul(LL a, LL b)
{
    return (a*b)%MOD;
}

LL ps[MAX];
LL ar[MAX];
LL tr[4*MAX];
LL tr2[4*MAX];
LL tr3[4*MAX];

void init(LL u, LL l, LL r)
{
    if (l==r) {
        tr[u] = ar[l];
        tr2[u] = mul(ar[l], ps[l]);
        tr3[u] = mul(ar[l], l);
        return;
    }

    LL mid = (l+r)/2;
    init(u*2, l, mid);
    init(u*2+1, mid+1, r);

    tr[u] = tr[u*2]+tr[u*2+1];
    tr2[u] = sum(tr2[u*2], tr2[u*2+1]);
    tr3[u] = sum(tr3[u*2], tr3[u*2+1]);
}

void update(LL u, LL l, LL r, LL idx, LL v)
{
    if (l==r) {
        ar[l] = v;
        tr[u] = ar[l];
        tr2[u] = mul(ar[l], ps[l]);
        tr3[u] = mul(ar[l], l);
        return;
    }

    LL mid = (l+r)/2;
    if (idx <= mid) update(u*2, l, mid, idx, v);
    else update(u*2+1, mid+1, r, idx, v);

    tr[u] = tr[u*2]+tr[u*2+1];
    tr2[u] = sum(tr2[u*2], tr2[u*2+1]);
    tr3[u] = sum(tr3[u*2], tr3[u*2+1]);
}

LL query(LL u, LL l, LL r, LL x, LL y)
{
    if (x > y) return 0;
    if (r < x || y < l) return 0;
    if (x <= l && r <= y) return tr[u];

    LL mid = (l+r)/2;
    return query(u*2, l, mid, x, y)+query(u*2+1, mid+1, r, x, y);
}

LL query2(LL u, LL l, LL r, LL x, LL y)
{
    if (x > y) return 0;
    if (r < x || y < l) return 0;
    if (x <= l && r <= y) return tr2[u];

    LL mid = (l+r)/2;
    return sum(query2(u*2, l, mid, x, y), query2(u*2+1, mid+1, r, x, y));
}

LL query3(LL u, LL l, LL r, LL x, LL y)
{
    if (x > y) return 0;
    if (r < x || y < l) return 0;
    if (x <= l && r <= y) return tr3[u];

    LL mid = (l+r)/2;
    return sum(query3(u*2, l, mid, x, y), query3(u*2+1, mid+1, r, x, y));
}

LL n;
LL solve(LL l, LL r)
{
    if (l==r) return 0;
    LL sm = query(1, 1, n, l, r);
//    cout << sm << endl;
    LL lo = l, hi = r, mid;
    while (lo <= hi) {
//        cout << lo << "-" << hi << endl;
        mid = (lo+hi)/2;
        LL z = query(1, 1, n, l, mid);
        if (z <= sm/2) lo = mid+1;
        else hi = mid-1;
    }

    LL y = lo;
    LL x = lo-1;

//    cout << x << " " << y << endl;

    LL ans = 0;

    LL leftsum = query(1, 1, n, l, x);
    LL rightsum = query(1, 1, n, y, r);
    LL leftsum2 = query2(1, 1, n, l, x);
    LL rightsum2 = query2(1, 1, n, y, r);
    LL leftsum3 = query3(1, 1, n, l, x);
    LL rightsum3 = query3(1, 1, n, y, r);

//    cout << leftsum << " " << rightsum << endl;
//    cout << leftsum2 << " " << rightsum2 << endl;
//    cout << leftsum3 << " " << rightsum3 << endl;

    ans = sum(ans, sub(mul(ps[x], leftsum), leftsum2));
    ans = sub(ans, sub(mul(x, leftsum), leftsum3));
    ans = sum(ans, sub(rightsum2, mul(ps[y], rightsum)));
    ans = sub(ans, sub(rightsum3, mul(y, rightsum)));

    if (l <= x && y <= r)
        ans = sum(ans, mul(min(leftsum, rightsum), ps[y]-ps[x]-1));

    return ans;
}

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);

    LL q;
    cin >> n >> q;

    for (LL i = 1; i <= n; i++) cin >> ps[i];
    for (LL i = 1; i <= n; i++) cin >> ar[i];

    init(1, 1, n);

//    cout << "ok" << endl;

    while (q--) {
        LL a, b;
        cin >> a >> b;
        if (a < 0) update(1, 1, n, -a, b);
        else cout << solve(a, b) << endl;
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ull = unsigned ll;

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x first
#define y second

const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};
const char dir[] = {'R', 'L', 'D', 'U'};

int add(int a, int b){ //(a + b) % 1e9 + 7
    a += b;
    if(a >= MOD){
        a -= MOD;
    }
    return a;
}

int sub(int a, int b){
    a -= b;
    if(a < 0) a += MOD;
    return a;
}

int mult(int a, int b){
    return ((ll) a * b) % MOD;
}

void setIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
//    freopen((s+".in").c_str(),"r",stdin);
//    freopen((s+".text").c_str(),"w",stdout);
}

const int mxN = 200'000;

ll tree[mxN + 5];
void update(int index, ll val) {
    index++;
    while(index < mxN + 5) {
        tree[index] += val;
        index += index & -index;
    }
}
ll query(int index) {
    ll ret = 0;
    index++;
    while(index > 0) {
        ret += tree[index];
        index -= index & -index;
    }
    return ret;
}
ll rquery(int a, int b) {
    return query(b)-query(a-1);
}

int n, q;
int a[mxN], w[mxN];

struct node{
    int toLeft, toRight, total, l, r, inSeg;
    node(int tl, int tr, int tt, int left, int right, int is){
        toLeft = tl;
        toRight = tr;
        total = tt;
        l = left;
        r = right;
        inSeg = is;
    }
    node(){
        toLeft = 0, toRight = 0, total = 0;
        l = 0, r = 0;
        inSeg = 0;
    }
};

node st[mxN << 2];

void update(node& t, int ind){
    t = node(0, 0, w[ind], a[ind], a[ind], 1);
}

node merge(node& a, node& b){
    if(a.inSeg == 0) return b;
    if(b.inSeg == 0) return a;
    node c;
    c.r = b.r;
    c.l = a.l;
    int nextRight = b.r - b.inSeg;
    c.toRight = add(b.toRight, add(a.toRight, mult(a.total, nextRight - a.r)));
    int nextLeft = a.l + a.inSeg;
    c.toLeft = add(a.toLeft, add(b.toLeft, mult(b.total, b.l - nextLeft)));
    c.total = add(a.total, b.total);
    c.inSeg = add(a.inSeg, b.inSeg);
    return c;
}

void build(int v, int l, int r){
    if(l == r){
        st[v] = node(0, 0, w[l], a[l], a[l], 1);
        return;
    }
    int m = (l + r) / 2;
    build(v * 2 + 1, l, m);
    build(v * 2 + 2, m + 1, r);
    st[v] = merge(st[v * 2 + 1], st[v * 2 + 2]);
}

void update(int v, int l, int r, int ind){
    if(r < ind || l > ind) return;
    if(l == r){
        update(st[v], ind);
        return;
    }
    int m = (l + r) / 2;
    build(v * 2 + 1, l, m);
    build(v * 2 + 2, m + 1, r);
    st[v] = merge(st[v * 2 + 1], st[v * 2 + 2]);
}

node get(int v, int l, int r, int L, int R){
    if(L > R || r < L || l > R) return node();
    if(L == l && r == R){
        return st[v];
    }
    int m = (l + r) / 2;
    node left = get(v * 2 + 1, l, m, L, min(R, m));
    node right = get(v * 2 + 2, m + 1, r, max(L, m + 1), R);
    return merge(left, right);
}

int main(){
    setIO();
    //CHECK FOR LONG LONG!!!
    //LONG LONG OVERFLOW??
    cin >> n >> q;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    for(int i = 0; i < n; ++i){
        cin >> w[i];
        update(i, w[i]);
    }
    build(0, 0, n - 1);
    while(q--){
        int x, y; cin >> x >> y;
        if(x < 0){
            x = -x; --x;
            update(x, -w[x]);
            w[x] = y;
            update(x, w[x]);
            update(0, 0, n - 1, x);
        }
        else{
            --x; --y;
            if(x == y){
                cout << "0\n";
                continue;
            }
            ll tot = rquery(x, y);
            int l = x, r = y;
            while(r - l > 1){
                int m = (l + r) / 2;
                if(2 * rquery(x, m) <= tot){
                    l = m;
                }
                else{
                    r = m;
                }
            }
            ++l;
            int curloc = a[l];
            if(l == x){
                node cur = get(0, 0, n - 1, l + 1, y);
                cout << add(cur.toLeft, mult(cur.total, cur.l - curloc - 1)) << "\n";
            }
            else if(l == y){
                node cur = get(0, 0, n - 1, x, l - 1);
                cout << add(cur.toRight, mult(cur.total, curloc - cur.r - 1)) << "\n";
            }
            else{
                node right = get(0, 0, n - 1, l + 1, y);
                node left = get(0, 0, n - 1, x, l - 1);
                cout << add(add(right.toLeft, mult(right.total, sub(right.l, curloc) - 1)), add(left.toRight, mult(left.total, sub(curloc, left.r) - 1))) << "\n";
            }
        }
    }
    //CHECK FOR LONG LONG!!!
}

#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define f first
#define s second

using namespace std;

const ll mod=1LL*1000*1000*1000+7;
ll ftree_S[200005];
ll ftree_wa[200005];
ll a[200005],w[200005];

void upd(ll *ftree,ll x,ll d)
{
          for(int i=x;i<200005;i|=i+1)
                    ftree[i]=(ftree[i]+d)%mod;
}

ll s(ll *ftree,ll x)
{
          ll res=0;
          for(int i=x;i>=0;i=(i&(i+1))-1)
                    res=(res+ftree[i])%mod;
          return res;
}

ll s(ll *ftree,ll l,ll r)
{
          return s(ftree,r)-s(ftree,l-1);
}

int n,q;

int main()
{
          ios_base::sync_with_stdio(0);
          cin>>n>>q;
          for(int i=1;i<=n;i++)
          {
                    cin>>a[i];
                    a[i]-=i;
          }
          for(int i=1;i<=n;i++)
          {
                    cin>>w[i];
                    upd(ftree_S,i,w[i]);
                    upd(ftree_wa,i,w[i]*a[i]%mod);
          }

          for(int i=0;i<q;i++)
          {
                    int x,y;
                    cin>>x>>y;
                    if(x<0)
                    {
                              upd(ftree_S,-x,y-w[-x]);
                              upd(ftree_wa,-x,(y-w[-x])*(a[-x]));
                              w[-x]=y;
                    }
                    else
                    {
                              ll l=x,r=y;
                              while(r-l>1)
                              {
                                        ll mid=(r+l)/2;
                                        if(2*s(ftree_S,x,mid)>=s(ftree_S,x,y))
                                                  r=mid;
                                        else
                                                  l=mid;
                              }
                              ll res=0;
                              res=(s(ftree_S,x,r-1)*a[r]%mod-s(ftree_wa,x,r-1)+mod)%mod;
                              res=(res+s(ftree_wa,r+1,y)+mod-s(ftree_S,r+1,y)*a[r]%mod)%mod;
                              cout<<res<<endl;
                    }
          }
}

#include<bits/stdc++.h>
#define re register
#define ll long long
#define int ll
const int N=2e5+5;
const ll mod=1e9+7;
using namespace std;
template<class T>
inline void read(T &x)
{
	x=0; int f=1;
	static char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') f=-1; ch=getchar();}
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
}
inline void write(ll x)
{
	if(x<0) {x=-x; putchar('-');}
	if(x>9) write(x/10);
	putchar(x%10+'0');
}
int n,Q;
ll a[N],w[N],b[N];
struct Tree
{
	int l,r;
	ll sum,s;
}tree[4*N];
inline void pushup(int now)
{
	tree[now].sum=(tree[now<<1].sum+tree[now<<1|1].sum)%mod;
	tree[now].s=(tree[now<<1].s+tree[now<<1|1].s)%mod;
}
inline void build(int now,int l,int r)
{
	tree[now].l=l,tree[now].r=r;
	if(l==r)
	{
		tree[now].sum=w[l];
		tree[now].s=b[l]*w[l]%mod;
		return;
	}
	int m=(l+r)>>1;
	build(now<<1,l,m);
	build(now<<1|1,m+1,r);
	pushup(now);
}
inline ll query(int now,int l,int r)
{
	if(l<=tree[now].l&&tree[now].r<=r) return tree[now].sum;
	int m=(tree[now].l+tree[now].r)>>1; ll ans=0;
	if(l<=m) ans+=query(now<<1,l,r);
	if(r>m) ans+=query(now<<1|1,l,r);
	return ans%mod;
}
inline void update(int now,int pos,ll x)
{
	if(tree[now].l==tree[now].r)
	{
		tree[now].sum=x;
		tree[now].s=b[pos]*x%mod;
		return;
	}
	int m=(tree[now].l+tree[now].r)>>1;
	if(pos<=m) update(now<<1,pos,x);
	else update(now<<1|1,pos,x);
	pushup(now);
}
inline ll ask(int now,int l,int r)
{
	if(l<=tree[now].l&&tree[now].r<=r)	return tree[now].s;
	int m=(tree[now].l+tree[now].r)>>1; ll ans=0;
	if(l<=m) ans+=ask(now<<1,l,r);
	if(r>m) ans+=ask(now<<1|1,l,r);
	return ans%mod;
}
inline void Solve(int l,int r)
{
	int L=l,R=r,ans=l;
	while(L<=R)
	{
		int mid=(L+R)>>1;
		ll QL=query(1,l,mid),QR=query(1,mid+1,r);
		if(QL>=QR) ans=mid,R=mid-1;
		else L=mid+1;
	}
	ll Q1=((ll)(query(1,l,ans-1)*(a[ans]-ans))-ask(1,l,ans-1));
	ll Q2=((ll)(query(1,ans+1,r)*(ans-a[ans]))+ask(1,ans+1,r));
	write((Q1+Q2)%mod),putchar('\n');
}
signed main()
{
	read(n),read(Q);
	for(int i=1;i<=n;i++) read(a[i]),b[i]=a[i]-i;
	for(int i=1;i<=n;i++) read(w[i]);
	build(1,1,n);
	ll l,r;
	while(Q--)
	{
		read(l),read(r);
		if(l<0) update(1,-l,r);
		if(l>0)	Solve(l,r);
	}
	return 0;
}

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <array>

using namespace std;

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;

const long MOD = 1e9+7;
const long BIG = 1e9+5;

int n, q;
long A[200003], W[200003];

long ft[200003];
long sum(int a) {return (a)? ft[a] + sum(a-(a&-a)) : 0; }
long sum(int a, int b) {return (a > b)? 0 : sum(b)-sum(a-1); }
void update(int a, long val) {for(; a <= n; a += (a&-a)) ft[a] += val; }

long ftk[20003][2];
long sumk(int a, int tipe) {return (a)? (ftk[a][tipe] + sumk(a-(a&-a), tipe))%MOD : 0; }
long sumk(int a, int b, int tipe) { return (a > b)? 0 : sumk(b,tipe)-sumk(a-1,tipe); }
void updatek(int a, long val, int tipe) {for(; a <= n; a += (a&-a)) ftk[a][tipe] = (ftk[a][tipe]+val)%MOD; }

int binser(int l, int r, int x)
{
	int iki = l, ika = r;
	while(iki < ika)
	{
		int imi = (1+iki+ika)/2;
		if(A[imi] > x) ika = imi-1;
		else iki = imi;
	}
	return iki;
}

bool cek(int l, int r, int x)
{
	int idx = binser(l, r, x);
	return sum(l,idx) <= sum(idx+1,r);
}

int main()
{
	// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);

	scanf("%d %d", &n, &q);
	for(int i = 1; i <= n; i++) scanf("%lld", &A[i]);
	for(int i = 1; i <= n; i++) scanf("%lld", &W[i]);
	for(int i = 1; i <= n; i++)
	{
		update(i, W[i]);
		updatek(i, ((A[i]-i)*W[i])%MOD, 0);
		updatek(i, ((-A[i]+i+BIG)*W[i])%MOD, 1);
	}
	// for(int i = 1; i <= n; i++) { printf("%lld ", sumk(i,i,0)); } printf("\n");
	while(q--)
	{
		int l, r;
		scanf("%d %d", &l, &r);
		if(l < 0)
		{
			l = -l;
			update(l, -W[l]);
			updatek(l, -((A[l]-l)*W[l])%MOD, 0);
			updatek(l, -((-A[l]+l+BIG)*W[l])%MOD, 1);
			W[l] = r;
			update(l, W[l]);
			updatek(l, ((A[l]-l)*W[l])%MOD, 0);
			updatek(l, ((-A[l]+l+BIG)*W[l])%MOD, 1);
		}
		else
		{
			long kir = A[l], kan = A[r];
			while(kir < kan)
			{
				long mid = (1+kir+kan)/2;
				if(!cek(l,r,mid)) kan = mid-1;
				else kir = mid;
			}
			int idx = binser(l,r,kir);
			long res = 0;
			res += (sumk(l,idx,1) - ((BIG+idx-kir)*(sum(l,idx)%MOD))%MOD)%MOD;
			res += (sumk(idx+1,r,0) - ((kir-idx)*(sum(idx+1,r)%MOD))%MOD)%MOD;
			res %= MOD;
			// printf("%lld %d %lld ", kir, idx, sumk(l,idx,1));
			printf("%lld\n", (res%MOD+MOD)%MOD);

		}
	}

}

#include <bits/stdc++.h>
using namespace std;
const int N = 200005,P = 1000000007;
using ll = long long;
int n,q,a[N],w[N];
struct BIT
{
    ll c[N];bool mod;
    inline static int lowbit(int x) {return x & -x;}
    void add(int x,ll val)
    {
        while (x <= n)
        {
            c[x] += val;if (mod) c[x] %= P;
            x += lowbit(x);
        }
    }
    ll query(int x)
    {
        ll ret = 0;
        while (x) ret += c[x],x -= lowbit(x);
        return mod ? ret % P : ret;
    }
    inline ll query(int x,int y) {return query(y) - query(x - 1);}
} ta,tb;
int getpos(int l,int r)
{
    int ans = l,lp = l;ll t = ta.query(l,r);
    while (l <= r)
    {
        int mid = (l + r) >> 1;
        if (ta.query(lp,mid) > t / 2) ans = mid,r = mid - 1;
        else l = mid + 1;
    }
    return ans;
}
int main ()
{
    ios::sync_with_stdio(false);
    cin >> n >> q;
    for (int i = 1;i <= n;i++) cin >> a[i];
    for (int i = 1;i <= n;i++) cin >> w[i];
    ta.mod = 0;tb.mod = 1;
    for (int i = 1;i <= n;i++)
    {
        a[i] -= i;ta.add(i,w[i]);tb.add(i,a[i] * w[i] % P);
    }
    for (int _ = 0;_ < q;_++)
    {
        int t1,t2;cin >> t1 >> t2;
        if (t1 < 0)
        {
            t1 = -t1;ta.add(t1,-w[t1]);tb.add(t1,a[t1] * -w[t1] % P);
            ta.add(t1,w[t1] = t2);tb.add(t1,a[t1] * w[t1] % P);
        }
        else
        {
            int k = getpos(t1,t2);
            ll ans = (ta.query(t1,k) % P * a[k] % P - tb.query(t1,k)) % P
            + (tb.query(k,t2) - ta.query(k,t2) % P * a[k] % P) % P;
            ans = (ans % P + P) % P;
            cout << ans << endl;
        }
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int maxn=212345;
const long long mod=1e9+7;
int n,q,w[maxn],a[maxn];
long long bit1[maxn],bit2[maxn];
long double bit11[maxn],bit22[maxn];
inline void update(long long *bit,int x,long long v,bool flag=false) {
    if (flag) v=(v%mod+mod)%mod;
    while (x<=n) {
        bit[x]+=v;
        if (flag) bit[x]%=mod;
        x+=x&-x;
    }
}
inline long long sum(long long *bit,int x,bool flag=false) {
    long long ret=0;
    while (x) {
        ret+=bit[x];
        if (flag) ret%=mod;
        x-=x&-x;
    }
    return ret;
}
inline void update(long double *bit,int x,long long v) {
    while (x<=n) {
        bit[x]+=v;
        x+=x&-x;
    }
}
inline long double sum(long double *bit,int x) {
    long double ret=0;
    while (x) {
        ret+=bit[x];
        x-=x&-x;
    }
    return ret;
}
inline long long getans(int x,int y,int res) {
    long long sum1=(sum(bit1,res)-sum(bit1,x-1))%mod*a[res]%mod-(sum(bit2,res,true)-sum(bit2,x-1,true))%mod;
    long long sum2=(sum(bit2,y,true)-sum(bit2,res,true))%mod-(sum(bit1,y)-sum(bit1,res))%mod*a[res]%mod;
    return ((sum1+sum2)%mod+mod)%mod;
}
inline long double getcost(int x,int y,int res) {
    //printf("x=%d y=%d res=%d\n",x,y,res);
    long double sum1=(sum(bit11,res)-sum(bit11,x-1))*a[res]-sum(bit22,res)-sum(bit22,x-1);
    long double sum2=sum(bit22,y)-sum(bit22,res)-(sum(bit11,y)-sum(bit11,res))*a[res];
    return sum1+sum2;
}
inline int getpos(int left,int right) {
    long double l=left,r=right;
    for (int i=0;r-l>0.5;++i) {
        long double mid=l+(r-l)/3,midmid=l+2*(r-l)/3;
        long double cost1=min(getcost(left,right,(int)ceil(mid)),getcost(left,right,(int)floor(mid)));
        long double cost2=min(getcost(left,right,(int)ceil(midmid)),getcost(left,right,(int)floor(midmid)));
        if (cost1>=cost2) l=mid;
        else r=midmid;
    }
    long double pos=(l+r)/2.0;
    //printf("%.12f\n",(double)pos);
    long double cost1=getcost(left,right,(int)ceil(pos));
    long double cost2=getcost(left,right,(int)floor(pos));
    //printf("%.12f %.12f\n",(double)cost1,(double)cost2);
    if (cost1<=cost2) return (int)ceil(pos);
    return (int)floor(pos);
}
int main()
{
    scanf("%d%d",&n,&q);
    for (int i=1;i<=n;++i) scanf("%d",&a[i]),a[i]-=i;
    for (int i=1;i<=n;++i) {
        scanf("%d",&w[i]);
        update(bit1,i,w[i]);
        update(bit2,i,1LL*a[i]*w[i]%mod,true);
        update(bit11,i,w[i]);
        update(bit22,i,1.0*a[i]*w[i]);
    }
    while (q--) {
        int x,y;scanf("%d%d",&x,&y);
        if (x<0) {
            x=-x;
            update(bit1,x,y-w[x]);
            update(bit2,x,1LL*a[x]*(y-w[x])%mod,true);
            update(bit11,x,y-w[x]);
            update(bit22,x,1.0*a[x]*(y-w[x]));
            w[x]=y;
        } else {
            if (x==y) {
                puts("0");
                continue;
            }
            int res=getpos(x,y);
            /*
            int left=x,right=y,resres=x;
            long long rev=sum(bit1,x-1);
            long long tot=sum(bit1,y)-rev;
            tot=(tot+1)>>1;
            while (left<=right) {
                int mid=(left+right)>>1;
                if (sum(bit1,mid-1)-rev<tot) {
                    resres=mid;
                    left=mid+1;
                } else right=mid-1;
            }
            printf("resres=%d res=%d\n",resres,res);
            printf("%f %f %d\n",(double)getcost(x,y,1),(double)getcost(x,y,2),getcost(x,y,1)>getcost(x,y,2));
            */
            printf("%I64d\n",getans(x,y,res));
        }
    }
    return 0;
}
/*
3 3
351772224 464078370 812738126
149252109 153315732 540915058
1 2
-3 861733588
-1 190898187
*/

#include <iostream>
#define maxn 400000
#define mod 1000000007
using namespace std;
long long n,q,a[maxn],w[maxn],t1[maxn],t2[maxn];
void build(long long left,long long right,long long p)
{
	if(left==right)
	{
		t1[p]=w[left];
		t2[p]=w[left]*(left-a[left]);
		return;
	}
	long long mid=(left+right)>>1;
	build(left,mid,p*2);
	build(mid+1,right,p*2+1);
	t1[p]=t1[p*2]+t1[p*2+1];
	t2[p]=t2[p*2]+t2[p*2+1];
	t2[p]%=mod;
}
void update1(long long left,long long right,long long q,long long p,long long c)
{
	if(left>q||right<q)
	{
		return;
	}
	if(left==right)
	{
		t1[p]+=c;
		return;
	}
	long long mid=(left+right)>>1;
	update1(left,mid,q,p*2,c);
	update1(mid+1,right,q,p*2+1,c);
	t1[p]=t1[p*2]+t1[p*2+1];
}
void update2(long long left,long long right,long long q,long long p,long long c)
{
	if(left>q||right<q)
	{
		return;
	}
	if(left==right)
	{
		t2[p]+=c*(q-a[q]);
		t2[p]%=mod;
		return;
	}
	long long mid=(left+right)>>1;
	update2(left,mid,q,p*2,c);
	update2(mid+1,right,q,p*2+1,c);
	t2[p]=t2[p*2]+t2[p*2+1];
	t2[p]%=mod;
}
long long query1(long long left,long long right,long long ql,long long qr,long long p)
{
	if(left>=ql&&right<=qr)
	{
		return t1[p];
	}
	if(left>qr||right<ql)
	{
		return 0;
	}
	long long mid=(left+right)>>1;
	return query1(left,mid,ql,qr,p*2)+query1(mid+1,right,ql,qr,p*2+1);
}
long long query2(long long left,long long right,long long ql,long long qr,long long p)
{
	if(left>=ql&&right<=qr)
	{
		return t2[p];
	}
	if(left>qr||right<ql)
	{
		return 0;
	}
	long long mid=(left+right)>>1;
	return (query2(left,mid,ql,qr,p*2)+query2(mid+1,right,ql,qr,p*2+1))%mod;
}
int main()
{
	cin>>n>>q;
	for(long long i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(long long i=1;i<=n;i++)
	{
		cin>>w[i];
	}
	build(1,n,1);
	while(q--)
	{
		long long x,y;
		cin>>x>>y;
		if(x<0)
		{
			x=-x;
			update1(1,n,x,1,y-w[x]);
			update2(1,n,x,1,y-w[x]);
			w[x]=y;
//			for(long long i=1;i<=n;i++)
//			{
//				cout<<w[i]<<' ';
//			}
//			cout<<endl;
//			for(long long i=1;i<=4*n;i++)
//			{
//				cout<<t1[i]<<' ';
//			}
//			cout<<endl;
		}
		else
		{
			long long l=1,r=n;
			while(l<=r)
			{
				long long mid=(l+r)>>1;
//				cout<<mid<<":"<<query1(1,n,x,mid-1,1)<<' '<<query1(1,n,mid+1,y,1)<<endl;
				if(query1(1,n,x,mid-1,1)<query1(1,n,mid+1,y,1))
				{
					l=mid+1;
				}
				else r=mid-1;
			}
//			cout<<query1(1,n,1,n,1)<<endl;
//			cout<<query1(1,n,x,l-1,1)<<' '<<a[l]-l<<' '<<query2(1,n,x,l-1,1)<<' '<<query1(1,n,l+1,y,1)<<' '<<l-a[l]<<' '<<query2(1,n,l+1,y,1)<<endl;
			long long ans=(query1(1,n,x,l-1,1)*(a[l]-l))%mod+query2(1,n,x,l-1,1)+(query1(1,n,l+1,y,1)*(l-a[l]))%mod-query2(1,n,l+1,y,1);
			l--;
			ans=min(ans,(query1(1,n,x,l-1,1)*(a[l]-l))%mod+query2(1,n,x,l-1,1)+(query1(1,n,l+1,y,1)*(l-a[l]))%mod-query2(1,n,l+1,y,1));
			cout<<(ans+mod)%mod<<endl;
		}
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

template<typename T>
struct SegmentTree{
    using F=function<T(T,T)>;

    int n;
    vector<T> dat;
    F f;
    T ti;

    SegmentTree(int n_ ,F f ,T ti) :f(f),ti(ti){
        n=1;
        while(n<n_) n*=2;
        dat.assign(2*n-1,ti);
    }

    SegmentTree(int n_ ,vector<T> &v ,F f,T ti) :f(f),ti(ti){
        n=1;
        while(n<n_) n*=2;
        dat.assign(2*n-1,ti);

        for(int i=n-1;i-(n-1)<v.size();i++) dat[i]=v[i-(n-1)];

        for(int i=n-2;i>=0;i--) dat[i]=f(dat[i*2+1],dat[i*2+2]);
    }

    void update(int k,T x){
        k+=n-1;
        dat[k]=x;

        while(k){
            k=(k-1)/2;
            dat[k]=f(dat[k*2+1],dat[k*2+2]);
        }
    }

    void set(int k,T x){
        dat[n-1+k]=x;
    }

    void built(){
        for(int i=n-2;i>=0;i--) dat[i]=f(dat[i*2+1],dat[i*2+2]);
    }

    T query_(int a,int b,int k,int l,int r){
        if(r<=a||b<=l) return ti;
        if(a<=l&&r<=b) return dat[k];
        else{
            T vl=query_(a,b,2*k+1,l,(l+r)/2);
            T vr=query_(a,b,2*k+2,(l+r)/2,r);
            return f(vl,vr);
        }
    }

    T query(int a,int b){
        return query_(a,b,0,0,n);
    }

    T get(int k){
        return dat[k+n-1];
    }

    template<typename C>
    int findright(int st,C &check,T &acc,int k,int l,int r){
        if(l+1==r){
            acc=f(acc,dat[k]);
            return check(acc)?k-(n-1):-1;
        }
        int m=(l+r)/2;
        if(m<=st) return findright(st,check,acc,2*k+2,m,r);
        if(st<=l&&!check(f(acc,dat[k]))){
            acc=f(acc,dat[k]);
            return -1;
        }
        int vl=findright(st,check,acc,2*k+1,l,m);
        if(~vl) return vl;
        return findright(st,check,acc,2*k+2,m,r);
    }

    template<typename C>
    int findright(int st,C &check){
        T acc=ti;
        return findright(st,check,acc,0,0,n);
    }//条件を満たす最小のidxを返す

    template<typename C>
    int findleft(int st,C &check,T &acc,int k,int l,int r){
        if(l+1==r){
            acc=f(acc,dat[k]);
            return check(acc)?k-(n-1):INF;
        }
        int m=(l+r)/2;
        if(m>=st) return findleft(st,check,acc,2*k+1,l,m);
        if(st>=r&&!check(f(acc,dat[k]))){
            acc=f(acc,dat[k]);
            return INF;
        }
        int vr=findleft(st,check,acc,2*k+2,m,r);
        if(vr!=INF) return vr;
        return findleft(st,check,acc,2*k+1,l,m);
    }

    template<typename C>
    int findleft(int st,C &check){
        T acc=ti;
        return findleft(st,check,acc,0,0,n);
    }//条件を満たす最大のidxを返す

};

int main(){

    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N,Q;cin>>N>>Q;
    vector<double> pos(N);
    vector<ll> w(N);

    for(int i=0;i<N;i++){
        cin>>pos[i];
        pos[i]-=i;
    }

    for(int i=0;i<N;i++){
        cin>>w[i];
    }

    SegmentTree<pair<ll,ll>> seg(N,
                                 [](pair<ll,ll> a,pair<ll,ll> b){return mp(a.fi+b.fi,a.se+b.se);},
                                 mp(0,0));

    SegmentTree<ll> wsum(N,
                         w,
                         [](ll a,ll b){return a+b;},
                         0);

    for(int i=0;i<N;i++){
        seg.update(i,mp(w[i]*pos[i],w[i]*(1000000000LL-pos[i])));
    }

    while(Q--){
        ll l,r;cin>>l>>r;
        if(l<0){
            l*=-1;
            l--;
            seg.update(l,mp(r*pos[l],r*(1000000000LL-pos[l])));
            wsum.update(l,r);
        }else{
            l--;
            r--;

            double lpos=pos[l],rpos=pos[r];

            for(int k=0;k<50;k++){
                double c1=(lpos*2+rpos)/3.0,c2=(lpos+rpos*2)/3.0;

                int d1=lower_bound(all(pos),c1)-pos.begin(),d2=lower_bound(all(pos),c2)-pos.begin();

                double lsum1=0,rsum1=0,lsum2=0,rsum2=0;

                lsum1+=double(seg.query(l,d1).se)-double(wsum.query(l,d1))*(1000000000LL-c1);
                rsum1+=double(seg.query(d1,r+1).fi)-double(wsum.query(d1,r+1))*c1;

                lsum2+=double(seg.query(l,d2).se)-double(wsum.query(l,d2))*(1000000000LL-c2);
                rsum2+=double(seg.query(d2,r+1).fi)-double(wsum.query(d2,r+1))*c2;

                if(lsum1+rsum1<=lsum2+rsum2) rpos=c2;
                else lpos=c1;
            }

            ll ans=1LL<<62;

            for(ll p=max(pos[0],lpos-1.0);p<=min(pos[N-1],lpos+1.0);p++){
                int d=lower_bound(all(pos),p)-pos.begin();

                ll lsum=0,rsum=0;

                lsum+=seg.query(l,d).se-wsum.query(l,d)*(1000000000LL-p);
                rsum+=seg.query(d,r+1).fi-wsum.query(d,r+1)*p;

                ll sum=lsum+rsum;

                chmin(ans,sum);
            }

            cout<<ans<<endl;
        }
    }
}

#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 200000;
const int MOD = 1000000007;

int a[1+MAX_N+1];
int w[1+MAX_N+1];

template<int n, typename T, typename Updater>
class Aint {
private:
	T neutralQry, initval;
	T *aint;
	Updater upd;
public:
	Aint(T _neutralQry, T _initval) {
		initval = _initval;
		neutralQry = _neutralQry;

		aint = new T[1 + 4 * n];

		for(int i = 0; i <= 4 * n; ++i)
			aint[i] = initval;
	}
	void update(int poz, T val, int nod = 1, int l = 1, int r = n) {
		if(poz < l || r < poz)
			return ;
		if(l == r && l == poz)
			aint[nod] = upd.update(aint[nod], val);

		int mid = (l + r) / 2;
		if(l < r) {
			update(poz, val, 2 * nod, l, mid);
			update(poz, val, 2 * nod + 1, mid + 1, r);
			aint[nod] = upd.query(aint[2 * nod], aint[2 * nod + 1]);
		}
	}
	T query(int i, int j, int nod = 1, int l = 1, int r = n) {
		if(r < i || j < l || r < l)
			return neutralQry;
		if(i <= l && r <= j)
			return aint[nod];
		int mid = (l + r) / 2;
		return upd.query(query(i, j, 2 * nod, l, mid),
		                 query(i, j, 2 * nod + 1, mid + 1, r));
	}
	void debug(int nod = 1, int l = 1, int r = n) {
		printf("[%d %d]->%d %d %d %d %lld\n", l, r,
		aint[nod].l, aint[nod].r, aint[nod].cost1, aint[nod].cost2, aint[nod].weight);
		int mid = (l + r) / 2;
		if(l < r) {
			debug(2 * nod, l, mid);
			debug(2 * nod + 1, mid + 1, r);
		}
	}
};

struct Cell {
	int l, r, cost1, cost2;
	long long weight;
};

struct Combiner {
	Cell query(Cell ax, Cell bx) {
		if(ax.l == MAX_N+1)
			return bx;
		else if(bx.l == MAX_N+1)
			return ax;
		Cell rez;
		rez.l = min(ax.l, bx.l);
		rez.r = max(ax.r, bx.r);

		rez.cost1 = (ax.cost1 + bx.cost1) % MOD;
		rez.cost2 = (ax.cost2 + bx.cost2) % MOD;
		int dist = a[bx.r] - a[ax.l] + 1 - (ax.r - ax.l + 1) - (bx.r - bx.l + 1);

		rez.cost1 = ((long long)ax.weight % MOD * dist + rez.cost1) % MOD;
		rez.cost2 = ((long long)bx.weight % MOD * dist + rez.cost2) % MOD;
		rez.weight = ax.weight + bx.weight;
		return rez;
	}
	Cell update(Cell a, Cell b) {
		return b;
	}
};

Aint<MAX_N, Cell, Combiner> aint({MAX_N+1, 0, 0, 0, 0}, {MAX_N+1, 0, 0, 0, 0});

int main() {
#ifdef HOME
	FILE *fin = fopen("input.in", "r");
	FILE *fout = fopen("output.out", "w");
#else
	FILE *fin = stdin;
	FILE *fout = stdout;
#endif

	int n, q;

	fscanf(fin, "%d%d", &n, &q);
	for(int i = 1; i <= n; ++i) {
		fscanf(fin, "%d", &a[i]);
	}
	for(int i = 1; i <= n; ++i) {
		fscanf(fin, "%d", &w[i]);
		aint.update(i, {i, i, 0, 0, w[i]});
	}
	for(int i = 0; i < q; ++i) {
		int x, y;
		fscanf(fin, "%d%d", &x, &y);
		if(x < 0) {
			x = -x;
			w[x] = y;
			aint.update(x, {x, x, 0, 0, w[x]});
		} else {
			int st = x - 1, dr = y;
			while(dr - st > 1) {
				int mid = (st + dr) / 2;
				long long cost = aint.query(x, mid).weight -
				                 aint.query(mid + 1, y).weight;
				if(cost <= 0)
					st = mid;
				else
					dr = mid;
			}
			int rez = dr;
			Cell leftCell = aint.query(x, rez - 1), rightCell = aint.query(rez + 1, y);
			int finalRez = 0;
			if(leftCell.l != MAX_N+1) {
				finalRez = ((long long)leftCell.weight % MOD * (a[rez] - a[rez - 1] - 1) + finalRez) % MOD;
				finalRez = (finalRez + leftCell.cost1) % MOD;
			}
			if(rightCell.l != MAX_N+1) {
				finalRez = ((long long)rightCell.weight % MOD * (a[rez + 1] - a[rez] - 1) + finalRez) % MOD;
				finalRez = (finalRez + rightCell.cost2) % MOD;
			}
			fprintf(fout, "%d\n", finalRez);
		}
	}

#ifdef HOME
	fclose(fin);
	fclose(fout);
#endif
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

const int MAXN = 200005;
const int S = 450;
const int MOD = 1e9 + 7;
const int INF = 1 << 30;

inline void add(int &a, int b)
{
	a += b;
	if (a >= MOD) a -= MOD;
}

inline void mul(int &a, int b)
{
	a = (long long)a * b % MOD;
}

struct Block
{
	int sum, movel, mover, l, r;
}b[S + 10];

long long sum_prev[MAXN];

int a[MAXN], w[MAXN];

int n, q, x, y;

#define SUM(x) (x < 0 ? 0 : sum_prev[x])

int calc(int l, int r)
{
	int x = l, y = r;
//	cout << "(" << l << "," << r << ")" << endl;
	while (l < r)
	{
		int mid = (l + r) >> 1;
		if (SUM(mid) - SUM(x - 1) >= SUM(y) - SUM(mid))
			r = mid;
		else
			l = mid + 1;
//		cout << (SUM(mid) - SUM(x - 1)) << " <-> " << SUM(y) - SUM(mid) << endl;
//		cout << "(" << l << "," << r << ")" << endl;
	}
	return l;
}

int main()
{
	scanf("%d%d", &n, &q);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (int i = 0; i < n; i++)
		scanf("%d", &w[i]);
	a[n] = INF;
	sum_prev[0] = w[0];
	for (int i = 1; i < n; i++)
		sum_prev[i] = w[i] + sum_prev[i - 1];
	for (int i = 0; i < n; i++)
		add(b[i / S].sum, w[i]);
	for (int i = 0; i < n; i++)
	{
		int l = i, r = i, id = i / S;
		while (id == (r + 1) / S && r + 1 < n)
			++r;
		for (int j = l; j <= r; j++)
			add(b[id].movel, (long long)(a[j] - a[l] - (j - l)) * w[j] % MOD);
		for (int j = r; j >= l; j--)
			add(b[id].mover, (long long)(a[r] - a[j] - (r - j)) * w[j] % MOD);
		b[id].l = l, b[id].r = r;
		i = r;
	}
	for (int i = 1; i <= q; i++)
	{
		scanf("%d%d", &x, &y);
		if (x < 0)
		{
			x = -x;
			--x;
			int id = x / S, l = b[id].l, r = b[id].r;
			add(b[id].sum, (y - w[x] + MOD) % MOD);
			add(b[id].movel, MOD - (long long)(a[x] - a[l] - (x - l)) * w[x] % MOD);
			add(b[id].movel, (long long)(a[x] - a[l] - (x - l)) * y % MOD);
			add(b[id].mover, MOD - (long long)(a[r] - a[x] - (r - x)) * w[x] % MOD);
			add(b[id].mover, (long long)(a[r] - a[x] - (r - x)) * y % MOD);
			w[x] = y;
		}
		else
		{
			if (x == y)
			{
				printf("0\n");
				continue;
			}
			--x, --y;
			int L = x, R = y, M = calc(L, R);
			int idl = L / S, idm = M / S, idr = R / S, res = 0, d = max(L, b[idm].l), u = min(R, b[idm].r);
			for (int j = M - 1; j >= d; j--)
				add(res, (long long)(a[M] - a[j] - (M - j)) * w[j] % MOD);
			for (int j = M + 1; j <= u; j++)
				add(res, (long long)(a[j] - a[M] - (j - M)) * w[j] % MOD);
			for (int j = idm - 1; j > idl; j--)
			{
				int x = b[j].r;
				add(res, ((long long)((a[M] - M) - (a[x] - x)) * b[j].sum % MOD + b[j].mover) % MOD);
			}
			for (int j = idm + 1; j < idr; j++)
			{
				int x = b[j].l;
				add(res, ((long long)((a[x] - x) - (a[M] - M)) * b[j].sum % MOD + b[j].movel) % MOD);
			}
			if (idl != idm)
				for (int j = b[idl].r; j >= L; j--)
					add(res, (long long)((a[M] - M) - (a[j] - j)) * w[j] % MOD);
			if (idr != idm)
				for (int j = b[idr].l; j <= R; j++)
					add(res, (long long)((a[j] - j) - (a[M] - M)) * w[j] % MOD);
			printf("%d\n", res);
		}
	}
	return 0;
}

/**
 * Author: houtaruijika
 * Create: 2018.09.25 16:18:11
 */
#include <bits/stdc++.h>

using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORD(i, b, a) for (int i = b; i >= a; --i)

const int maxn = 2e5 + 10;
const int MOD = 1e9 + 7;

int n, q;
int a[maxn], w[maxn];
long long tW[maxn], tAw[maxn];

void updateW(int x, int delta) {
    for (; x < maxn; x += x & -x) tW[x] += delta;
}

long long getW(int x, int y) {
    long long res = 0;
    for (; y > 0; y -= y & -y) res += tW[y];
    x--;
    for (; x > 0; x -= x & -x) res -= tW[x];
    return res;
}

void updateAw(int x, long long delta) {
    for (; x < maxn; x += x & -x) tAw[x] += delta;
}

long long getAw(int x, int y) {
    long long res = 0;
    for (; y > 0; y -= y & -y) res = (res + tAw[y]) % MOD;
    x--;
    for (; x > 0; x -= x & -x) res = (res - tAw[x] + MOD) % MOD;
    return res;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> q;
    FOR(i, 1, n) cin >> a[i], a[i] -= i;
    FOR(i, 1, n) cin >> w[i];

    FOR(i, 1, n) {
        updateW(i, w[i]);
        updateAw(i, 1ll * w[i] * a[i] % MOD);
    }

    while (q--) {
        int x, y; cin >> x >> y;
        if (x < 0) {
            x = -x;
            updateW(x, -w[x]);
            updateAw(x, (-1ll * w[x] * a[x] % MOD + MOD) % MOD);
            w[x] = y;
            updateW(x, w[x]);
            updateAw(x, 1ll * w[x] * a[x] % MOD);
        } else {
            int l = x, r = y, k = y; long long s = getW(x, y);
            while (l <= r) {
                int m = (l + r) >> 1;
                if (getW(x, m) * 2 >= s) {
                    k = m; r = m - 1;
                } else {
                    l = m + 1;
                }
            }
            long long lo = (1ll * a[k] * getW(x, k) % MOD - getAw(x, k) % MOD + MOD) % MOD;
            long long hi = (getAw(k + 1, y) % MOD - 1ll * a[k] * getW(k + 1, y) % MOD + MOD) % MOD;
            cout << lo + hi << "\n";
        }
    }
    return 0;
}

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <regex> //for __gcd

#define ul unsigned long long
#define ll long long
#define fastio ios_base :: sync_with_stdio(false), cin.tie(0), cout.tie(0)

using namespace std;

void println(vector<int> v) {
    for (int c: v) {
        cout << c << " ";
    }
    cout << endl;
}

void println(vector<ul> v) {
    for (ul c: v) {
        cout << c << " ";
    }
    cout << endl;
}

int main() {
//#ifndef NDEBUG
//    freopen("input.txt", "r", stdin);
//#endif // DEBUG
    fastio;
    int n, q;
    cin >> n >> q;

    vector<int> weight(n + 1);
    vector<int> position(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> position[i];
    }
    for (int i = 1; i <= n; ++i) {
        cin >> weight[i];
    }

    vector<int> dyrok(n + 1);
    vector<ul> summWeight(n + 1);
    for (int i = 1; i <= n; ++i) {
        summWeight[i] = summWeight[i - 1] + weight[i];
    }
    for (int i = 1; i < n; ++i) {
        dyrok[i] = position[i + 1] - position[i] - 1;
    }

    function solve = [&](int left, int right) {
        const int mod = 1000000007;
        ul total = 0;
        for (int x = left; x < right; x++) {
            if (dyrok[x] == 0) continue;
            ul leftWeigth = summWeight[x] - summWeight[left] + weight[left];
            ul rightWeigth = summWeight[right] - summWeight[x];
            ul delta = min(leftWeigth, rightWeigth) * dyrok[x];
            total += delta % mod;
        }
        return total;
    };

    for (int j = 0; j < q; ++j) {
        int x, y;
        cin >> x >> y;
        if (x < 0) {
            int pos = -x;
            int delta = y - weight[pos];
            weight[pos] = y;
            for (int i = pos; i <= n; ++i) {
                summWeight[i] += delta;
            }
        } else {
            cout << solve(x, y) << endl;
        }
    }
}

#include <bits/stdc++.h>

using namespace std;

const long long mod = 1e9 + 7;

int n, q, i, j, l, mid, r;
long long a[200010], w[200010];

////////////////////////// PARTEA I - simple partial sums on weight
long long aibpart[200010];
long long part(int poz)
{
    long long ret = 0LL;
    for(;poz;poz-=poz&-poz)
        ret = ret + aibpart[poz] ;
    return ret;
}
void updpart(int poz, int val)
{
    for(;poz<=n;poz+=poz&-poz)
        aibpart[poz] += val;
    return ;
}
//////////////////////////

////////////////////////// PARTEA II - simple partial sums on products between weight and position
long long aibprodus[200010];
int produs(int poz)
{
    int ret = 0;
    for(;poz;poz-=poz&-poz)
    {
        ret = ret + aibprodus[poz] ;
        ret = ( ret > mod ) ? ret - mod : ret ;
    }
    return ret;
}
void updprodus(int poz, int val)
{
    for(;poz<=n;poz+=poz&-poz)
        aibprodus[poz] = ( aibprodus[poz] + val >= mod ) ? aibprodus[poz] + val - mod : aibprodus[poz] + val ;
    return ;
}
//////////////////////////

////////////////////////// PARTEA III - first grade function
long long aibA[200010], aibB[200010], aibretard[200010];
int getA(int poz)
{
    int ret = 0;
    for(;poz;poz-=poz&-poz)
    {
        ret = ret + aibA[poz] ;
        ret = ( ret > mod ) ? ret - mod : ret ;
    }
    return ret;
}
void updA(int poz,long long val)
{
    for(;poz<=n;poz+=poz&-poz)
        aibA[poz] = ( aibA[poz] + val >= mod ) ? aibA[poz] + val - mod : aibA[poz] + val ;
    return ;
}

int getB(int poz)
{
    int ret = 0;
    for(;poz;poz-=poz&-poz)
    {
        ret = ret + aibB[poz] ;
        ret = ( ret > mod ) ? ret - mod : ret ;
    }
    return ret;
}
void updB(int poz,long long val)
{
    for(;poz<=n;poz+=poz&-poz)
        aibB[poz] = ( aibB[poz] + val >= mod ) ? aibB[poz] + val - mod : aibB[poz] + val ;
    return ;
}

int getthird(int poz)
{
    long long ret = ( getA(poz) * poz + getB(poz) ) % mod ;
    return ( ret < 0 ) ? ret + mod : ret ;
}

void updretard(int poz,int val)
{
    for(;poz<=n;poz+=poz&-poz)
        aibretard[poz] = ( aibretard[poz] + val >= mod ) ? aibretard[poz] + val - mod : aibretard[poz] + val;
    return ;
}
int retard(int poz)
{
    int ret = 0;
    for(;poz;poz-=poz&-poz)
        ret = ( ret + aibretard[poz] >= mod ) ? ret + aibretard[poz] - mod : ret + aibretard[poz];
    return ret;
}
//////////////////////////

int main()
{
    cin>>n>>q;
    for(i=1;i<=n;i++) cin >> a[i];
    for(i=1;i<=n;i++)
    {
        cin >> w[i];
        updpart   ( i , w[i] );
        updprodus ( i , ( w[i] * a[i] ) % mod );
        updA      ( i , w[i] );
        long long aux = ( w[i] * ( 1 - i ) ) % mod ;
        aux = ( aux < 0 ) ? aux + mod : aux ;
        updB      ( i , aux );
        updretard ( i , ( w[i] * i ) % mod );
    }

    for(;q;q--)
    {
        cin >> l >> r;

        if( l < 0 )
        {
            l = -l;
            long long dif = ( r - w[l] < 0 ) ? r - w[l] + mod : r - w[l] ;
            updpart   ( l , dif );
            updprodus ( l , ( dif * a[l] ) % mod );
            updA      ( l , dif );
            long long aux = ( dif * ( 1 - l ) ) % mod ;
            aux = ( aux < 0 ) ? aux + mod : aux ;
            updB      ( l , aux );
            updretard ( l , ( dif * l ) % mod );
            w[l] = r;
            continue ;
        }

        int laux=l, raux=r;long long L=part(l-1);long long total=part(r)-L;
        while( laux < raux )
        {
            mid = ( laux + raux ) / 2;
            if( ( part(mid) - L ) * 2 < total )
                laux = mid + 1;
            else
                raux = mid;
        }
        mid = laux;
        long long ans = 0;
//        for(j=l;j<mid;j++)    ans = ( ans + ( a[mid] - a[j] - ( mid - j ) ) * w[j] ) % mod;
//        for(j=mid+1;j<=r;j++) ans = ( ans + ( a[j] - a[mid] - ( j - mid ) ) * w[j] ) % mod;
//        cout << "ACTUAL ANSWER: " << ans << '\n';
//
//        cout << "MIDDLE : " << mid << '\n';
//        cout << "WEIGHTS: ";for(j=1;j<=n;j++) cout << part(j)-part(j-1) << ' ';cout<<'\n';
//        cout << "POSES  : ";for(j=1;j<=n;j++) cout << a[j] << ' ';cout<<'\n';
//        cout << "PRODUSE: ";for(j=1;j<=n;j++) cout << (produs(j)-produs(j-1)+mod)%mod << ' ';cout<<'\n';
//        cout << "A & B  : ";for(j=1;j<=n;j++) cout << getthird(j) << ' ';cout<<'\n';

        ans = 0LL;
////////////////////////// PARTEA I
        ans = ( ans + a[mid] * ( ( part(mid-1) - part(l-1) ) % mod ) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans ;

        ans = ( ans - a[mid] * ( ( part(r)   -   part(mid) ) % mod ) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans ;
        //cout << " PARTEA I: " << ans << '\n';

        //ans = 0LL;
////////////////////////// PARTEA II
        ans = ( ans - ( produs(mid-1) - produs (l-1) ) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans ;

        ans = ( ans + ( produs(r) - produs(mid) ) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans ;
        //cout << " PARTEA II: " << ans << '\n';

        //ans = 0LL;
////////////////////////// PARTEA III
        ans = ( ans - getthird(mid-1) );
        ans = ( ans < 0 ) ? ans + mod : ans;
        ans = ( ans  +  getthird(l-1) );
        ans = ( ans < 0 ) ? ans + mod : ans;
        ans = ( ans  + ( ( mid - l ) * part(l-1) ) % mod ) % mod;

        //cout << " PARTEA III a: " << ans << '\n';

        //ans = 0LL;

        ans = ( ans - retard(r) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans;
        ans = ( ans + retard (mid) ) % mod;
        if(mid!=r)ans = ( ans + mid * ( part(r) - part(mid) ) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans;

        //cout << " PARTEA III b: " << ans << '\n';
        cout << ans << '\n';
    }
    return 0;
}

#include<cstdio>
#define mo 1000000007
using namespace std;
using LL=long long;

struct Finwick
{
	int n,logn;
	LL C[200005];

	void init(int x)
	{
		logn=sizeof(int)*8-__builtin_clz(n=x)-1;
	}

	LL sum(int x, int o=0)
	{
		LL res=0;
		while(x)
		{
			res+=C[x],x-=x&-x;
			if(o)
				res%=mo;
		}
		return res;
	}

	void add(int x, LL d, int o=0)
	{
		while(x<=n)
		{
			C[x]+=d,x+=x&-x;
			if(o)
				C[x]%=mo;
		}
	}

	int lower_bound(LL v)
	{
		LL sum=0;
		int pos=0;
		for(int i=logn;i>=0;i--)
			if((pos|1<<i)<=n&&sum+C[pos|1<<i]<v)
				sum+=C[pos|=1<<i];
		return pos+1;
	}
}F,H;

int n,q,pos,x,y;
LL ans,w[200005],a[200005];

int main()
{
	freopen("B.in","r",stdin);
	freopen("B.out","w",stdout);
	scanf("%d%d",&n,&q);
	F.init(n),H.init(n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%lld",&w[i]),F.add(i,w[i]),H.add(i,w[i]%mo*(a[i]-i)%mo,1);
	while(q--)
	{
		scanf("%d%d",&x,&y);
		if(x<0)
		{
			x=-x;
			F.add(x,y-w[x]);
			H.add(x,(y-w[x]+mo)%mo*(a[x]-x)%mo,1);
			w[x]=y;
		}
		else
		{
			pos=F.lower_bound(F.sum(y)+F.sum(x-1)+1>>1);
			ans=(F.sum(pos-1,1)-F.sum(x-1,1)+mo)%mo*(a[pos]-pos)%mo+mo-H.sum(pos-1,1)+H.sum(x-1,1);
			ans%=mo;
			ans+=(-F.sum(y,1)+F.sum(pos,1)+mo)%mo*(a[pos]-pos)%mo+mo+H.sum(y,1)-H.sum(pos,1);
			printf("%d\n",int((ans+mo)%mo));
		}
	}
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second

typedef long long ll;
typedef pair<int, int> ii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

const int mod = 1e9 + 7;
const int N = 2e5 + 5;

struct segT {
    int n;
    ll *seg;
    bool f;

    segT(){}

    segT(const vector<int> &v, bool f) : f(f) {
        n = v.size();
        seg = new ll[4*N + 1];
        build(1, 0, n-1, v);
    }

    void build(int r, int i, int j, const vector<int> &v) {
        if(i == j) {
            seg[r] = v[i];
        } else {
            int mid = (i+j)>>1;
            build(2*r, i, mid, v);
            build(2*r+1, mid+1, j, v);

            seg[r] = seg[2*r] + seg[2*r+1];
            if(f)
                seg[r] %= mod;
        }
    }

    int a, b;
    ll query(int r, int i, int j, ll val) {
        if(j < a or i > b)  return 0;

        if(i >= a and j <= b) {
            if(val != -1)
                seg[r] = val;
            return seg[r];
        } else {
            int mid = (i+j)>>1;

            ll L = query(2*r, i, mid, val);
            ll R = query(2*r+1, mid+1, j, val);

            if(f) {
                seg[r] = (seg[2*r] + seg[2*r+1])%mod;
                return (L+R)%mod;
            } else {
                seg[r] = seg[2*r] + seg[2*r+1];
                return L+R;
            }
        }
    }

    ll query(int l, int r) {
        a = l;  b = r;
        return query(1, 0, n-1, -1);
    }

    void update(int p, ll val) {
        a = b = p;
        query(1, 0, n-1, val);
    }
} segw, segaw, segiw;

int n, q;
int a[N], w[N];

ll get(int a, int b, ll l, ll beg) {
    ll ret = (segw.query(a, b)*beg)%mod;
    ret = (ret + segiw.query(a, b))%mod;
    ret = (ret - segw.query(a, b)*l)%mod;
    ret = (ret - segaw.query(a, b))%mod;

    return ret;
}

int go(int l, int r) {
    l--;    r--;

    ll sum = segw.query(l, r);

    int bot = l, top = r;
    int center = 0;
    while(bot <= top) {
        int mid = (bot + top)>>1;

        if(segw.query(l,mid)*2LL >= sum) {
            center = mid;
            top = mid-1;
        } else {
            bot = mid+1;
        }
    }

    int beg = a[center] - (center-l);

    int L = get(l, center, l, beg);
    int R = -get(center+1, r, l, beg);

    int ret = (L + R)%mod;
    if(ret < 0)
        ret += mod;
    return ret;
}

int main (void) {

    vector<int> vw, vaw, viw;
    scanf("%d %d", &n, &q);
    for(int i = 0; i < n; i++)
        scanf("%d", a+i);
    for(int i = 0; i < n; i++) {
        scanf("%d", w+i);
        vw.pb(w[i]);
        vaw.pb( (1LL*w[i]*a[i])%mod );
        viw.pb( (1LL*w[i]*i)%mod );
    }

    segw = segT(vw, false);
    segaw = segT(vaw, true);
    segiw = segT(viw, true);

    while(q--) {
        int x, y;   scanf("%d %d", &x, &y);

        if(x>0) {
            printf("%d\n", go(x, y));
        } else {
            x *= -1;
            x--;
            segw.update(x, y);
            segaw.update(x, (1LL*a[x]*y)%mod);
            segiw.update(x, (1LL*y*x)%mod);
        }
    }

	return 0;
}

//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
//~ #pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(),x.end()
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define erase_duplicates(x) sort(all(x)); (x).resize(distance((x).begin(), unique(all(x))));

using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<
T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long double LD;
typedef pair<LD,LD> PLD;
typedef vector<LD> VLD;
typedef vector<PLD> VPLD;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<" = "<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#define cerr if(0)cout
#endif

const int maxn = (1e6)+7;
const int maxk = 20;
const int inf = (1e9)+7;
const LL LLinf = ((LL)1e18)+7LL;
const LD eps = 1e-9;
const LL mod = 1e9+7;

// ***************************** CODE ***************************** //

struct node
{
  LL suma;
  LL ilo;
  LL ile;
  LL lewo, prawo;
  node(LL pos = 0LL, LL wag = 0LL)
  {
    if(pos == 0)
      ile = 0;
    else
      ile = 1;
    lewo = wag;
    prawo = wag;
    suma = wag;
    ilo = pos * wag % mod;
  }

};

void wypisz(node a)
{
  dbg(a.suma, a.ilo, a.ile, a.lewo, a.prawo);
}

const int pot = 1<<20;

node drze[2 * pot + 7];

LL pos[maxn];

node merge(node a, node b)
{
  node res;
  res.suma = (a.suma + b.suma);
  res.ilo = (a.ilo + b.ilo) % mod;
  res.ile = a.ile + b.ile;
  res.lewo = (b.lewo + a.lewo + (a.suma % mod) * b.ile) % mod;
  res.prawo = (a.prawo + b.prawo + (b.suma % mod) * a.ile) % mod;
  return res;
}

LL sum(int l, int p)
{
  LL res = 0LL;
  l += pot;
  p += pot;
  while(l <= p)
  {
    if(l & 1)
      res += drze[l].suma;
    if(!(p & 1))
      res += drze[p].suma;
    l = (l + 1) / 2;
    p = (p - 1) / 2;
  }
  return res;
}

node daj(int l, int p)
{
  if(l > p)
    return node();
  l += pot;
  p += pot;
  vector<node> L, P;
  while(l <= p)
  {
    if(l & 1)
      L.pb(drze[l]);
    if(!(p & 1))
      P.pb(drze[p]);
    l = (l + 1) / 2;
    p = (p - 1) / 2;
  }
  while(SZ(P) > 1)
  {
    P[SZ(P) - 2] = merge(P.back(), P[SZ(P) - 2]);
    P.pop_back();
  }
  if(SZ(P))
    L.pb(P[0]);
  while(SZ(L) > 1)
  {
    L[SZ(L) - 2] = merge(L[SZ(L) - 2], L.back());
    L.pop_back();
  }
  return L[0];
}

void update(int x)
{
  while(x)
  {
    drze[x] = merge(drze[2 * x], drze[2 * x + 1]);
    x /= 2;
  }
}

int main()
{
	_upgrade
  int n, q;
  cin>>n>>q;
  for(int i = 1;i <= n;i++)
    cin>>pos[i];
  for(int j = 1;j <= n;j++)
  {
    int w;
    cin>>w;
    drze[j + pot] = node(pos[j], w);
  }
  for(int i = pot - 1;i > 0;i--)
    drze[i] = merge(drze[i * 2], drze[i * 2 + 1]);
  while(q--)
  {
    dbg("elo");
    int x, y;
    cin>>x>>y;
    if(x < 0)
    {
      x *= -1;
      // dbg(x, y);
      drze[x + pot] = node(pos[x], y);
      update((pot + x) / 2);
    }
    else
    {
      int l = x;
      int p = y + 1;
      LL xdd = daj(x, y).suma;
      while(l + 1 < p)
      {
        int sr = (l + p) / 2;
        if(sum(x, sr - 1) * 2LL <= xdd)
          l = sr;
        else
          p = sr;
      }
      int sr = l;
      l = x;
      p = y;
      // dbg(daj(x, y).suma, daj(1, 2).suma);
      // dbg(l, sr, p);
      LL res = pos[sr] * daj(x, sr - 1).suma % mod - daj(x, sr - 1).ilo - daj(x, sr - 1).lewo;
      res %= mod;
      res += mod;
      res %= mod;
      // dbg(res);
      // wypisz(daj(l, sr - 1));
      // wypisz(daj(sr + 1, p));
      res += daj(sr + 1, p).ilo - pos[sr] * daj(sr + 1, p).suma - daj(sr + 1, p).prawo;
      res %= mod;
      res += mod;
      res %= mod;
      // dbg(res);
      cout<<res<<"\n";
    }
  }
  // wypisz(drze[pot + 7]);
  // wypisz(drze[(pot + 8) / 2]);
  // wypisz(drze[(pot + 10)]);
	return 0;
}

#include <iostream>
#include <iomanip>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <cassert>
#include <fstream>
#include <algorithm>
#include <list>
#include <random>
#include <ctime>
#include <cmath>
#include <random>
#include <bitset>
#include <complex>
#include <stack>

using namespace std;
// a - b
// a inc b dec
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define mmin(a, b) a = min(a, (b))
#define mmax(a, b) a = max(a, (b))
#define mp(a,b) make_pair(a,b)
#define modsum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define modsubtract(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define modmultiply(a, b) (((a) * (b)) % M)
#define pb(a) push_back(a)
#define ALL(a) a.begin(),a.end()
#define sqr(x) (x) * (x)
#define fori(i, n) for(int i = 0; i < (int)(n); ++i)
#define cint const int &
#define SZ(a) ((int)(a.size()))
#define f(cnt) (((cnt) + 1) * (cnt) / 2)
#define watch(x) cout << (#x) << " = " << x << endl;
//#define log log10

const double PI = 2 * acos(0.0);

template<typename T>
struct edge {
    int from, to;
    T w;
    edge(int from, int to, T w): from(from), to(to), w(w) { }
    edge() { }
};

const ld EPS = 1e-9;

template<class T>
void show(T a) {
    for (auto x : a)
        cout << x << " ";
    cout << endl;
}

const int N = 2e5 + 9;
const ll oo = 1e18;
const ll M = 1e9 + 7;

int pw_double[N], pa_double[N];

ld tw_double[N], ta_double[N];

inline void updw_double(int i, ld w) {
    ld tmp = w;
    w -= pw_double[i];
    pw_double[i] = tmp;
    for (++i; i < N; i += i&-i)
        tw_double[i] += w;

}

inline void upda_double(int i, ld a) {
    ld tmp = a;
    a -= pa_double[i];
    pa_double[i] = tmp;
    for (++i; i < N; i += i&-i)
        ta_double[i] += a;
}

ld getw_double(int i) {
    ld ret = 0;
    for (; i > 0; i -= i&-i)
        ret += tw_double[i];
    return ret;
}

ld getw_double(int l, int r) {
    if (l > r) return 0;
    ++r;
    if (l) return getw_double(r) - getw_double(l);
    return getw_double(r);
}

ld geta_double(int i) {
    ld ret = 0;
    for (; i > 0; i -= i&-i)
        ret += ta_double[i];
    return ret;
}

ld geta_double(int l, int r) {
    if (l > r) return 0;
    ++r;
    if (l) return geta_double(r) - geta_double(l);
    return geta_double(r);
}

int pw[N], pa[N];
int tw[N], ta[N];

inline void updw(int i, int w) {
    int tmp = w;
    w = modsubtract(w, pw[i]);
    pw[i] = tmp;
    for (++i; i < N; i += i&-i)
        tw[i] = modsum(tw[i], w);
}

inline void upda(int i, int w) {
    int tmp = w;
    w = modsubtract(w, pa[i]);
    pa[i] = tmp;
    for (++i; i < N; i += i&-i)
        ta[i] = modsum(ta[i], w);
}

inline int getw(int i) {
    int ret = 0;
    for (; i > 0; i -= i&-i)
        ret = modsum(ret, tw[i]);
    return ret;
}

inline int getw(int l, int r) {
    if (l > r) return 0;
    ++r;
    int a = getw(r), b = getw(l);
    return modsubtract(a, b);
}

inline int geta(int i) {
    int ret = 0;
    for (; i > 0; i -= i&-i)
        ret = modsum(ret, ta[i]);
    return ret;
}

inline int geta(int l, int r) {
    if (l > r) return 0;
    ++r;
    int a = geta(r), b = geta(l);
    return modsubtract(a, b);
}

int a[N];
int n, q;

#define int long long
inline int bins(ll xl) {
    int l = -1, r = n;
    while (r - l > 1) {
        int m = (l + r) >> 1;
        if (xl + m - a[m] >= 0)
            l = m;
        else
            r = m;
    }
    return r;
}

inline ld get_double(int xx, int l, int r) {
    int pos = bins(xx - l);
    ld x = xx;
    return (getw_double(l, min(pos - 1, r)) - getw_double(max(l, pos), r)) * (x - l) + geta_double(l, min(pos - 1, r)) - geta_double(max(pos, l), r);
}

inline int get(int x, int l, int r) {
    int pos = bins(x - l);
    ll tmp = getw(l, min(pos - 1, r));
    int plus =  modmultiply(tmp, modsubtract(x, l));
    tmp = geta(l, min(pos - 1, r));
    plus = modsum(plus, tmp);
    tmp = getw(max(l, pos), r);
    int minus =  modmultiply(tmp, modsubtract(x, l));
    tmp = geta(max(pos, l), r);
    minus = modsum(minus, tmp);
    return modsubtract(plus, minus);
}

inline bool check(int x, int l, int r) {
    ld a = get_double(x, l, r), b = get_double(x + 1, l, r);
    return  a > b || abs(a - b) < EPS;
}

int solve(int L, int R) {
    int l = -1, r = 1e9 + 9;
    while (r - l > 1) {
        int m = (l + r) >> 1;
        if (check(m, L, R))
            l = m;
        else
            r = m;

    }
    return get(r, L, R);
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

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

    fori (i, n) {
        int w;
        cin >> w;
        updw(i, w);
        upda(i, modmultiply((ll)w, modsubtract(i, a[i])));
        updw_double(i, w);
        upda_double(i, (ld) w * ((ld) i - (ld) a[i]));
    }

    while (q--) {
        int x, y;
        cin >> x >> y;
        if (x < 0) {
            x = -x - 1;
            updw(x, y);
            upda(x, modmultiply((ll)y, modsubtract(x, a[x])));
            updw_double(x, y);
            upda_double(x, (ld)y * ((ld)x - (ld) a[x]));
        } else {
            cout << solve(--x, --y) << "\n";
        }
    }
}

#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
#define lowbit(x) ((x) & (-(x)))
using namespace std;

typedef long long ll;
const int N = 2e5 + 10, mod = 1e9 + 7;
ll n, Q;
ll a[N], w[N], c1[N], c2[N];
struct node {
    ll c[N];
    void add(ll x, ll v) {
        for (; x <= n; x += lowbit(x)) c[x] += v;
    }
    ll ask(ll x) {
        ll ret = 0;
        for (; x; x -= lowbit(x)) ret += c[x]; return ret % mod;
    }
}A, B;

void task1(ll id, ll v) {
    A.add(id, -w[id]);
    B.add(id, -1ll * w[id] * a[id] % mod);
    w[id] = v;
    A.add(id, w[id]);
    B.add(id, 1ll * w[id] * a[id] % mod);
}

ll task2(ll L, ll R) {
    ll tmp = A.ask(L - 1);
    ll sum = A.ask(R) - tmp;
    ll l = L, r = R, pos, ret = 0;
    while (l <= r) {
        ll mid = (l + r) >> 1;
        ll val = A.ask(mid) - tmp;
        if (val * 2 >= sum) r = mid - 1, pos = mid;
        else l = mid + 1;
    }
    ll a1 = 1ll * (A.ask(pos) - tmp + mod) % mod * a[pos] % mod;
    ll a2 = 1ll * (B.ask(pos) - B.ask(L - 1) + mod) % mod;
    ll a3 = 1ll * (A.ask(R) - A.ask(pos) + mod) % mod * a[pos] % mod;
    ll a4 = 1ll * (B.ask(R) - B.ask(pos) + mod) % mod;
    ret = a4 - a3 + a1 - a2;
    return (ret % mod + mod) % mod;
}

int main() {
    cin >> n >> Q;
    rep(i, 1, n) scanf("%lld", &a[i]), a[i] += -i + n;
    rep(i, 1, n) {
        scanf("%lld", &w[i]);
        A.add(i, w[i]);
        B.add(i, 1ll * w[i] * a[i] % mod);
    }
    while (Q--) {
        int x, y; scanf("%d%d", &x, &y);
        if (x < 0) task1(-x, y); else printf("%lld\n", task2(x, y));
    }
    return 0;
}

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=200005,tt=1e9+7;
int n,Q,a[maxn],w[maxn],T[maxn],t[4*maxn],t1[maxn];
void Ins(int x,int y){for (int i=x;i<=n;i+=(i&(-i))) T[i]+=y;}
int Get(int x){int r=0; for (int i=x;i;i-=(i&(-i))) r+=T[i]; return r;}
void ins1(int x,int y){for (int i=x;i<=n;i+=(i&(-i))) t1[i]=(t1[i]+y)%tt;}
int get1(int x){int r=0; for (int i=x;i;i-=(i&(-i))) r=(r+t1[i])%tt; return r;}
int get(int L,int R){
    int l=L,r=R,all=Get(R)-Get(L-1),ret=R;
    while (l<=r){
        int mid=(l+r)>>1;
        if (2*(Get(mid)-Get(L-1))>=all) ret=mid,r=mid-1; else l=mid+1;
    }
    return ret;
}
void ins(int x,int l,int r,int p){
    if (l==r) {t[x]=1ll*a[l]*w[l]%tt; return;}
    int mid=(l+r)>>1;
    if (p<=mid) ins(2*x,l,mid,p); else ins(2*x+1,mid+1,r,p);
    t[x]=(t[2*x]+t[2*x+1])%tt;
}
int query(int x,int l,int r,int ql,int qr){
    if (l==ql&&r==qr) return t[x];
    int mid=(l+r)>>1;
    if (qr<=mid) return query(2*x,l,mid,ql,qr);
    else if (ql>mid) return query(2*x+1,mid+1,r,ql,qr);
    else return (query(2*x,l,mid,ql,mid)+query(2*x+1,mid+1,r,mid+1,qr))%tt;
}
signed main(){
    scanf("%lld%lld",&n,&Q);
    for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
    for (int i=1;i<=n;i++) scanf("%lld",&w[i]),Ins(i,w[i]),ins(1,1,n,i),ins1(i,w[i]*i%tt);
    for (int i=1;i<=Q;i++){
        int x,y; scanf("%lld%lld",&x,&y);
        if (x<0){
            Ins(-x,-w[-x]); ins1(-x,tt-w[-x]*(-x)%tt);
            w[-x]=y; Ins(-x,y); ins1(-x,y*(-x)%tt);
            ins(1,1,n,-x);
        } else {
            int p=get(x,y),ret=0; //printf("!!!%lld\n",p);
            if (p!=x) ret+=((a[p]-p)*(Get(p-1)-Get(x-1))%tt-query(1,1,n,x,p-1)+get1(p-1)-get1(x-1))%tt;
            if (p!=y) ret+=(query(1,1,n,p+1,y)-(a[p]-p)*(Get(y)-Get(p))%tt-get1(y)+get1(p))%tt;
            ret=(ret%tt+tt)%tt;
            printf("%lld\n",ret);
        }
    }
    return 0;
}

#define Link ""

#include <iostream>
#include <cstdio>

#define TASK "1053C"

using namespace std;

const long long Mod = 1e9 + 7;
const long long maxn = 2e5 + 1;
long long n,q,a[maxn],w[maxn];
struct T_node
{
    long long l,r,cost;
    long long sz;
} node[maxn*6];

void Enter()
{
    cin >> n >> q;
    for (long long i=1;i<=n;++i) {
        cin >> a[i];
        a[i] -= i - 1;
    }
    for (long long i=1;i<=n;++i)
        cin >> w[i];
}

void Init()
{

}

void Combine(long long i)
{
    node[i].sz = node[i*2].sz + node[i*2+1].sz;
    node[i].cost = (node[i*2].cost + node[i*2+1].cost) % Mod;
}

void Build_tree(long long i, long long l, long long r)
{
    node[i].l = l;
    node[i].r = r;
    if (l != r) {
        Build_tree(i*2,l,(l+r)/2);
        Build_tree(i*2+1,(l+r)/2+1,r);
        Combine(i);
    }
    else {
        node[i].sz = w[l];
        node[i].cost = 1ll * a[l] * w[l] % Mod;
    }
}

void Update(long long i, long long id, long long val)
{
    if (node[i].r < id || id < node[i].l)
        return;
    if (node[i].l == node[i].r) {
        w[id] = val;
        node[i].sz = w[id];
        node[i].cost = 1ll * a[id] * w[id] % Mod;
    }
    else {
        Update(i*2,id,val);
        Update(i*2+1,id,val);
        Combine(i);
    }
}

long long QuerySize(long long i, long long l, long long r)
{
    if (node[i].r < l || r < node[i].l)
        return 0;
    if (l <= node[i].l && node[i].r <= r)
        return node[i].sz;
    else
        return QuerySize(i*2,l,r) + QuerySize(i*2+1,l,r);
}

long long FindPos(long long i, long long val)
{
//    cout << node[i].l << ' ' << node[i].r << ' ' << val << '\n';
    if (node[i].l == node[i].r)
        return node[i].l;
    if (val <= node[i*2].sz)
        return FindPos(i*2,val);
    return FindPos(i*2+1,val-node[i*2].sz);
}

long long QueryCost(long long i, long long l, long long r)
{
    if (node[i].r < l || r < node[i].l)
        return 0;
    if (l <= node[i].l && node[i].r <= r)
        return node[i].cost;
    else
        return (QueryCost(i*2,l,r) + QueryCost(i*2+1,l,r)) % Mod;
}

void Solve()
{
    Build_tree(1,1,n);
    for (;q>0;--q) {
        long long x,y;
        cin >> x >> y;
        if (x < 0)
            Update(1,-x,y);
        else {
            long long chose = QuerySize(1,1,x-1) + QuerySize(1,x,y) / 2 + 1;
//            cout << chose << '\n';
            long long med = FindPos(1,chose);
//            cout << med << ' ';
            cout << (1ll * a[med] * QuerySize(1,x,med-1) % Mod - QueryCost(1,x,med-1) + QueryCost(1,med+1,y) - 1ll * a[med] * QuerySize(1,med+1,y) % Mod + 1ll * Mod * Mod) % Mod << '\n';
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

#ifdef LHL
    freopen(".INP","r",stdin);
    freopen(".OUT","w",stdout);
#else
//    freopen(TASK".INP","r",stdin);
//    freopen(TASK".OUT","w",stdout);
#endif // LHL

    Enter();
    Init();
    Solve();
}

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int N = 200010, LGN = 18, X = 1 << LGN, P = 1000000007;

int n, q;
int a[N], w[N];
int fw[N];
ll wfw[X];

int lowBit(int k) { return k & -k; }
ll lq(int k);
void lch(int k, int x);
int bound(ll v);
int qr(int k);
void ch(int k, int x);

int main() {
#ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
	int nol_cl = clock();
#endif

	scanf("%d%d", &n, &q);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		a[i] -= i;
	}
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &w[i]);
		ch(i, w[i] * (ll)a[i] % P);
		lch(i, w[i]);
	}
	while (q--) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x < 0) {
			x = -x;
			int delt = y - w[x];
			lch(x, delt);
			if ((delt %= P) < 0)
				delt += P;
			ch(x, delt * (ll)a[x] % P);
			w[x] += delt;
		} else {
			int pos = bound(lq(x - 1) + (lq(y) - lq(x - 1) + 1) / 2);
			int ans = ((qr(y) - qr(pos)) % P - (lq(y) - lq(pos)) % P * a[pos] % P) % P;
			if (ans < 0)
				ans += P;
			ans = (ans + (lq(pos - 1) - lq(x - 1)) % P * a[pos] % P - (qr(pos - 1) - qr(x - 1)) % P) % P;
			if (ans < 0)
				ans += P;
			printf("%d\n", ans);
		}
	}

#ifndef ONLINE_JUDGE
	LOG("Time: %dms\n", int((clock() - nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
	return 0;
}

int qr(int k) {
	int ret = 0;
	for (; k; k -= lowBit(k))
		if ((ret += fw[k]) >= P)
			ret -= P;
	return ret;
}

void ch(int k, int x) {
	for (; k <= n; k += lowBit(k))
		if ((fw[k] += x) >= P)
			fw[k] -= P;
}

ll lq(int k) {
	ll ret = 0;
	for (; k; k -= lowBit(k))
		ret += wfw[k];
	return ret;
}

void lch(int k, int x) {
	for (; k < X; k += lowBit(k))
		wfw[k] += x;
}

int bound(ll x) {
	int ret = 0;
	for (int k = LGN - 1; k >= 0; --k)
		if (x > wfw[ret | (1 << k)])
			x -= wfw[ret |= 1 << k];
	return ret + 1;
}

#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define MOD 1000000007LL
#define MOD1 1000000009LL
#define INF 1000000000000000018LL
#define F first
#define S second
#define ll long long
#define eps 1e-9

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll gcd(ll a, ll b)
{
	if(a == 0LL)
		return b;
	if(b == 0LL)
		return a;
	return gcd(b, a%b);
}

const int N = 200005;
ll A[N], W[N];
pll tree[N<<2];

void build(int node, int l, int r)
{
	if(l == r)
	{
		tree[node] = mp(W[l], (A[l]*W[l])%MOD);
		return;
	}
	int mid = (l+r)>>1;
	int left = node<<1;
	int right = left + 1;
	build(left, l, mid);
	build(right, mid+1, r);
	tree[node].F = tree[left].F + tree[right].F;
	tree[node].S = (tree[left].S + tree[right].S)%MOD;

	return;
}

void update(int node, int l, int r, int idx)
{
	if(l == r)
	{
		tree[node] = mp(W[idx], (A[idx]*W[idx])%MOD);
		return;
	}
	int mid = (l+r)>>1;
	int left = node<<1;
	int right = left + 1;
	if(idx <= mid)
		update(left, l, mid, idx);
	else
		update(right, mid+1, r, idx);
	tree[node].F = tree[left].F + tree[right].F;
	tree[node].S = (tree[left].S + tree[right].S)%MOD;

	return;
}

pll query(int node, int l, int r, int a, int b)
{
	if(l == a && r == b)
		return tree[node];
	int mid = (l+r)>>1;
	int left = node<<1;
	int right = left + 1;
	if(b <= mid)
		return query(left, l, mid, a, b);
	else if(a > mid)
		return query(right, mid+1, r, a, b);
	pll L = query(left, l, mid, a, mid);
	pll R = query(right, mid+1, r, mid+1, b);
	pll ans = mp(L.F + R.F, (L.S + R.S)%MOD);
	return ans;
}

ll getAns(int n, int L, int R, int ind)
{
	ll X = A[ind];
	ll ans = 0LL;
	pll val = query(1, 1, n, L, ind);
	val.F = val.F%MOD;
	ans = (ans + ((X*val.F)%MOD) - val.S + 2LL*MOD)%MOD;
	val = query(1, 1, n, ind, R);
	val.F = val.F%MOD;
	ans = (ans + val.S - ((X*val.F)%MOD) + 2LL*MOD)%MOD;
	return ans;
}

bool check(int n, int L, int R, int ind)
{
	pll val1 = query(1, 1, n, L, ind);
	pll val2 = query(1, 1, n, ind, R);

	ll temp1 = val1.F;
	ll temp2 = val2.F;

	ll ans = A[ind+1]*(temp1 + W[ind+1]) - A[ind]*temp1 - A[ind+1]*W[ind+1] - A[ind]*W[ind] - A[ind+1]*(temp2 - W[ind]) + A[ind]*temp2;

	return (ans >= 0LL);
}

void solve1(int n, int L, int R)
{
	int l = L, r = R, mid;
	ll val1, val2;
	while(l < r)
	{
		mid = (l+r)/2;

		if(check(n, L, R, mid))
			r = mid;
		else
			l = mid+1;
	}
	assert(l == r);
	cout << getAns(n, L, R, l) << "\n";

	return;
}

void solve()
{
	int n, q;
	cin >> n >> q;
	for(int i = 1; i<=n; i++)
	{
		cin >> A[i];
		A[i] = A[i] - i;
	}
	for(int i = 1; i<=n; i++)
		cin >> W[i];
	build(1, 1, n);

	int L, R;
	while(q--)
	{
		cin >> L >> R;
		if(L<0)
		{
			L = -1*L;
			W[L] = R;
			update(1, 1, n, L);

			continue;
		}
		solve1(n, L, R);
	}

	return;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	// freopen("in.in", "r", stdin);
	// freopen("out.out", "w", stdout);

	clock_t clk = clock();

	int t = 1;
	// cin >> t;
	for(int tests = 1; tests <= t; tests++)
	{
		// cout << "Case #" << tests << ": ";
		solve();
	}

	clk = clock() - clk;
	cerr << "Time Elapsed: " << fixed << setprecision(10) << ((long double)clk)/CLOCKS_PER_SEC << "\n";

	return 0;
}

//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef tuple <int, int> tii;
typedef tuple <long long, long long> tll;
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define endl "\n"
#define mt make_tuple

const int mod = 1000000007;
const int INF = 1000000001;

int n, q;
ll segSum[800005], segMult[800005], w[200005], a[200005];

void update(ll seg[], int v, int l, int r, int index, ll x);
ll get(ll seg[], int v, int l, int r, int cl, int cr);
pair <int, ll> find(ll seg[], int v, int l, int r, int cl, int cr, int s);

ll norm(ll a) {
    a %= mod;

    if (a > mod)
        a -= mod;
    if (a < 0)
        a += mod;

    return a;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> q;

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] -= i;
    }

    for (int i = 1; i <= n; i++)
        cin >> w[i];

    for (int i = 1; i <= n; i++) {
        update(segSum, 1, 1, n, i, w[i]);
        update(segMult, 1, 1, n, i, w[i] * a[i] % mod);
    }

    while (q--) {
        int x, y;
        cin >> x >> y;

        if (x < 0) {
            x *= -1;
            w[x] = y;
            update(segSum, 1, 1, n, x, w[x]);
            update(segMult, 1, 1, n, x, w[x] * a[x] % mod);
        } else {
            ll result = 0;
            auto pos = find(segSum, 1, 1, n, x, y, get(segSum, 1, 1, n, x, y) / 2);
            result = norm(result + a[pos.first] * get(segSum, 1, 1, n, x, pos.first) - norm(get(segMult, 1, 1, n, x, pos.first)));
            result = norm(result + norm(get(segMult, 1, 1, n, pos.first, y)) - a[pos.first] * get(segSum, 1, 1, n, pos.first, y));

            cout << result << endl;
        }
    }

    cout << endl << endl;

    return 0;
}

void update(ll seg[], int v, int l, int r, int index, ll x) {
    if (l == r) {
        seg[v] = x;
        return;
    }

    int mid = (l + r) >> 1;

    if (index <= mid)
        update(seg, v * 2, l, mid, index, x);
    else
        update(seg, v * 2 + 1, mid + 1, r, index, x);

    seg[v] = seg[v * 2] + seg[v * 2 + 1];
}

ll get(ll seg[], int v, int l, int r, int cl, int cr) {
    if ((l == cl) && (r == cr))
        return seg[v];

    int mid = (l + r) >> 1;
    ll result = 0;

    if (cl <= mid)
        result = get(seg, v * 2, l, mid, cl, min(cr, mid));
    if (cr > mid)
        result += get(seg, v * 2 + 1, mid + 1, r, max(cl, mid + 1), cr);

    return result;
}

pair <int, ll> find(ll seg[], int v, int l, int r, int cl, int cr, int s) {
    if ((l == cl) && (r == cr)) {
        if (seg[v] <= s)
            return  { INF, seg[v]};

        if (l == r)
            return  {l, 0};
    }

    int mid = (l + r) >> 1;
    pair <int, ll> result = {INF, 0};

    if (cl <= mid)
        result = find(seg, v * 2, l, mid, cl, min(mid, cr), s);

    if ((cr > mid) && (result.first == INF)) {
        auto res = find(seg, v * 2 + 1, mid + 1, r, max(mid + 1, cl), cr, s - result.second);
        result.first = min(result.first, res.first);
        result.second += res.second;
    }

    return result;
}

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ull = unsigned ll;

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x first
#define y second

const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};
const char dir[] = {'R', 'L', 'D', 'U'};

int add(int a, int b){ //(a + b) % 1e9 + 7
    a += b;
    if(a >= MOD){
        a -= MOD;
    }
    return a;
}

int subtract(int a, int b){
    a -= b;
    if(a < 0) a += MOD;
    return a;
}

int mult(int a, int b){
    return ((ll) a * b) % MOD;
}

void setIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
//    freopen((s+".in").c_str(),"r",stdin);
//    freopen((s+".text").c_str(),"w",stdout);
}

const int mxN = 200'000;

ll tree[mxN + 5];
void update(int index, ll val) {
    index++;
    while(index < mxN + 5) {
        tree[index] += val;
        index += index & -index;
    }
}
ll query(int index) {
    ll ret = 0;
    index++;
    while(index > 0) {
        ret += tree[index];
        index -= index & -index;
    }
    return ret;
}
ll rquery(int a, int b) {
    return query(b)-query(a-1);
}

int n, q;
double a[mxN], w[mxN];

struct node{
    double toLeft, toRight, total, l, r, inSeg;
    node(int tl, int tr, int tt, int left, int right, int is){
        toLeft = tl;
        toRight = tr;
        total = tt;
        l = left;
        r = right;
        inSeg = is;
    }
    node(){
        toLeft = 0, toRight = 0, total = 0;
        l = 0, r = 0;
        inSeg = 0;
    }
};

node st[mxN << 2];

void update(node& t, int ind){
    t = node(0, 0, w[ind], a[ind], a[ind], 1);
}

node merge(node& a, node& b){
    if(a.inSeg == 0) return b;
    if(b.inSeg == 0) return a;
    node c;
    c.r = b.r;
    c.l = a.l;
    int nextRight = b.r - b.inSeg;
    c.toRight = b.toRight + a.toRight + a.total * (nextRight - a.r);
    int nextLeft = a.l + a.inSeg;
    c.toLeft = a.toLeft + b.toLeft + b.total * (b.l - nextLeft);
    c.total = a.total + b.total;
    c.inSeg = a.inSeg + b.inSeg;
    return c;
}

void build(int v, int l, int r){
    if(l == r){
        st[v] = node(0, 0, w[l], a[l], a[l], 1);
        return;
    }
    int m = (l + r) / 2;
    build(v * 2 + 1, l, m);
    build(v * 2 + 2, m + 1, r);
    st[v] = merge(st[v * 2 + 1], st[v * 2 + 2]);
}

void update(int v, int l, int r, int ind){
    if(r < ind || l > ind) return;
    if(l == r){
        update(st[v], ind);
        return;
    }
    int m = (l + r) / 2;
    build(v * 2 + 1, l, m);
    build(v * 2 + 2, m + 1, r);
    st[v] = merge(st[v * 2 + 1], st[v * 2 + 2]);
}

node get(int v, int l, int r, int L, int R){
    if(L > R || r < L || l > R) return node();
    if(L == l && r == R){
        return st[v];
    }
    int m = (l + r) / 2;
    node left = get(v * 2 + 1, l, m, L, min(R, m));
    node right = get(v * 2 + 2, m + 1, r, max(L, m + 1), R);
    return merge(left, right);
}

int main(){
    setIO();
    //CHECK FOR LONG LONG!!!
    //LONG LONG OVERFLOW??
    cin >> n >> q;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    for(int i = 0; i < n; ++i){
        cin >> w[i];
        update(i, w[i]);
    }
    build(0, 0, n - 1);
    while(q--){
        int x, y; cin >> x >> y;
        if(x < 0){
            x = -x; --x;
            update(x, -w[x]);
            w[x] = y;
            update(x, w[x]);
            update(0, 0, n - 1, x);
        }
        else{
            --x; --y;
            ll tot = rquery(x, y);
            int l = x, r = y;
            while(l < r){
                int m = (l + r + 1) / 2;
                if(2 * rquery(x, m) <= tot){
                    l = m;
                }
                else{
                    r = m - 1;
                }
            }
            ++l;
            int curloc = a[l];
            if(l == x){
                node cur = get(0, 0, n - 1, l + 1, y);
                cout << add(cur.toLeft, mult(cur.total, cur.l - curloc - 1)) << "\n";
            }
            else if(l == y){
                node cur = get(0, 0, n - 1, x, l - 1);
                cout << add(cur.toRight, mult(cur.total, curloc - cur.r - 1)) << "\n";
            }
            else{
                node right = get(0, 0, n - 1, l + 1, y);
                node left = get(0, 0, n - 1, x, l - 1);
                cout << add(add(right.toLeft, mult(right.total, right.l - curloc - 1)), add(left.toRight, mult(left.total, curloc - left.r - 1))) << "\n";
            }
        }
    }
    //CHECK FOR LONG LONG!!!
}

#include <bits/stdc++.h>
using namespace std;

#define N 200005
const int mod = 1e9 + 7;

#define ll long long

int add(int x,int y) {
  return ((x+y)%mod+mod)%mod;
}
int mul(int x,int y) {
  return (ll)x*y%mod;
}
int mypow(int x,int c) {
  int ret = 1;
  while(c>0) {
    if(c&1) {
      ret = mul(ret,x);
    }
    c/=2;
    x = mul(x,x);
  }
  return ret;
}

ll pen[N];

void update(int ind,int add) {
  while(ind<N) {
    pen[ind] += add;
    ind += ind&(-ind);
  }
}

ll query(int ind) {
  ll ret = 0;
  while(ind>0) {
    ret = ret + pen[ind];
    ind = ind&(ind-1);
  }
  return ret;
}

int a[N],w[N];

int pen2[N];
int pen3[N];

void update2(int *pp,int ind,int ad) {
  while(ind<N) {
    pp[ind] = add(pp[ind],ad);
    ind += ind&(-ind);
  }
}

int query2(int *pp,int ind) {
  int ret = 0;
  while(ind>0) {
    ret = add(ret,pp[ind]);
    ind = ind&(ind-1);
  }
  return ret;
}

int getS(int x,int y,int wei) {
  ll s = query(y)- query(x-1);
  int sum = s%mod;
  int r = add(add(query2(pen3,y) ,-query2(pen3,x-1)), -mul(sum,x));
  return add(r, mul(sum,wei));
}

void solve() {
  int n,q;
  scanf("%d %d ", &n,&q);
  for(int i=1;i<=n;++i) {
    scanf("%d ", &a[i]);
  }
  for(int i=1;i<=n;++i) {
    scanf("%d ", &w[i]);
    update(i,w[i]);
    update2(pen2,i,mul(w[i],a[i]));
    update2(pen3,i,mul(i,w[i]));

  }

  while(q--) {
    int x,y;
    scanf("%d %d ", &x,&y);
    if(x<0) {
      int id = -x;
      update(id,-w[id]);
      update2(pen2,id,-mul(w[id],a[id]));
      update2(pen3,id,-mul(id,w[id]));
      w[id] = y;
      update(id,w[id]);
      update2(pen2,id,mul(w[id],a[id]));
      update2(pen3,id,mul(id,w[id]));
    } else {
      ll pre = query(x-1);
      ll sum = query(y) - pre;
      int l = x,r = y,mid;
      while(l<r) {
        mid = (l + r + 1)/2;
        if( (query(mid) - pre)*2<=sum) {
          l = mid;
        } else {
          r = mid - 1;
        }
      }
      int ind = l;
      if(ind+1<=y) {
        sum = query(y);
        ll ab1 = abs( (query(ind-1) - pre) - (sum - query(ind)));

        ll ab2 = abs( (query(ind) - pre) - (sum - query(ind+1)));
        if(ab1>ab2) {
          ++ind;
        }
      }

      int ret = 0;
      if(x<=ind-1) {
        int wei = a[ind] - ind  + x;
        ret = add(ret, add(getS(x,ind-1,wei),-add(query2(pen2,ind-1),-query2(pen2,x-1))));
      }
      if(ind+1<=y) {
        int wei = a[ind] + 1;
        ret = add(ret, add(-getS(ind+1,y,wei),add(query2(pen2,y),-query2(pen2,ind))));
      }
      printf("%d\n", ret);
    }
  }

}

int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}

#include <bits/stdc++.h>
// #include "lib.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define LLINF 1234567890987654321
#define INF 1234567890
#define pb push_back
#define ins insert
#define f first
#define s second
#define db 0
#define MAXN 200006
#define MAXK 200006
#define MAXX 15000006
#define rep(kk, l1, l2)for(ll kk = l1; kk < l2; kk++)
#define bg(ms) *ms.begin()
#define ed(ms) *prev(ms.end(), 1)
#define addedge(a, b, c) v[a].pb(pi(b, c)); v[b].pb(pi(a, c))
#define MOD LLINF
#define ph push
#define all(x) x.begin(), x.end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef long long ll;
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
ll n, q, fw[MAXN], total, ans;
ll l, r, lefty, righty;
ll st, en, mid;
void update(ll x, ll v)
{
  for(; x<=n; x+=x&(-x))fw[x] += v;
}
ll sum(ll x)
{
  ll res = 0;
  for(; x; x-=x&(-x))res += fw[x];
  return res;
}
ll range_sum(ll a, ll b)
{
  if(a > b)return 0;
  return sum(b) - sum(a-1);
}
struct box
{
  ll p=0, w=0;
} A[MAXN];
struct fen2
{
  ll fw[MAXN];
  void init() { rep(i, 0, MAXN)fw[i] = 0; }
  void update(ll x, ll nv)
  {
    for(; x<=n; x+=x&(-x))fw[x] += nv;
  }
  ll sum(ll x)
  {
    ll res = 0;
    for(; x; x-=x&(-x))res += fw[x];
    return res;
  }
  ll range_sum(ll a, ll b)
  {
    if(a > b)return 0;
    return (sum(b) - sum(a-1));
  }
} f2;
int main()
{
  f2.init();
  cin >> n >> q;
  rep(i, 0, n)cin >> A[i].p;
  rep(i, 0, n)cin >> A[i].w;
  rep(i, 0, n)update(i+1, A[i].w), f2.update(i+1, ( (A[i].w*(((i+1)-A[i].p)))) );
  rep(_, 0, q)
  {
    cin >> l >> r;
    st = l-1, en = r, mid = 0, ans = 0;
    if(l < 0)
    {
      //means update
      l = -l;
      ll ol = A[l-1].w;
      ll original = f2.range_sum(l, l);
      A[l-1].w = r;
      update(l, (A[l-1].w-ol)); //l(given in input) is one-indexed, but A is 0-indexed
      f2.update(l, -original);
      f2.update(l, ( A[l-1].w*(l-A[l-1].p) ));
      continue;
    }
    total = range_sum(l, r);
    // cout << total << '\n';
    while(en-st > 1)
    {
      mid = ( (st+en) / 2);
      if(range_sum(l, mid) <= total/2) st = mid;
      else en = mid;
    }
    ++st;
    lefty = range_sum(l, st-1), righty = range_sum(st+1, r);
    ans = ( ((lefty*A[st-1].p)) - ((lefty*st)) + f2.range_sum(l, st-1)) ;
    // cout << ans << ' ';
    ans = ( (ans - ((righty*A[st-1].p)) + ((righty*st)) - f2.range_sum(st+1, r)));
    // cout << ans << ' ' << st << '\n';
    cout << ans%1000000007 << '\n';
  }
}

/*

F() Wi(Ak - Ai - k + i )
TwAk - Twk + F() WiI - WiAi

4 10
1 333333333 666666666 1000000000
1000000000 1000000000 1000000000 1000000000
1 4
*/

#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iomanip>
#include <cctype>
#include <cassert>
#include <bitset>
#include <ctime>
#include <cstdint>
#include <bits/stdc++.h>

using namespace std;

#define pau system("pause")
#define ll long long
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define mp make_pair
#define pli pair<ll, int>
#define pil pair<int, ll>
#define clr(a, x) memset(a, x, sizeof(a))

const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define TREE tree<pli, null_type, greater<pli>, rb_tree_tag, tree_order_statistics_node_update>
TREE T;
*/

#define __int128 ll

int n, q;
ll a[200015], w[200015], c[200015];
__int128 c2[200015];
inline int lb(int x) {return x & -x;}
void add(int p,  ll x) {
	for (; p <= n; p += lb(p)) c[p] += x;
}
void add2(int p, ll x) {
	for (; p <= n; p += lb(p)) c2[p] += x;
}
ll query(int p) {
	ll res = 0;
	for (; p; p -= lb(p)) res += c[p];
	return res;
}
__int128 query2(int p) {
	__int128 res = 0;
	for (; p; p -= lb(p)) res += c2[p];
	return res;
}
__int128 cal(int p, int l, int r) {
	__int128 res1, res2;
	res1 = query2(r) - query2(p);
	res1 -= (__int128)(query(r) - query(p)) * a[p];
	res2 = query2(p) - query2(l - 1);
	res2 = (__int128)(query(p) - query(l - 1)) * a[p] - res2;
	//printf("%lld %lld\n", (ll)res1, (ll)res2);
	return res1 + res2;
}
int main() {
	scanf("%d%d", &n, &q);
	for (int i = 1; i <= n; ++i) {
		scanf("%lld", &a[i]);
		a[i] -= i;
	}
	for (int i = 1; i <= n; ++i) {
		scanf("%lld", &w[i]);
	}
	for (int i = 1; i <= n; ++i) {
		add(i, w[i]);
		add2(i, w[i] * a[i]);
	}
	//cal(4, 1, 5);
	while (q--) {
		int l, r;
		scanf("%d%d", &l, &r);
		if (l < 0) {
			add(-l, r - w[-l]);
			add2(-l, (ll)(r - w[-l]) * a[-l]);
			w[-l] = r;
		} else {
			int s = l, e = r;
			int ml, mr;
			__int128 res = 1e18;
			while (l <= r - 3) {
				ml = (2 * l + r) / 3;
				mr = (l + 2 * r) / 3;
				if (cal(ml, s, e) < cal(mr, s, e)) {
					r = mr;
				} else {
					l = ml;
				}
			}
			for (int i = l; i <= r; ++i) {
				__int128 tt = cal(i, s, e);
				if (tt < res) res = tt;
			}
			printf("%d\n", (int)(res % MOD));
		}
	}
	return 0;
}

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/priority_queue.hpp>
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
//#pragma GCC target("avx2")

#define deb(x) cout << #x << " = " << x << "\n"
#define all(x) (x).begin(), (x).end()
#define len(x) (ll) x.size()
#define lsb(x) (x) & -(x)
#define l(x) (x << 1) + 1
#define r(x) (x << 1) + 2

#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound

using namespace std;
// using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef __int128_t big;
typedef pair <ll, ll> pii;
typedef pair <ld, ld> pld;
typedef pair <ll, ll> pll;

//template <class T1, class T2 = less <T1>> using pb_heap = __gnu_pbds::priority_queue <T1, T2, binary_heap_tag>;
//template <class T1, class T2 = null_type, class T3 = less <T1>> using pb_map = tree <T1, T2, T3, rb_tree_tag, tree_order_statistics_node_update>;
//template <class T1, class T2 = null_type, class T3 = hash <T1>> using pb_umap = gp_hash_table <T1, T2, T3>;
template <class T1, class T2, class T3 = hash <T1>> using umap = unordered_map <T1, T2, T3>;
template <class T> using uset = unordered_set <T>;
template <class T> using vec = vector <T>;

const ll infll = numeric_limits <ll>::max() >> 1;
const ll inf = numeric_limits <ll>::max() >> 1;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
ll n, q;
ll a[N];
ll w[N];

struct Node {
    ll l, r;
    big sum;
    big prd;
    big all1;
    big all2;
} node[N << 2];

void merge(ll id, ll l, ll r) {
    ll q = node[id].l + node[id].r >> 1;
    node[id].sum = node[l].sum + node[r].sum;
    node[id].prd = node[l].prd + node[r].prd;
    node[id].all1 = node[l].all1 + node[l].sum * (node[id].r - q) + node[r].all1;
    node[id].all2 = node[r].all2 + node[r].sum * (q - node[id].l + 1) + node[l].all2;
}

void build(ll id, ll l, ll r) {
    node[id].l = l;
    node[id].r = r;
    if(l == r) {
        node[id].sum = w[l];
        node[id].prd = a[l] * w[l];
        return;
    }
    ll q = l + r >> 1;
    build(l(id), l, q);
    build(r(id), q + 1, r);
    merge(id, l(id), r(id));
}

void update(ll id, ll i, ll x) {
    if(node[id].l == node[id].r) {
        node[id].sum = x;
        node[id].prd = x * a[i];
        return;
    }
    ll q = node[id].l + node[id].r >> 1;
    if(i <= q) {
        update(l(id), i, x);
    } else {
        update(r(id), i, x);
    }
    merge(id, l(id), r(id));
}

big sum_query(ll id, ll l, ll r) {
    if(l > r) {
        return 0;
    }
    if(node[id].l == l && node[id].r == r) {
        return node[id].sum;
    }
    big res = 0;
    ll q = node[id].l + node[id].r >> 1;
    if(l <= q) {
        res += sum_query(l(id), l, min(q, r));
    }
    if(r > q) {
        res += sum_query(r(id), max(q + 1, l), r);
    }
    return res;
}

big prd_query(ll id, ll l, ll r) {
    if(l > r) {
        return 0;
    }
    if(node[id].l == l && node[id].r == r) {
        return node[id].prd;
    }
    big res = 0;
    ll q = node[id].l + node[id].r >> 1;
    if(l <= q) {
        res += prd_query(l(id), l, min(q, r));
    }
    if(r > q) {
        res += prd_query(r(id), max(q + 1, l), r);
    }
    return res;
}

ll all1_query(ll id, ll l, ll r, ll add = 0) {
    if(l > r) {
        return 0;
    }
    if(node[id].l == l && node[id].r == r) {
        return node[id].all1 + node[id].sum * add;
    }
    big res = 0;
    ll cnt = 0;
    ll q = node[id].l + node[id].r >> 1;
    if(r > q) {
        res += all1_query(r(id), max(q + 1, l), r, add);
        cnt += r - max(q + 1, l) + 1;
    }
    if(l <= q) {
        res += all1_query(l(id), l, min(q, r), add + cnt);
    }
    return res;
}

ll all2_query(ll id, ll l, ll r, ll add = 0) {
    if(l > r) {
        return 0;
    }
    if(node[id].l == l && node[id].r == r) {
        return node[id].all2 + node[id].sum * add;
    }
    big res = 0;
    ll cnt = 0;
    ll q = node[id].l + node[id].r >> 1;
    if(l <= q) {
        res += all2_query(l(id), l, min(q, r), add);
        cnt += min(q, r) - l + 1;
    }
    if(r > q) {
        res += all2_query(r(id), max(q + 1, l), r, add + cnt);
    }
    return res;
}

big f(ll l, ll r, ll mid) {
    big ansl = (big) a[mid] * sum_query(0, l, mid) - (big) prd_query(0, l, mid) - (big) all1_query(0, l, mid);
    big ansr = (big) prd_query(0, mid + 1, r) - (big) a[mid] * (big) sum_query(0, mid + 1, r) - all2_query(0, mid, r);
    return ansl + ansr;
}

ll binary_search(ll l, ll r) {
    ll lef = l;
    ll rig = r;
    while(lef < rig) {
        ll mid = lef + rig + 1 >> 1;
        big ansl = (big) a[mid] * sum_query(0, l, mid) - (big) prd_query(0, l, mid) - (big) all1_query(0, l, mid);
        big ansr = (big) prd_query(0, mid + 1, r) - (big) a[mid] * (big) sum_query(0, mid + 1, r) - all2_query(0, mid, r);
        if(ansl <= ansr) {
            lef = mid;
        } else {
            rig = mid - 1;
        }
    }
    return lef;
}

void input() {
    cin >> n >> q;
    for(ll i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for(ll i = 1; i <= n; ++i) {
        cin >> w[i];
    }
}

void solve() {
    build(0, 1, n);
    for(ll i = 1; i <= q; ++i) {
        ll x; cin >> x;
        ll y; cin >> y;
        if(x < 0) {
            x *= -1;
            update(0, x, y);
            w[x] = y;
        } else {
            ll q = binary_search(x, y);
            big res = f(x, y, q);
            if(q != y) {
                res = min(res, f(x, y, q + 1));
            }
            if(q != x) {
                res = min(res, f(x, y, q - 1));
            }
            cout << (ll) (res % (big) mod) << "\n";
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    input();
    solve();
}

/*
5 8
1 2 6 7 10
1 1 1 1 2
1 1
1 5
1 3
3 5
-3 5
-1 10
1 4
2 5
*/

#include<cstdio>
#include<cstring>
#include<algorithm>
#define lowbit(a) ((a)&(-(a)))
#define ll long long
using namespace std;
const int M=2e5+10;
const ll MOD=1e9+7;
int n,Q;
ll A[M],W[M];
struct bit_tree{
	ll bit[M],Mod;
	void init(ll mod){Mod=mod;}
	void Add(ll &a,ll b){
		a+=b;
		if(Mod!=-1){a%=Mod;if(a<0)a+=Mod;}
	}
	void add(int a,ll v){for(;a<=n;a+=lowbit(a))Add(bit[a],v);}
	ll query(int a){
		if(a<=0) return 0;
		ll res=0;
		for(;a;a-=lowbit(a))Add(res,bit[a]);
		return res;
	}
}b1,b2;
void change_pos(ll p,ll v){
	ll res=v-W[p];
	b1.add(p,res);
	b2.add(p,A[p]*res%MOD);
	W[p]=res;
}
void solve_area(ll le,ll ri){
	if(le==ri){puts("0");return;}
	ll sum=b1.query(le-1);
	sum+=((b1.query(ri)-sum+1)>>1);
	int l=le,r=ri,mid;
	while(l<r){
		mid=l+r>>1;
		if(b1.query(mid)>=sum)r=mid;
		else l=mid+1;
	}
	ll all=b2.query(ri)-b2.query(le-1)-2ll*b2.query(l);
	all%=MOD;if(all<0)all+=MOD;
	sum=b1.query(l);
	ll bef=sum-b1.query(le-1)+sum-b1.query(ri);
	bef%=MOD;if(bef<0)bef+=MOD;
	printf("%I64d\n",(all+bef*A[l]%MOD)%MOD);
}
ll a,b;
int main(){
	b1.init(-1);b2.init(MOD);
	scanf("%d%d",&n,&Q);
	for(int i=1;i<=n;i++){scanf("%I64d",&A[i]);A[i]-=i;}
	for(int i=1;i<=n;i++)scanf("%I64d",&W[i]);
	for(int i=1;i<=n;i++)b1.add(i,W[i]),b2.add(i,A[i]*W[i]%MOD);
	while(Q--){
		scanf("%I64d%I64d",&a,&b);
		if(a<0) change_pos(-a,b);
		else solve_area(a,b);
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ull = unsigned ll;

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x first
#define y second

const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};
const char dir[] = {'R', 'L', 'D', 'U'};

int add(int a, int b){ //(a + b) % 1e9 + 7
    a += b;
    if(a >= MOD){
        a -= MOD;
    }
    return a;
}

int sub(int a, int b){
    a -= b;
    if(a < 0) a += MOD;
    return a;
}

int mult(int a, int b){
    return ((ll) a * b) % MOD;
}

void setIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
//    freopen((s+".in").c_str(),"r",stdin);
//    freopen((s+".text").c_str(),"w",stdout);
}

const int mxN = 200'000;

struct bit{
    ll tree[mxN + 5];
    void update(int index, ll val) {
        index++;
        while(index < mxN + 5) {
            tree[index] += val;
            index += index & -index;
        }
    }
    ll query(int index) {
        ll ret = 0;
        index++;
        while(index > 0) {
            ret += tree[index];
            index -= index & -index;
        }
        return ret;
    }
    ll rquery(int a, int b) {
        return query(b)-query(a-1);
    }
};
struct bit2{
    int tree[mxN + 5];
    void update(int index, int val) {
        index++;
        while(index < mxN + 5) {
            tree[index] = add(tree[index], val);
            index += index & -index;
        }
    }
    int query(int index) {
        int ret = 0;
        index++;
        while(index > 0) {
            ret = add(ret, tree[index]);
            index -= index & -index;
        }
        return ret;
    }
    int rquery(int a, int b) {
        return sub(query(b), query(a-1));
    }
};
int n, q;
int a[mxN], w[mxN];

int main(){
    setIO();
    //CHECK FOR LONG LONG!!!
    //LONG LONG OVERFLOW??
    cin >> n >> q;
    bit s;
    bit2 wa;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        a[i] -= i;
    }
    for(int i = 0; i < n; ++i){
        cin >> w[i];
        s.update(i, w[i]);
        wa.update(i, mult(a[i], w[i]));
    }
    while(q--){
        int x, y; cin >> x >> y;
        if(x < 0){
            x = -x; --x;
            s.update(x, -w[x]);
            wa.update(x, -mult(w[x], a[x]));
            w[x] = y;
            s.update(x, w[x]);
            wa.update(x, mult(w[x], a[x]));
        }
        else{
            --x; --y;
            if(x == y){
                cout << "0\n";
                continue;
            }
            ll tot = s.rquery(x, y);
            int l = x, r = y;
            while(l < r){
                int m = (l + r + 1) / 2;
                if(2 * s.rquery(x, m) <= tot){
                    l = m;
                }
                else{
                    r = m - 1;
                }
            }
            ++l;
            int left = sub(mult(s.rquery(x, l - 1), a[l]), wa.rquery(x, l - 1));
            int right = sub(wa.rquery(l, y), mult(s.rquery(l, y), a[l]));
            cout << add(left, right) << "\n";
        }
    }
    //CHECK FOR LONG LONG!!!
}

#include <bits/stdc++.h>
using namespace std;

#define N 200005
const int mod = 1e9 + 7;
#define ll long long

int a[N],w[N];
ll pen[N];

int add(int x,int y) {
  return ((x+y)%mod+mod)%mod;
}
int mul(int x,int y) {
  return (ll)x*y%mod;
}
int mypow(int x,int c) {
  int ret = 1;
  while(c>0) {
    if(c&1) {
      ret = mul(ret,x);
    }
    c/=2;
    x = mul(x,x);
  }
  return ret;
}

void update(int ind,ll ad) {
  while(ind<N) {
    pen[ind] += ad;
    ind += ind&(-ind);
  }
}

ll query(int ind) {
  ll ret = 0;
  while(ind>0) {
    ret += pen[ind];
    ind = ind&(ind-1);
  }
  return ret;
}

int seg[N*4];

void init(int pos,int l,int r) {
  if(l==r) {
    seg[pos] = mul(a[l],w[l]);
    return;
  }
  int mid = (l+r)/2;
  init(pos*2,l,mid);
  init(pos*2+1,mid+1,r);
  seg[pos] = add(seg[pos*2],seg[pos*2+1]);
}

void update(int pos,int l,int r,int ind) {
  if(l==r) {
    seg[pos] = mul(a[l],w[l]);
    return;
  }
  int mid = (l+r)/2;
  if(ind<=mid)
    update(pos*2,l,mid,ind);
  else
    update(pos*2+1,mid+1,r,ind);
  seg[pos] = add(seg[pos*2],seg[pos*2+1]);
}

int query(int pos,int l,int r,int ql,int qr) {
  if(r<ql || qr<l) {
    return 0;
  }
  if(ql<=l && r<=qr) {
    return seg[pos];
  }
  int mid = (l+r)/2;
  return add(query(pos*2,l,mid,ql,qr),query(pos*2+1,mid+1,r,ql,qr));
}

ll sum(int x,int y) {
  return query(y) - query(x-1);
}

int pre[N];

void solve() {
  int n,q;
  scanf("%d %d ", &n,&q);
  for(int i=1;i<=n;++i) {
    scanf("%d ", &a[i]);
    a[i] = a[i] - i;
    pre[i] = add(pre[i-1],a[i]);
  }
  for(int i=1;i<=n;++i) {
    scanf("%d ", &w[i]);
    update(i,w[i]);
  }
  init(1,1,n);

  while(q--) {
    int x,y;
    scanf("%d %d ", &x,&y);
    if(x<0) {
      //type 1
      int ind = -x;
      update(ind,-w[ind] + y);
      w[ind] = y;
      update(1,1,n,ind);
    } else {
      if(y-x==0) {
        printf("0\n");
      } else {
        int l = x,r = y,mid;
        ll total = sum(x,y);
        while(l<r) {
          mid = (l+r)/2;
          if(sum(x,mid)*2>total) {
            r = mid;
          } else {
            l = mid + 1;
          }
        }
        assert(sum(x,l-1)*2<=total);
        int ret = 0;
        if(x<=l-1) {
          ret = add( mul(sum(x,l-1),a[l]),-query(1,1,n,x,l-1)) ;
        }
        if(l<=y) {
          ret = add(ret, query(1,1,n,l,y));
          ret = add(ret, -mul(sum(l,y),a[l]));
        }
        printf("%d\n",ret);
      }
    }
  }
}

int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}

#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;

class P {
public:
	ll x, y;
	P() {}
	P(ll xx, ll yy) {
		x = xx;
		y = yy;
	}
	P operator +(P p) {
		P res=P(x + p.x, y + p.y);
		if(res.y>=MOD){
			res.y-=MOD;
			res.x++;
		}
		return res;
	}
	P operator -(P p) {
		P res=P(x-p.x,y-p.y);
		if(res.y<0){
			res.y+=MOD;
			res.x--;
		}
		return res;
	}
	P operator *(ll a) {
		P res=P(a*x,a*y);
		res.x+=res.y/MOD;
		res.y%=MOD;
		return res;
	}
	bool operator<(const P &p)const {
		return x != p.x ? x < p.x : y < p.y;
	}

};

int n,q;

ll labs(ll v){
	if(v<0LL)return -v;
	return v;
}

class segtree{
public:
	P dp[200005];
	segtree(){
		memset(dp,0,sizeof(dp));
	}

	void update(int i,ll v){
		P res=P(v/MOD,v%MOD);
		if(v<0LL){
			res.x=(labs(v)+MOD-1)/MOD;
			res.y=MOD*res.x-labs(v);
		}
		i++;
		while(i<=n){
			dp[i]=dp[i]+res;
			i+=i&-i;
		}
	}

	P query(int i){
		P res=P(0,0);
		while(i>0){
			res=res+dp[i];
			i-=i&-i;
		}
		return res;
	}

	P query(int a,int b){
		return query(b)-query(a);
	}
};

segtree seg;
segtree seg2;
ll a[200005],w[200005];
ll sum[200005];

P C(int v,int aa,int bb){
	int l=-1,r=bb-aa+1;
	while(l+1<r){
		int mid=(l+r)/2;
		int pos=a[v+mid];
		//printf("%d %d %d\n",mid,pos,aa+mid);
		if(pos<=aa+mid)l=mid;
		else r=mid;
	}
	l++;
	P res=P(0,0);
	P wv1=seg2.query(v,v+l);
	P wv2=seg2.query(v+l,v+(bb-aa)+1);
	res=wv1*(aa-v)-seg.query(v,v+l);
	res=res+seg.query(v+l,v+(bb-aa)+1)-wv2*(aa-v);
	//printf("%d a=%d b=%d %d w1=%lld w2=%lld aa-v=%d seg1=%lld seg2=%lld res=%lld\n",v,aa,bb,l,wv1,wv2,aa-v,seg.query(v,v+l),seg.query(v+l,v+(bb-aa)+1),res);
	return res;
}

int main(void){
	scanf("%d%d",&n,&q);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%lld",&w[i]);
	}
	for(int i=0;i<n;i++){
		seg.update(i,w[i]*(a[i]-i));
		seg2.update(i,w[i]);
	}
	for(int i=0;i<q;i++){
		int t,v;
		scanf("%d%d",&t,&v);
		if(t<0){
			t=-t;
			t--;
			seg.update(t,(a[t]-t)*(v-w[t]));
			seg2.update(t,v-w[t]);
			w[t]=v;
		}else{
			ll l=a[t-1],r=a[v-1]+1LL;
			while(l+1LL<r){
				ll mid=(l+r)/2;
				P v1=C(t-1,mid-1,mid-1+(v-t))-C(t-1,mid,mid+(v-t));
				if(v1<P(0,0)){
					r=mid;
				}else{
					l=mid;
				}
			}
			P ans=C(t-1,l,l+(v-t));
			//printf("%d\n",l);
			cout << ans.y << endl;
		}
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

#define IO ios::sync_with_stdio(false);cin.tie(0)
#define _rep(i,a,b) for(int i = (a);i<=(b);++i)
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _dep(i,a,b) for(int i = (a);i>=(b);--i)
#define pb push_back
#define fr first
#define sc second
#define all(x) (x).begin(),(x).end()

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;
typedef vector<LL> vl;

const int maxn = 200050;
const LL mod = 1e9+7;

// So,A tricky and beautiful data structure problem,I have closen myself
// for almost 2 hours beacuse I leak a important detail---the moved boxes'
// position should be distinct,FUCK....I even think the tutorial is wrong
// and silly proof,emm...I am a fucking silly boy...
// Now let's have a look at the problem
// Firstly,we can prove there should be at least a unmoved box in
// among the r-l+1 boxes,if all is moved denotes S1 is the left cost and the S2 is the right
// cost, and we can move the "interval" left or right to replace max(S1,S2) with min(S1,S2) until some
// box(es) should be unmoved to form the interval,you can draw a picture to have a look at the condition

// And next,We can prove the unmoved element should statisfy the fact that (let's denote that box's index is k and
// make f(l,r):=w[l]+w[l+1]....+w[r] ) S(l,k-1)<=S(l,r)/2 && S(l,k)>S(l,r)/2
// IF NOT?
// 1--S(l,k-1)>S(l,r)/2 : [l...{...k...}...r] and we denote that the condition is the best ans But we can find
// a new unmoved box---o (it doesn't matter whether it is the a[k-1]) which is left than k exactly bu 1 and
// the cost won't increase so if the k is the best unmoved one the o must not inferior to k
// get contradiction with the fact--k is the best unmoved box,and if S(l,k) still < S(l,r)/2 we can
// let o be the exactly right one also get a contradiction!!!So,now the problem is simply,maintain the
// w[] with Bitree or the Segtree and binary search the k,you can easily get the formular of the unmoved
// k is knowed (TIPS: make relative position between a[i] and i),SO orz...When can I come up with so beautiful
// constructive strategy....

inline int lowbit(int x){return x&(-x);}

LL pos[maxn];
LL we[maxn];
LL val[maxn][3];
LL sum[maxn][3];
// 0--is the sum_w
// 1--is the sum_w[i]*pos[i]
// 2--is the sum_w[i]*i
int n;
int k;
void modify(int p,LL v)
{
	LL vv = v+mod;
	vv = vv%mod;
	for(int i=p;i<=n;i+=lowbit(i))
	{
		_for(j,1,3)
			sum[i][j]=(sum[i][j]+vv*val[p][j])%mod,sum[i][j]+=mod,sum[i][j]%=mod;
		sum[i][0]+=v;
	}
}

LL Aid(int x,int id)
{
	LL ans = 0;
	for(int i = x;i;i-=lowbit(i))
	{
		ans+=sum[i][id];
		if(id)ans%=mod;
	}
	return ans;
}

inline LL qury(int l,int r,int id=0)
{
	if(r<l)return 0LL;
	LL ans = Aid(r,id)-Aid(l-1,id);
	if(id) ans+=mod,ans%=mod;
	return ans;
}

inline void getK(int l,int r)
{
	LL qq = qury(l,r);
	const LL ha = qq/2+qq%2;
	int nl = l;
	while(l<r)
	{
		int mid = r-(r-l+1)/2;
		if(ha<qury(nl,mid)) r = mid;
		else l = mid+1;
	}
	k = r;
	//cout<<k<<"-----------\n\n";
}

int main(void)
{
	IO;
	int q;
	cin>>n>>q;
	_rep(i,1,n) cin>>pos[i];
	_rep(i,1,n) cin>>we[i],val[i][0] = 1,val[i][1] = pos[i],val[i][2] = i,modify(i,we[i]);
	//cout<<qury(3,3)<<endl;
	while(q--)
	{
		int l,r;
		cin>>l>>r;
		//cout<<l<<" "<<r<<endl;
		if(l<0)
		{

			l = -l;
			modify(l,-we[l]),modify(l,r);
			we[l] = r;
		}
		else
		{
			getK(l,r);
			LL ans1,ans2,ans3;
			ans1 = ans2 = ans3 = 0LL;
			ans1 += qury(l,k-1),ans1-=qury(k+1,r),ans1 = (ans1+mod)%mod,ans1 = ans1*(pos[k]-k)%mod;
			ans2 -=qury(l,k-1,1),ans2+=qury(k+1,r,1),ans2+=mod,ans2%=mod;
			ans3 +=qury(l,k-1,2),ans3-=qury(k+1,r,2),ans3+=mod,ans3%=mod;
			cout<<(ans1+ans2+ans3)%mod<<endl;
		}
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
struct seg{
  LL sum = 0;
  seg* ch[2] = {nullptr, nullptr};
  int l, r, m;
  void pull() {
    sum = ch[0] -> sum + ch[1] -> sum;
  }
  seg(int l, int r, vector<LL> &A) : l(l), r(r) {
    if (r - l > 1) {
      m = l + r >> 1;
      ch[0] = new seg(l, m, A);
      ch[1] = new seg(m, r, A);
      pull();
    }
    else sum = A[l];
  }
  void modify(int x, LL val) {
    if (r - l == 1) return sum = val, void();
    if (x < m) ch[0] -> modify(x, val);
    if (m <= x) ch[1] -> modify(x, val);
    pull();
  }
  LL query(int L, int R) {
    if (L >= R) return 0;
    if (L <= l and r <= R) return sum;
    LL ans = 0;
    if (L < m) ans += ch[0] -> query(L, R);
    if (m < R) ans += ch[1] -> query(L, R);
    return ans;
  }
};
signed main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n, q; cin >> n >> q;
  vector<LL> w(n), wr(n), a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i)
    cin >> w[i], wr[i] = (w[i] * (i - a[i]) % MOD + MOD) % MOD;
  seg *wrT = new seg(0, n, wr), *wT = new seg(0, n, w);
  auto ask = [&](int l, int r, int m) {
    return ((a[m] - m) * wT->query(l, r) + wrT->query(l, r)) % MOD;
  };
  auto queryL = [&](int l, int r, int m) {
    LL ans = ask(l, m, m) - ask(m, r, m);
    return (ans % MOD + MOD) % MOD;
  };
  while (q--) {
    LL m = 0, l, r; cin >> l >> r;
    if (l < 0)
      l = -l - 1, wT->modify(l, r), wrT->modify(l, r * (l - a[l] + MOD) % MOD);
    else {
      --l;
      int ml = l, mr = r;
      LL target = wT->query(l, r);
      while (mr - ml > 1) {
        m = ml + mr >> 1;
        if (wT->query(l, m) * 2 >= target) mr = m;
        else ml = m;
      }
      cout << queryL(l, r, mr - 1) << '\n';
    }
  }
}

#include <bits/stdc++.h>
using namespace std;

#define N 200010
typedef long long LL;
const int mod = 1e9 + 7;
const double EPS = 1e-12;

LL a[N], w[N];
LL s[N << 2], s2[N << 2], sum, now, ans;
LL ql;
int pp, flag;
LL md;

void build(int x, int l, int r)
{
	if (l == r)
	{
		s[x] = w[l];
		s2[x] = w[l] * (a[l] - l) % mod;
		return;
	}
	int mid = (l + r) >> 1;
	build(x << 1, l, mid);
	build(x << 1 | 1, mid + 1, r);
	s[x] = s[x << 1] + s[x << 1 | 1];
	s2[x] = (s2[x << 1] + s2[x << 1 | 1]) % mod;
}

void modify(int x, int l, int r, int pos, int v)
{
	if (l == r)
	{
	    s[x] = w[l];
		s2[x] = w[l] * (a[l] - l) % mod;
		return;
	}
	int mid = (l + r) >> 1;
	if (pos <= mid) modify(x << 1, l, mid, pos, v);
	else modify(x << 1 | 1, mid + 1, r, pos, v);
	s[x] = s[x << 1] + s[x << 1 | 1];
	s2[x] = (s2[x << 1] + s2[x << 1 | 1]) % mod;
}

void Qsum(int x, int L, int R, int l, int r)
{
	if (l <= L && r >= R) {sum += s[x]; return;}
	if (l > R || r < L) return;

	int Mid = (L + R) >> 1;
	Qsum(x << 1, L, Mid, l, r);
	Qsum(x << 1 | 1, Mid + 1, R, l, r);
}

void calc(int x, int L, int R, int l, int r)
{
    int Mid = (L + R) >> 1;
	if (l <= L && r >= R)
	{
		if (L == R)
		{
		    now += s[x];
			pp = L;
			return;
		}
		if (now + s[x << 1] < sum / 2)
		{
			now += s[x << 1];
			calc(x << 1 | 1, Mid + 1, R, l, r);
		}
		else calc(x << 1, L, Mid, l, r);
		return;
	}
	if (r <= Mid)
	{
	    calc(x << 1, L, Mid, l, r);
	    return;
	}
	if (l > Mid)
	{
	   calc(x << 1 | 1, Mid + 1, R, l, r);
	   return;
    }

	calc(x << 1, L, Mid, l, r);
	if (now < sum / 2)
	   calc(x << 1 | 1, Mid + 1, R, l, r);
}

LL QQ(int x, int L, int R, int l, int r)
{
	LL res = 0;
    if (l <= L && r >= R)
	{
	    res += s2[x];
	    res += (ql - md) * (s[x] % mod) % mod;
	    res %= mod;
	    if (res < 0) res += mod;
	    return res;
	}
    if (l > R || r < L) return 0;
    int Mid = (L + R) >> 1;
    return (QQ(x << 1, L, Mid, l, r) + QQ(x << 1 | 1, Mid + 1, R, l, r)) % mod;
}
int main()
{
   // freopen("in.txt", "r", stdin);

    int n, q;
    scanf("%d %d", &n, &q);
    for (int i = 1; i <= n; ++i)
    	scanf("%I64d", &a[i]);
   	for (int i = 1; i <= n; ++i)
   		scanf("%I64d", &w[i]);
   	build(1, 1, n);
   	while (q--)
   	{
   		int x, y;
   		scanf("%d %d", &x, &y);
   		if (x < 0)
   		{
   			w[-x] = y;
   			modify(1, 1, n, -x, y);
   		}
   		else
   		{
   			if (x == y) {puts("0"); continue;}
   			ql = x;
   			sum = 0; ans = 0;
		    Qsum(1, 1, n, x, y);
		    now = 0;
   			calc(1, 1, n, x, y);
   			LL cur = 0;
   			for (int k = x; k <= y; ++k)
   			{
   				cur += w[k];
   				if (cur >= sum / 2)
   				{
   					assert(pp == k);
   					break;
   				}
   			}
   			md = a[pp] - (pp - x);
   			if (x <= pp) ans -= QQ(1, 1, n, x, pp);
   			if (pp + 1 <= y) ans += QQ(1, 1, n, pp + 1, y);
   			ans %= mod;
   			if (ans < 0) ans += mod;
   			printf("%I64d\n", ans);
   		}
   	}
	return 0;
}

#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
struct seg_node
{
	ll l,r,lazy,mx;
}seg[800005];
ll n,ans,q,i,j,a[200005],sm[200005],w[200005],tr[200005],l,r,pos,u,v,d;
const ll mod=1e9+7;
ll lowbit(ll p){return p&-p;}
ll add(ll a,ll b){return a+b>=mod?a+b-mod:(a+b<0?a+b+mod:a+b);}
void Add(int p,ll v)
{
	while(p<=n)
	{
		tr[p]=add(tr[p],v);
		p+=lowbit(p);
	}
}
ll ask(ll p)
{
	ll ans=0;
	while(p)
	{
		ans=add(ans,tr[p]);
		p-=lowbit(p);
	}
	return ans;
}
void build(int p,int l,int r)
{
	int mid;
	seg[p].l=l;seg[p].r=r;
	if(l==r)seg[p].mx=sm[l];
	else
	{
		mid=(l+r)/2;
		build(2*p,l,mid);
		build(2*p+1,mid+1,r);
		seg[p].mx=max(seg[2*p].mx,seg[2*p+1].mx);
	}
}
void push(int p)
{
	if(seg[p].l==seg[p].r)return;
	seg[2*p].mx+=seg[p].lazy;
	seg[2*p].lazy+=seg[p].lazy;
	seg[2*p+1].mx+=seg[p].lazy;
	seg[2*p+1].lazy+=seg[p].lazy;
	seg[p].lazy=0;
}
int identify(int p,ll l,ll r)
{
	if(seg[p].l==seg[p].r)return seg[p].l;
	if(seg[p].lazy)push(p);
	if(seg[2*p].mx-l>=r-seg[2*p].mx)return identify(2*p,l,r);
	else return identify(2*p+1,l,r);
}
void modify(int p,int l,ll v)
{
	if(seg[p].r<l)return;
	if(seg[p].l>=l)seg[p].mx+=v,seg[p].lazy+=v;
	else
	{
		if(seg[p].lazy)push(p);
		modify(2*p,l,v);
		modify(2*p+1,l,v);
		seg[p].mx=max(seg[2*p].mx,seg[2*p+1].mx);
	}
}
ll query(int p,int l)
{
	int mid;
	if(!l)return 0;
	if(seg[p].l==seg[p].r)return seg[p].mx;
	if(seg[p].lazy)push(p);
	mid=(seg[p].l+seg[p].r)/2;
	if(l<=mid)return query(2*p,l);
	else return query(2*p+1,l);
}
int main()
{
	scanf("%I64d%I64d",&n,&q);
	for(i=1;i<=n;i++)scanf("%I64d",&a[i]);
	for(i=1;i<=n;i++)scanf("%I64d",&w[i]),Add(i,(a[i]-i)*w[i]%mod),sm[i]=sm[i-1]+w[i];
	build(1,1,n);
	for(i=1;i<=q;i++)
	{
		scanf("%I64d%I64d",&l,&r);
		if(l<0)
		{
			Add(-l,((a[-l]+l)*(r-w[-l])%mod+mod)%mod);
			modify(1,-l,r-w[-l]);
			w[-l]=r;
		}
		else
		{
			u=query(1,l-1);v=query(1,r);
			pos=identify(1,u,v);
			d=query(1,pos-1);
			ans=(((ask(r)-ask(pos-1)+(pos-a[pos])*(v-d))%mod+((d+w[pos]-u)*(a[pos]-pos)-ask(pos)+ask(l-1))%mod)%mod+mod)%mod;
			printf("%I64d\n",ans);
		}
	}
	return 0;
}

/*
░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░▐▐▐▐▐▐░░░░░░░
░░░░░░░░░░▐▐▌▌▌▌▌▌▐▐░░░░░
░░░░░░░░░▐▌▌▌▌▌▌▌▌▌▌▐░░░░
░░░░░░░░▐░░▌◐░▌▌▌◐░░░▐░░░
░░░░░░░░▐░░░░░░░░░░░░▐░░░
░░░░░░░░▐░░░░░▐░░░░░░▐░░░
░░░░░░░░░▐░░░▐▐▐░░░░░▐░░░
░░░░░░░░░▐░░░░░░░░░░▐░░░░
░░░░░░░░░░▐░░████░░▐░░░░░
запускаем░░▐░░░░░░░▐░░░░░
░░░░Влада░░▐░░░░░░▐░░░░░░
░░░Макеева░░▐░░░░▐░░░░░░░
░░░░░░░░░░░░░▐▐▐▐░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░
*/

#include <cstdio>

/** Interface */

inline int readChar();
template <class T = int> inline T readInt();
template <class T> inline void writeInt( T x, char end = 0 );
inline void writeChar( int x );
inline void writeWord( const char *s );

/** Read */

static const int buf_size = 4096;

inline int getChar() {
	static char buf[buf_size];
	static int len = 0, pos = 0;
	if (pos == len)
		pos = 0, len = fread(buf, 1, buf_size, stdin);
	if (pos == len)
		return -1;
	return buf[pos++];
}

inline int readChar() {
	int c = getChar();
	while (c <= 32)
		c = getChar();
	return c;
}

template <class T>
inline T readInt() {
	int s = 1, c = readChar();
	T x = 0;
	if (c == '-')
		s = -1, c = getChar();
	while ('0' <= c && c <= '9')
		x = x * 10 + c - '0', c = getChar();
	return s == 1 ? x : -x;
}

/** Write */

static int write_pos = 0;
static char write_buf[buf_size];

inline void writeChar( int x ) {
	if (write_pos == buf_size)
		fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
	write_buf[write_pos++] = x;
}

template <class T>
inline void writeInt( T x, char end ) {
	if (x < 0)
		writeChar('-'), x = -x;

	char s[24];
	int n = 0;
	while (x || !n)
		s[n++] = '0' + x % 10, x /= 10;
	while (n--)
		writeChar(s[n]);
	if (end)
		writeChar(end);
}

inline void writeWord( const char *s ) {
	while (*s)
		writeChar(*s++);
}

struct Flusher {
	~Flusher() {
		if (write_pos)
			fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
	}
} flusher;

inline void readWord( char *s ) {
	int c = readChar();
	while (c > 32)
		*s++ = c, c = getChar();
	*s = 0;
}

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define sz(a) (int)((a).size())
#define all(a) begin(a), end(a)
#define pb push_back
#define x first
#define y second
//#define int ll
#define NAME ""

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using ull = unsigned long long;

const int maxn = 2e5;
const int mod = 998244353;
const int M = 1e9 + 7;
const int inf = 1e4;
const ll inf64 = 3e18L;
const ld pi = acos((ld)-1.0);
const ld eps = (ld)1e-6;
const int di[] = {0, 0, 1,-1, 0};
const int dj[] = {1,-1, 0, 0, 0};
const int SQ = 1000;

struct utree {
    int n; vll t;
    utree(int n) : n(n), t(2 * n, 0) {}
    void upd(int v, ll x) {
        t[v += n] = x;
        for(v >>= 1; v; v >>= 1) t[v] = t[v * 2] + t[v * 2 + 1];
    }
    ll get(int l, int r) {
        ll ret = 0;
        for(l += n, r += n; l <= r; l = (l + 1) >> 1, r = (r - 1) >> 1) {
            if(l & 1) ret += t[l];
            if(!(r & 1)) ret += t[r];
        }
        return ret;
    }
};
struct tree {
    int n; vll t;
    tree(int n) : n(n), t(2 * n, 0) {}
    void upd(int v, ll x) {
        x %= M;
        t[v += n] = x;
        for(v >>= 1; v; v >>= 1) t[v] = (t[v * 2] + t[v * 2 + 1]) % M;
    }
    ll get(int l, int r) {
        ll ret = 0;
        for(l += n, r += n; l <= r; l = (l + 1) >> 1, r = (r - 1) >> 1) {
            if(l & 1) ret = (ret + t[l]) % M;
            if(!(r & 1)) ret = (ret + t[r]) % M;
        }
        return ret;
    }
};

int n, q, a[maxn], w[maxn];
utree t1(maxn);
utree t2(maxn);

main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //freopen(NAME".in", "r", stdin); freopen(NAME".out", "w", stdout);
    //freopen("in.txt", "r", stdin);
    cin >> n >> q;
    for(int i = 0; i < n; i++) cin >> a[i], a[i] -= i;
    for(int i = 0; i < n; i++) cin >> w[i];
    for(int i = 0; i < n; i++) {
        t1.upd(i, w[i]);
        t2.upd(i, 1LL * a[i] * w[i]);
    }
    while(q--) {
        int x, y; cin >> x >> y;
        if(x < 0) {
            x = -x - 1;
            t1.upd(x, y);
            t2.upd(x, 1LL * a[x] * y);
        } else {
            x--; y--;
            int lf = x, rg = y;
//            ll ans = inf64;
//            for(int lf = x; lf <= y; lf++)
//                ans = min(ans, (1LL*a[lf]*t1.get(x,lf) - t2.get(x,lf) + t2.get(lf,y) - 1LL*a[lf]*t1.get(lf,y)));
           // cout << ans % M << '\n';
//            for(int i = x; i < y; i++) {
//                int md = i;
//                ll A = (1LL*a[md]*t1.get(x,md) - t2.get(x,md) + t2.get(md,y) - 1LL*a[md]*t1.get(md,y));
//                ll B = (1LL*a[md+1]*t1.get(x,md+1) - t2.get(x,md+1) + t2.get(md+1,y) - 1LL*a[md+1]*t1.get(md+1,y));
//                if(B - A > 0) break;
//                lf++;
//            }

            while(lf < rg) {
                int md = (lf + rg) >> 1;
                //if(1ULL * (md - x + 1) * t1.get(x, md) >= 1ULL * (y - md) * t1.get(md + 1, y)) rg = md;
                //else lf = md + 1;
                ll A = (1LL*a[md]*t1.get(x,md) - t2.get(x,md) + t2.get(md,y) - 1LL*a[md]*t1.get(md,y));
                ll B = (1LL*a[md+1]*t1.get(x,md+1) - t2.get(x,md+1) + t2.get(md+1,y) - 1LL*a[md+1]*t1.get(md+1,y));
                if(B - A > 0) rg = md;
                else lf = md + 1;
            }
//            ll ans = inf64;
//            lf--;
//            for(int i = 0; i < 3; i++, lf++)
//                if(x <= lf && lf <= y)
//                    ans = min(ans, (1LL*a[lf]*t1.get(x,lf) - t2.get(x,lf) + t2.get(lf,y) - 1LL*a[lf]*t1.get(lf,y)));
            //cout << ans % M << '\n';
            cout << ((1LL*a[lf]*(t1.get(x,lf)%M)%M - t2.get(x,lf) + t2.get(lf,y) - 1LL*a[lf]*(t1.get(lf,y)%M)%M) % M + M) % M << '\n';
        }
    }
}

#include <bits/stdc++.h>

using namespace std;
#define IOS ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>

typedef long long ll;
const int maxn=200005;
const int mod=1000000007;
ll a[maxn],w[maxn];
ll pos[maxn];
int n,q;
struct Bit{
    ll sum[maxn];
    int n;
    bool mod_flag;
    Bit(int n_){
        n=n_;
        mod_flag=true;
        memset(sum,0,sizeof sum);
    }
    void init(int n_,bool flag=true){
        n=n_;
        mod_flag=flag;
    }
    void add(int x,ll val){
        while(x<=n){
            sum[x]+=val;
            if(mod_flag)
            {
                if(sum[x]<0)sum[x]+=mod;
                if(sum[x]>=mod)sum[x]%=mod;
            }
            x+=x&-x;
        }
    }
    ll get(int x){
        ll res=0;
        while(x){
            res+=sum[x];
            if(mod_flag)
            {
                if(res>=mod)res%=mod;
            }
            x-=x&-x;
        }
        return res;
    }
    ll query(int l,int r){
        ll res=get(r)-get(l-1);
        if(mod_flag)
        {
            res=(res+mod)%mod;
        }
        return res;
    }
};
Bit bit1(maxn),bit2(maxn),bit3(maxn);
int main()
{
//    IOS;
    cin>>n>>q;
    int m=1e9;
    bit1.init(n,false);bit2.init(n);bit3.init(n);
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++){
        cin>>w[i];
        pos[i]=m-(n-i);
        bit1.add(i,w[i]);
        bit2.add(i,w[i]*(a[i]-i));
        bit3.add(i,w[i]*(pos[i]-a[i]));
    }
    while(q--){
        int x,y;
        cin>>x>>y;
        if(x<0){
            int id=-x;
            bit1.add(id,-w[id]);
            bit2.add(id,(a[id]-id)*(mod-w[id]));
            bit3.add(id,(pos[id]-a[id])*(mod-w[id]));
            w[id]=y;
            bit1.add(id,w[id]);
            bit2.add(id,(a[id]-id)*w[id]);
            bit3.add(id,(pos[id]-a[id])*w[id]);
        }else {
            ll res=bit1.get(y)-bit1.get(x-1);
            ll middlesum=res/2;
            int l=x,r=y,opt=-1;
            while(l<=r){
                int m=(l+r)>>1;
                if(bit1.get(m)-bit1.get(x-1)>middlesum)r=m-1,opt=m;
                else l=m+1;
            }
//            cout<<"opt:"<<x<<" "<<y<<" "<<opt<<endl;
            ll ans=0;
            if(opt<y){
                ll diff=a[opt]-opt;
                ll rsum=bit1.query(opt+1,y);
                ans=(ans+bit2.query(opt+1,y)-rsum*diff%mod+mod)%mod;
//                cout<<"ansr:"<<ans<<" "<<diff<<" "<<rsum<<endl;
            }
            if(opt>x){
                ll diff=pos[opt]-a[opt];
                ll lsum=bit1.query(x,opt-1);
                ans=(ans+bit3.query(x,opt-1)-lsum*diff%mod+mod)%mod;
//                cout<<"ansl:"<<ans<<" "<<diff<<" "<<lsum<<endl;
            }
            cout<<ans<<endl;
        }
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int maxn=212345;
const long long mod=1e9+7;
int n,q,w[maxn],a[maxn];
long long bit1[maxn],bit2[maxn];
long double bit11[maxn],bit22[maxn];
inline void update(long long *bit,int x,long long v,bool flag=false) {
    if (flag) v=(v%mod+mod)%mod;
    while (x<=n) {
        bit[x]+=v;
        if (flag) bit[x]%=mod;
        x+=x&-x;
    }
}
inline long long sum(long long *bit,int x,bool flag=false) {
    long long ret=0;
    while (x) {
        ret+=bit[x];
        if (flag) ret%=mod;
        x-=x&-x;
    }
    return ret;
}
inline void update(long double *bit,int x,long long v) {
    while (x<=n) {
        bit[x]+=v;
        x+=x&-x;
    }
}
inline long double sum(long double *bit,int x) {
    long double ret=0;
    while (x) {
        ret+=bit[x];
        x-=x&-x;
    }
    return ret;
}
inline long long getans(int x,int y,int res) {
    long long sum1=(sum(bit1,res)-sum(bit1,x-1))%mod*a[res]%mod-(sum(bit2,res,true)-sum(bit2,x-1,true))%mod;
    long long sum2=(sum(bit2,y,true)-sum(bit2,res,true))%mod-(sum(bit1,y)-sum(bit1,res))%mod*a[res]%mod;
    return ((sum1+sum2)%mod+mod)%mod;
}
inline long double getcost(int x,int y,int res) {
    //printf("x=%d y=%d res=%d\n",x,y,res);
    long double sum1=(sum(bit11,res)-sum(bit11,x-1))*a[res]-sum(bit22,res)-sum(bit22,x-1);
    long double sum2=sum(bit22,y)-sum(bit22,res)-(sum(bit11,y)-sum(bit11,res))*a[res];
    return sum1+sum2;
}
inline int getpos(int left,int right) {
    long double l=left,r=right;
    for (int i=0;r-l>0.5;++i) {
        long double mid=l+(r-l)/3,midmid=l+2*(r-l)/3;
        long double cost1=getcost(left,right,(int)floor(mid));
        long double cost2=getcost(left,right,(int)ceil(midmid));
        if (cost1>=cost2) l=mid;
        else r=midmid;
    }
    long double pos=(l+r)/2.0;
    //printf("%.12f\n",(double)pos);
    long double cost1=getcost(left,right,(int)ceil(pos));
    long double cost2=getcost(left,right,(int)floor(pos));
    //printf("%.12f %.12f\n",(double)cost1,(double)cost2);
    if (cost1<=cost2) return (int)ceil(pos);
    return (int)floor(pos);
}
int main()
{
    scanf("%d%d",&n,&q);
    for (int i=1;i<=n;++i) scanf("%d",&a[i]),a[i]-=i;
    for (int i=1;i<=n;++i) {
        scanf("%d",&w[i]);
        update(bit1,i,w[i]);
        update(bit2,i,1LL*a[i]*w[i]%mod,true);
        update(bit11,i,w[i]);
        update(bit22,i,1.0*a[i]*w[i]);
    }
    while (q--) {
        int x,y;scanf("%d%d",&x,&y);
        if (x<0) {
            x=-x;
            update(bit1,x,y-w[x]);
            update(bit2,x,1LL*a[x]*(y-w[x])%mod,true);
            update(bit11,x,y-w[x]);
            update(bit22,x,1.0*a[x]*(y-w[x]));
            w[x]=y;
        } else {
            if (x==y) {
                puts("0");
                continue;
            }
            int res=getpos(x,y);
            /*
            int left=x,right=y,resres=x;
            long long rev=sum(bit1,x-1);
            long long tot=sum(bit1,y)-rev;
            tot=(tot+1)>>1;
            while (left<=right) {
                int mid=(left+right)>>1;
                if (sum(bit1,mid-1)-rev<tot) {
                    resres=mid;
                    left=mid+1;
                } else right=mid-1;
            }
            printf("resres=%d res=%d\n",resres,res);
            printf("%f %f %d\n",(double)getcost(x,y,1),(double)getcost(x,y,2),getcost(x,y,1)>getcost(x,y,2));
            */
            printf("%I64d\n",getans(x,y,res));
        }
    }
    return 0;
}
/*
3 3
351772224 464078370 812738126
149252109 153315732 540915058
1 2
-3 861733588
-1 190898187
*/

#include <bits/stdc++.h>
using namespace std;

const int maxn = 2e5 + 10;
typedef long long ll;
const ll mod = 1e9 + 7;
ll n,q,a[maxn],w[maxn];
ll seg1[maxn<<2],seg2[maxn<<2];
ll add(ll x,ll y){ return (x + y) % mod;}
ll mul(ll x,ll y){ return x * y % mod;}
ll norm(ll x){
	x %= mod;
	while(x < 0) x += mod;
	while(x >= mod) x -= mod;
	return x;
}

 void change1(int cur,int l,int r,int a,int b,ll delta){
	if(a <= l && r <= b) {
		seg1[cur] += delta;
		return;
	}
	int mid = l + r >> 1;
	if(a <= mid) change1(cur<<1,l, mid,a,b,delta);
	if(b > mid) change1(cur<<1|1,mid + 1,r,a,b,delta);
	seg1[cur] = seg1[cur<<1] + seg1[cur<<1|1];
 }

void change2(int cur,int l,int r,int a,int b,ll delta){
	if(a <= l && r <= b) {
		seg2[cur] = add(seg2[cur],delta);
		return;
	}
	int mid = l + r >> 1;
	if(a <= mid) change2(cur<<1,l,mid,a,b,delta);
	if(b > mid) change2(cur<<1|1,mid + 1,r,a,b,delta);
	seg2[cur] = add(seg2[cur<<1],seg2[cur<<1|1]);
}

ll query1(int cur,int l,int r,int a,int b){
	if(a <= l && r <= b){
		return seg1[cur];
	}
	int mid = l + r >> 1;
	ll re = 0;
	if(a <= mid) re += query1(cur<<1,l,mid,a,b);
   	if(b > mid) re += query1(cur<<1|1,mid + 1,r,a,b);
	return re;
}

ll query2(int cur,int l,int r,int a,int b){
	if(a <= l && r <= b){
		return seg2[cur];
	}
	int mid = l + r>> 1;
	ll re = 0;
	if(a <= mid) re = add(re,query2(cur<<1,l,mid,a,b));
	if(b > mid) re = add(re,query2(cur<<1|1,mid + 1,r,a,b));
	return re;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin>>n>>q;
	for(int i = 1; i <= n; i++) cin>>a[i];
	for(int i = 1; i <= n; i++) cin>>w[i];
	for(int i = 1;i <= n; i++){
		a[i] -= i - 1;
		change1(1,1,n,i,i,w[i]);
		change2(1,1,n,i,i,mul(w[i],a[i]));
	}
	for(int i = 1; i <= q; i++){
		int x,y;
		cin>>x>>y;
		if(x < 0){
			x = -x;
			change1(1,1,n,x,x,-w[x]);
			change2(1,1,n,x,x,-mul(a[x],w[x]));
			w[x] = y;
			change1(1,1,n,x,x,w[x]);
			change2(1,1,n,x,x,mul(a[x],w[x]));

		}
		else{
			int lo = x, hi = y;
			int an = x;
			ll tot = query1(1,1,n,x,y);
			while(lo <= hi){
				int mid = lo + hi >> 1;
				int lft = query1(1,1,n,x,mid);
				if(lft * 2 >= tot) {
					an = mid;
					hi = mid - 1;
				}
				else lo = mid + 1;
			}
			ll ans = norm(mul(a[an],query1(1,1,n,x,an)) - query2(1,1,n,x,an));
			ans = norm(ans + norm(query2(1,1,n,an,y) - mul(a[an],query1(1,1,n,an,y))));
			cout<<ans<<endl;
		}
	}
	return 0;
}

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int a[200005];
int w[200005];
int seg[200005];
int sum[200005];
int mod=1e9+7;
void build(int ver,int tl,int tr)
{
   if(tl>tr)
      return ;
   else if(tl==tr)
   {
      seg[ver]=w[tl];
      sum[ver]=(w[tl]*a[tl])%mod;
   }
   else
   {
      int tm=(tl+tr)/2;
      build(2*ver,tl,tm);
      build(2*ver+1,tm+1,tr);
      seg[ver]=(seg[2*ver]+seg[2*ver+1]);
      sum[ver]=(sum[2*ver]+sum[2*ver+1])%mod;
   }
}

void upd(int ver,int tl,int tr,int pos,int val)
{
   if(tl>tr)
      return ;
   else if(tl==tr)
   {
      seg[ver]=val;
      sum[ver]=val*a[pos]%mod;
   }
   else
   {
      int tm=(tl+tr)/2;
      if(tm>=pos)
         upd(2*ver,tl,tm,pos,val);
      else
         upd(2*ver+1,tm+1,tr,pos,val);
      seg[ver]=(seg[2*ver]+seg[2*ver+1]);
      sum[ver]=(sum[2*ver]+sum[2*ver+1])%mod;
   }
}

int get_sum(int ver,int tl,int tr,int l,int r)
{
   if(tl>tr||l>r||tr<l||r<tl)
      return 0;
   else if(tl==l&& tr==r)
      return seg[ver];
   else
   {
      int tm=(tl+tr)/2;
      return (get_sum(2*ver,tl,tm,l,min(tm,r))+get_sum(2*ver+1,tm+1,tr,max(tm+1,l),r));
   }
}

int get_tot(int ver,int tl,int tr,int l,int r)
{
   if(tl>tr||l>r||tr<l||r<tl)
      return 0;
   else if(tl==l && tr==r)
      return sum[ver];
   else
   {
      int tm=(tl+tr)/2;
      return (get_tot(2*ver,tl,tm,l,min(tm,r))+get_tot(2*ver+1,tm+1,tr,max(tm+1,l),r))%mod;
   }
}

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(0);
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif

// -------------------------------------Code starts here---------------------------------------------------------------------

   int n,q;
   cin>>n>>q;
   for(int i=1;i<=n;i++)
   {
      cin>>a[i];
      a[i]-=i;
   }
   for(int i=1;i<=n;i++)
      cin>>w[i];
   build(1,1,n);
   int x,y;
   while (q--)
   {
      cin>>x>>y;
      if(x<0)
      {
         upd(1,1,n,-x,y);
      }
      else
      {
         int tot=get_sum(1,1,n,x,y);
         int l=x,r=y;
         int ini1=x,ini2=y;
         while (l<=r)
         {
            int mid=l+(r-l)/2;
            int sum=get_sum(1,1,n,l,mid);
            if(2*sum<tot)
            {
               l=mid+1;
               ini1=max(ini1,mid);
            }
            else
            {
               r=mid-1;
               ini2=min(ini2,mid);
            }
         }

         int ans=((get_sum(1,1,n,x,ini2-1)%mod*a[ini2])%mod-get_tot(1,1,n,x,ini2-1)+mod)%mod;
         int ans2=(get_tot(1,1,n,ini2,y)-((get_sum(1,1,n,ini2,y))%mod*a[ini2])%mod+mod)%mod;
         ans=(ans+ans2)%mod;
         cout<<ans<<'\n';
      }

   }

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();

    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

#define int LL
const int N = 2e5 + 5;
const int mod = 1e9 + 7;

int n , q;
int a[N] , w[N];

template <typename T> inline void chkmax(T &x , T y) { x = max(x , y); }
template <typename T> inline void chkmin(T &x , T y) { x = min(x , y); }
template <typename T> inline void read(T &x) {
	T f = 1; x = 0;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - '0';
	x *= f;
}

inline void inc(int &x , int y) {
	x = x + y < mod ? x + y : x + y - mod;
}
inline void dec(int &x , int y) {
	x = x - y >= 0 ? x - y : x - y + mod;
}

struct B1 {
	LL c[N];
	inline int lowbit(int x) {
		return x & (-x);
	}
	inline void mdf(int x , int val) {
		for (int i = x; i <= n; i += lowbit(i)) c[i] += val;
	}
	inline int qry(int x) {
		int ret = 0;
		for (int i = x; i >= 1; i -= lowbit(i)) ret += c[i];
		return ret;
	}
	inline int qry(int l , int r) {
		if (l > r) return 0;
		return qry(r) - qry(l - 1);
	}
} BitSum;

struct B2 {
	int c[N];
	inline int lowbit(int x) {
		return x & (-x);
	}
	inline void mdf(int x , int val) {
		for (int i = x; i <= n; i += lowbit(i)) inc(c[i] , val);
	}
	inline int qry(int x) {
		int ret = 0;
		for (int i = x; i >= 1; i -= lowbit(i)) inc(ret , c[i]);
		return ret;
	}
	inline int qry(int l , int r) {
		if (l > r) return 0;
		int ret = qry(r); dec(ret , qry(l - 1));
		return ret;
	}
} BitMul;

inline int getPos(int x, int y) {
    int ln = x, rn = y, mid, res = 0;
    for(; ln <= rn; ) {
        mid = (ln + rn) / 2;
        if(BitSum.qry(x, mid) >= BitSum.qry(mid + 1, y))
            res = mid, rn = mid - 1;
        else ln = mid + 1;
    }
    return res;
}
inline void solve(int x , int y) {
    if(x == y) {
        puts("0");
        return;
    }
    int pos = getPos(x, y);
    int res = 0LL;
    res = (-BitMul.qry(x , pos) + (BitSum.qry(x , pos) % mod) * abs(a[pos] - pos) % mod + mod) % mod;
    res = (res - (BitSum.qry(pos, y)) % mod * abs(a[pos] - pos) % mod + BitMul.qry(pos, y) + mod) % mod;
    printf("%lld\n", (res % mod + mod) % mod);
}

signed main() {

	read(n) , read(q);
	for (int i = 1; i <= n; ++i) read(a[i]);
	for (int i = 1; i <= n; ++i) {
		read(w[i]);
		BitMul.mdf(i , 1LL * w[i] * (a[i] - i));
		BitSum.mdf(i , w[i]);
	}
	while (q--) {
		int x , y;
		read(x) , read(y);
		if (x < 0) {
			x = -x;
            BitSum.mdf(x, -w[x]);
            BitMul.mdf(x, -1LL * w[x] * (a[x] - x));
            w[x] = 1LL * y;
            BitSum.mdf(x, w[x]);
            BitMul.mdf(x, 1LL * w[x] * (a[x] - x));
		} else solve(x , y);
	}
	return 0;
}

#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define int ll
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
using namespace std;
inline ll read(){
    ll x = 0; char zf = 1; char ch = getchar();
    while (ch != '-' && !isdigit(ch)) ch = getchar();
    if (ch == '-') zf = -1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); return x * zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int i,j,k,m,n,x,y,z,cnt;
int w[200010],v[200010];
struct seg{
	int x,L,R,v,vL,vR,len;
}a[2000010];
void up(int x){
	a[x].v=a[x<<1].v+a[x<<1|1].v;
	a[x].vL=a[x<<1].vL+a[x<<1|1].vL-a[x<<1].len*a[x<<1|1].v;
	a[x].vR=a[x<<1].vR+a[x<<1|1].vR-a[x<<1|1].len*a[x<<1].v;
}
void build(int x,int L,int R){
	a[x].L=L;a[x].R=R;a[x].len=R-L+1;
	if(L==R){
		a[x].vL=(w[L])*v[L];
		a[x].vR=(1000000000-w[L])*v[L];
		a[x].v=v[L];
		return;
	}
	const int mid=L+R>>1;
	build(x<<1,L,mid);build(x<<1|1,mid+1,R);
	up(x);
}
ll queryv(int x,int L,int R){
	if(L>R)return 0;
	if(a[x].L>R||a[x].R<L)return 0;
	if(a[x].L>=L&&a[x].R<=R)return a[x].v;
	return queryv(x<<1,L,R)+queryv(x<<1|1,L,R);
}
ll queryL(int x,int L,int R){
	if(a[x].L>R||a[x].R<L)return 0;
	if(a[x].L>=L&&a[x].R<=R){
		return a[x].vL;
	}
	const int mid=a[x].L+a[x].R>>1;
	if(mid>=R)return queryL(x<<1,L,R);
	if(mid<L)return queryL(x<<1|1,L,R);
	int ret=queryL(x<<1,L,R)+queryL(x<<1|1,L,R)-(a[x<<1].R-max(a[x].L,L)+1)*queryv(1,a[x<<1|1].L,min(a[x].R,R)) ;
	return ret;//-a[x<<1].len*a[x<<1|1].v;
}
ll queryR(int x,int L,int R){
	if(a[x].L>R||a[x].R<L)return 0;
	if(a[x].L>=L&&a[x].R<=R)return a[x].vR;
	const int mid=a[x].L+a[x].R>>1;
	if(mid>=R)return queryR(x<<1,L,R);
	if(mid<L)return queryR(x<<1|1,L,R);
	return queryR(x<<1,L,R)+queryR(x<<1|1,L,R)-(min(a[x].R,R)-a[x<<1].R)*queryv(1,max(a[x].L,L),a[x<<1].R);
}
void change(int x,int t,int z){
	if(a[x].L>t||a[x].R<t)return;
	if(a[x].L==a[x].R){

		a[x].v=z;
		a[x].vL=(w[t])*z;
		a[x].vR=(1000000000-w[t])*z;
		return;
	}
	change(x<<1,t,z);change(x<<1|1,t,z);
	up(x);
}
ll getval(int i){
	return queryR(1,x,i-1)+queryL(1,i+1,y)-queryv(1,x,i-1)*(1000000000-w[i]+1)-queryv(1,i+1,y)*(w[i]+1)	;
}
signed main(){
	n=r;m=r;
	for(rt i=1;i<=n;i++)w[i]=r;
	for(rt i=1;i<=n;i++)v[i]=r;
	build(1,1,n);
	//cout<<queryR(1,1,1)-queryv(1,1,1)*(1000000000-w[2]+1)<<endl;
	while(m--){
		x=r;y=r;
		if(x<0){
			change(1,-x,y);
			continue;
		}
		ll ans=min(queryR(1,x,y-1)-queryv(1,x,y-1)*(1000000000-w[y]-1),
				   queryL(1,x+1,y)-queryv(1,x+1,y)*(w[x]+1));
		int L=x+1,R=y-2;
		ans=min(ans,getval(R-1));
		while(L<=R){
			const int mid=L+R>>1;
			if(getval(mid)<=getval(mid+1)){
				R=mid-1;
			}else L=mid+1;
		}
		ans=min(ans,min(getval(L),getval(R)));
		writeln(ans%1000000007);
	}
	return 0;
}

#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
#include <queue>

using namespace std;
typedef long long lli;
typedef pair<lli,lli> pll;

const lli mod=1e9+7;

int n,q,a[300001];

const int MAX=1<<18;
struct sum_seg{
	lli tr[MAX<<1];
	void upd(int cur,lli val) {
		tr[cur+=MAX] = val;
		cur>>=1;
		while(cur) {
			tr[cur] = tr[cur<<1] + tr[cur<<1|1];
			cur>>=1;
		}
	}
	lli sum(int l,int r) {
		lli res=0;
		l+=MAX;r+=MAX;
		while(l<=r) {
			if(l&1) res+=tr[l++];
			if(!(r&1)) res+=tr[r--];
			l>>=1; r>>=1;
		}
		return res;
	}
}sum;

struct td{
	lli lsum,rsum,lwsum,rwsum;
	td() {}
	td(lli a,lli b,lli c,lli d):lsum(a),rsum(b),lwsum(c),rwsum(d) {}
};
struct wsum_seg {
	lli ltr[MAX<<1],rtr[MAX<<1];
	pll upd(int cur,int s,int f,int idx) {
		if(f<idx || s>idx) return pll(ltr[cur],rtr[cur]);
		else if(s==f) return pll(0,0);
		else {
			int nx=cur<<1,md=(s+f)>>1,l=f-md;
			pll lv=upd(nx,s,md,idx),rv=upd(nx+1,md+1,f,idx);
			ltr[cur] = lv.first+rv.first + sum.tr[nx]*(a[f]-l - a[md]);
			rtr[cur] = lv.first+rv.first + sum.tr[nx+1]*(a[md+1] - (a[s]+l));
			return pll(ltr[cur],rtr[cur]);
		}
	}
	td find(int cur,int s,int f,int l,int r) {
		if(f<l || s>r) return td(0,0,0,0);
		else if(l<=s && f<=r) return td(sum.tr[cur],sum.tr[cur],ltr[cur],rtr[cur]);
		else {
			int nx=cur<<1,md=(s+f)>>1,len=r-md;
			if(r<=md) return find(nx,s,md,l,r);
			else if(l>=md+1) return find(nx+1,md+1,f,l,r);

			td lv=find(nx,s,md,l,r),rv=find(nx+1,md+1,f,l,r);
			td res;
			//printf("#%d %d %d %d\n",s,f,l,r);
			//printf("%lld %lld, %lld %lld\n",lv.first,lv.second,rv.first,rv.second);
			res.lwsum = lv.lwsum+rv.lwsum + lv.lsum*(a[r]-len - a[md]);
			len=md-l+1;
			res.rwsum = lv.rwsum+rv.rwsum + rv.rsum*(a[md+1] - (a[l]+len));
			res.lsum = lv.lsum + rv.lsum;
			res.rsum = lv.rsum + rv.rsum;
			return res;
		}
	}
}wsum;

int get_point(int s,int l,int r) {
	int lo=l-1,up=r+1;
	while(up-lo>1) {
		int md=(lo+up)>>1;
		if(a[md] <= s+(md-l)) lo=md;
		else up=md;
	}
	return lo;
}

int main() {
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	for(int i=n+1;i<MAX;i++) a[i] = a[i-1]+1;
	for(int i=1;i<=n;i++) {
		lli val;
		scanf("%lld",&val);
		sum.upd(i,val);
		wsum.upd(1,0,MAX-1,i);
	}

	int x,y;
	while(q--) {
		scanf("%d%d",&x,&y);
		if(x<0) {
			x=-x;
			sum.upd(x,y);
			wsum.upd(1,0,MAX-1,x);
		} else {
			int lo=a[x-1], up=a[y+1];
			while(up-lo>1) {
				int md=(lo+up)>>1;
				int j=get_point(md,x,y);

				if(sum.sum(x,j)<=sum.sum(j+1,y)) lo=md;
				else up=md;
			}
			int i=up,j=get_point(up,x,y);
			//printf("POS : %d %d\n",i,j);
			lli ans=0;
			if(j>=x) {
				td val = wsum.find(1,0,MAX-1,x,j);
				ans += val.lwsum + val.lsum*(i+j-x-a[j]);
			}
			if(j+1<=y) {
				td val = wsum.find(1,0,MAX-1,j+1,y);
				ans += val.rwsum + val.rsum*(a[j+1]-(i+j-x+1));
			}
			printf("%lld\n",ans%mod);
		}
	}
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int mod = 1e9 + 7;

template <typename T> void add(T &a, const T b) { a = (a + b) % mod; }

const int maxn = 2e5 + 10, maxlg = 18;
int n, q, a[maxn], fen[maxn], w[maxn];
ll sum[maxn];

void upd_sum(int i, ll val) {
	for (; i < maxn; i += i & -i)
		sum[i] += val;
	return;
}

ll q_sum(int x, ll ans = 0) {
	for (; x; x -= x & -x)
		add(ans, sum[x]);
	return ans;
}

void upd_fen(int i, int val) {
	for (; i < maxn; i += i & -i)
		add(fen[i], val);
	return;
}

int q_fen(int x, int ans = 0) {
	for (; x; x -= x & -x)
		add(ans, fen[x]);
	return ans;
}

ll query_sum(int l, int r) {
	return q_sum(r) - q_sum(l - 1);
}

ll query_fen(int l, int r) {
	return (q_fen(r) - q_fen(l - 1) + mod) % mod;
}

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> q;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		a[i] -= i;
	}
	for (int i = 0; i < n; ++i) {
		cin >> w[i];
		upd_sum(i + 1, w[i]);
		upd_fen(i + 1, 1ll * w[i] * a[i] % mod);
	}
	for (int i = 0, x, y; i < q; ++i) {
		cin >> x >> y;
		if (x < 0) {
			x = -x - 1;
			upd_sum(x + 1, -w[x] + y);
			upd_fen(x + 1, (ll(mod - 1) * w[x] + y) % mod * a[x] % mod);
			w[x] = y;
		}
		else {
			int pos = 0;
			ll val = query_sum(x, y) / 2 + query_sum(1, x - 1);
			for (int i = maxlg - 1; ~i; --i)
				if (pos + (1 << i) < maxn && sum[pos + (1 << i)] <= val) {
					pos += 1 << i;
					val -= sum[pos];
				}
			pos++;
			ll ans = (query_sum(x, pos) - query_sum(pos, y)) * a[pos - 1] % mod;
			add(ans, query_fen(pos, y) - query_fen(x, pos));
			if (ans < 0)
				ans += mod;
			cout << ans << '\n';
		}
	}
	return 0;
}

#include <iostream>
#include <ios>
#include <cstdint>
#include <vector>

using ul = std::uint32_t;
using ull = std::uint64_t;
using li = std::int32_t;
using ll = std::int64_t;
using vull = std::vector<ull>;
using vul = std::vector<ul>;

const ul sz = 1 << 18;
const ul base = 1e9 + 7;

class scaler {
public:
    ul v = 0;
    scaler()=default;
    scaler(ul x): v(x) { }
};

scaler operator+(scaler a, scaler b)
{
    return scaler(a.v + b.v < base ? a.v + b.v : a.v + b.v - base);
}

scaler operator-(scaler a, scaler b)
{
    return scaler(a.v < b.v ? a.v + base - b.v : a.v - b.v);
}

scaler operator*(scaler a, scaler b)
{
    return scaler(ull(a.v) * b.v % base);
}

template<typename T>
void change(ul pos, const T& v, std::vector<T>& tree)
{
    for (tree[pos |= sz] = v, pos >>= 1; pos; pos >>= 1) {
        tree[pos] = tree[pos << 1] + tree[pos << 1 | 1];
    }
}

template<typename T>
T query(ul l, ul r, const std::vector<T>& tree)
{
    T ret = 0;
    for (l = l - 1 | sz, r = r + 1 | sz; l ^ r ^ 1; l >>= 1, r >>= 1) {
        if (~l & 1) {
            ret = ret + tree[l ^ 1];
        }
        if (r & 1) {
            ret = ret + tree[r ^ 1];
        }
    }
    return ret;
}

std::vector<scaler> atree(sz << 1, ul(0));
vull tree(sz << 1, ul(0));
ul n, q;
vul a(2e5 + 1);

scaler compute(ul l, ul r, ul cut)
{
    return scaler(query(l, cut - 1, tree)) * scaler(a[cut]) - query(l, cut - 1, atree)
     + query(cut + 1, r, atree) - scaler(query(cut + 1, r, tree)) * scaler(a[cut]);
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cin >> n >> q;
    for (ul i = 1; i <= n; ++i) {
        std::cin >> a[i];
        a[i] -= i;
    }
    for (ul i = 1; i <= n; ++i) {
        ul w;
        std::cin >> w;
        change(i, ull(w), tree);
        change(i, scaler(a[i]) * scaler(w), atree);
    }
    for (ul i = 0; i != q; ++i) {
        li x, y;
        std::cin >> x >> y;
        if (x < 0) {
            ul id = -x;
            ul w = y;
            change(id, ull(w), tree);
            change(id, scaler(a[id]) * scaler(w), atree);
        } else {
            ul l = x, r = y;
            ull temp = query(l, r, tree);
            ul lans = l, rans = r + 1;
            while (lans + 1 != rans) {
                ul mid = lans + rans >> 1;
                if ((query(mid, r, tree) << 1) < temp) {
                    rans = mid;
                } else {
                    lans = mid;
                }
            }
            std::cout << compute(l, r, lans).v << std::endl;
        }
    }
    return 0;
}

#include<bits/stdc++.h>
#define re register
#define ll long long
const int N=2e5+5;
const int mod=1e9+7;
using namespace std;
template<class T>
inline void read(T &x)
{
	x=0; int f=1;
	static char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') f=-1; ch=getchar();}
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
}
inline void write(ll x)
{
	if(x<0) {x=-x; putchar('-');}
	if(x>9) write(x/10);
	putchar(x%10+'0');
}
int n,Q;
ll a[N],w[N],b[N];
struct Tree
{
	int l,r;
	ll sum,s;
}tree[4*N];
inline void pushup(int now)
{
	tree[now].sum=(tree[now<<1].sum+tree[now<<1|1].sum)%mod;
	tree[now].s=(tree[now<<1].s+tree[now<<1|1].s)%mod;
}
inline void build(int now,int l,int r)
{
	tree[now].l=l,tree[now].r=r;
	if(l==r)
	{
		tree[now].sum=w[l];
		tree[now].s=b[l]*w[l]%mod;
		return;
	}
	int m=(l+r)>>1;
	build(now<<1,l,m);
	build(now<<1|1,m+1,r);
	pushup(now);
}
inline ll query(int now,int l,int r)
{
	if(l<=tree[now].l&&tree[now].r<=r) return tree[now].sum;
	int m=(tree[now].l+tree[now].r)>>1; ll ans=0;
	if(l<=m) ans+=ans+query(now<<1,l,r);
	if(r>m) ans+=query(now<<1|1,l,r);
	return ans%mod;
}
inline void update(int now,int pos,ll x)
{
	if(tree[now].l==tree[now].r)
	{
		tree[now].sum=x;
		tree[now].s=b[pos]*x%mod;
		return;
	}
	int m=(tree[now].l+tree[now].r)>>1;
	if(pos<=m) update(now<<1,pos,x);
	else update(now<<1|1,pos,x);
	pushup(now);
}
inline ll ask(int now,int l,int r)
{
	if(l<=tree[now].l&&tree[now].r<=r)	return tree[now].s;
	int m=(tree[now].l+tree[now].r)>>1; ll ans=0;
	if(l<=m) ans+=ask(now<<1,l,r);
	if(r>m) ans+=ask(now<<1|1,l,r);
	return ans%mod;
}
inline void Solve(int l,int r)
{
	int L=l,R=r,ans=l;
	while(L<=R)
	{
		int mid=(L+R)>>1;
		ll QL=query(1,l,mid),QR=query(1,mid+1,r);
		if(QL>=QR) ans=mid,R=mid-1;
		else L=mid+1;
	}
	ll Q1=(query(1,l,ans-1)*(a[ans]-ans)-ask(1,l,ans-1))%mod;
	ll Q2=(query(1,ans+1,r)*(ans-a[ans])+ask(1,ans+1,r))%mod;
	write((Q1+Q2)%mod),putchar('\n');
}
int main()
{
	read(n),read(Q);
	for(int i=1;i<=n;i++) read(a[i]),b[i]=a[i]-i;
	for(int i=1;i<=n;i++) read(w[i]);
	build(1,1,n);
	int l,r;
	while(Q--)
	{
		read(l),read(r);
		if(l<0) update(1,-l,r);
		if(l>0)	Solve(l,r);
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define MOD 1000000007LL
#define MOD1 1000000009LL
#define INF 1000000000000000018LL
#define F first
#define S second
#define ll long long
#define eps 1e-9

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll gcd(ll a, ll b)
{
	if(a == 0LL)
		return b;
	if(b == 0LL)
		return a;
	return gcd(b, a%b);
}

const int N = 200005;
ll A[N], W[N];
pll tree[N<<2];

void build(int node, int l, int r)
{
	if(l == r)
	{
		tree[node] = mp(W[l], (A[l]*W[l])%MOD);
		return;
	}
	int mid = (l+r)>>1;
	int left = node<<1;
	int right = left + 1;
	build(left, l, mid);
	build(right, mid+1, r);
	tree[node].F = tree[left].F + tree[right].F;
	tree[node].S = (tree[left].S + tree[right].S)%MOD;

	return;
}

void update(int node, int l, int r, int idx)
{
	if(l == r)
	{
		tree[node] = mp(W[idx], (A[idx]*W[idx])%MOD);
		return;
	}
	int mid = (l+r)>>1;
	int left = node<<1;
	int right = left + 1;
	if(idx <= mid)
		update(left, l, mid, idx);
	else
		update(right, mid+1, r, idx);
	tree[node].F = tree[left].F + tree[right].F;
	tree[node].S = (tree[left].S + tree[right].S)%MOD;

	return;
}

pll query(int node, int l, int r, int a, int b)
{
	if(l == a && r == b)
		return tree[node];
	int mid = (l+r)>>1;
	int left = node<<1;
	int right = left + 1;
	if(b <= mid)
		return query(left, l, mid, a, b);
	else if(a > mid)
		return query(right, mid+1, r, a, b);
	pll L = query(left, l, mid, a, mid);
	pll R = query(right, mid+1, r, mid+1, b);
	pll ans = mp(L.F + R.F, (L.S + R.S)%MOD);
	return ans;
}

ll getAns(int n, int L, int R, int ind)
{
	ll X = A[ind];
	ll ans = 0LL;
	pll val = query(1, 1, n, L, ind);
	val.F = val.F%MOD;
	ans = (ans + ((X*val.F)%MOD) - val.S + 2LL*MOD)%MOD;
	val = query(1, 1, n, ind, R);
	val.F = val.F%MOD;
	ans = (ans + val.S - ((X*val.F)%MOD) + 2LL*MOD)%MOD;
	return ans;
}

bool check(int n, int L, int R, int ind)
{
	pll val1 = query(1, 1, n, L, ind);
	pll val2 = query(1, 1, n, ind, R);

	ll temp1 = val1.F;
	ll temp2 = val2.F;

	ll ans = A[ind+1]*(temp1 + W[ind+1]) - A[ind]*temp1 - A[ind+1]*W[ind+1] - A[ind]*W[ind] - A[ind+1]*(temp2 - W[ind]) + A[ind]*temp2;

	ll wow = (getAns(n, L, R, ind+1) - getAns(n, L, R, ind) + 2LL*MOD)%MOD;

	assert(wow == ((ans + MOD*MOD)%MOD));

	return (ans >= 0LL);
}

void solve1(int n, int L, int R)
{
	int l = L, r = R, mid;
	ll val1, val2;
	while(l < r)
	{
		mid = (l+r)/2;

		if(check(n, L, R, mid))
			r = mid;
		else
			l = mid+1;
	}
	assert(l == r);
	cout << getAns(n, L, R, l) << "\n";

	return;
}

void solve()
{
	int n, q;
	cin >> n >> q;
	for(int i = 1; i<=n; i++)
	{
		cin >> A[i];
		A[i] = A[i] - i;
	}
	for(int i = 1; i<=n; i++)
		cin >> W[i];
	build(1, 1, n);

	int L, R;
	while(q--)
	{
		cin >> L >> R;
		if(L<0)
		{
			L = -1*L;
			W[L] = R;
			update(1, 1, n, L);

			continue;
		}
		solve1(n, L, R);
	}

	return;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	// freopen("in.in", "r", stdin);
	// freopen("out.out", "w", stdout);

	clock_t clk = clock();

	int t = 1;
	// cin >> t;
	for(int tests = 1; tests <= t; tests++)
	{
		// cout << "Case #" << tests << ": ";
		solve();
	}

	clk = clock() - clk;
	cerr << "Time Elapsed: " << fixed << setprecision(10) << ((long double)clk)/CLOCKS_PER_SEC << "\n";

	return 0;
}

#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:16777216")

#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;
using matrix = vector<vector<long long>>;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pd;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define all(x) (x).begin(), (x).end()
//#define int ll

void FAST_IO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.setf(ios::fixed);
    //cout.precision(20);
    #ifdef _offline
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // _offline
}

const ll mod = 1e9 + 7;

struct dat {
    ll sumw, sumaw, lf, rg, len;

    dat() : sumw(0), sumaw(0), lf(0), rg(0), len(0) {};

    dat merge(const dat &other) const {
        dat res;
        res.sumw = sumw + other.sumw;
        if (res.sumw >= mod) {
            res.sumw -= mod;
        }
        res.sumaw = sumaw + other.sumaw;
        if (res.sumaw >= mod) {
            res.sumaw -= mod;
        }
        res.lf = (lf + sumw * other.len + other.lf) % mod;
        res.rg = (rg + other.rg + other.sumw * len) % mod;
        res.len = len + other.len;
        return res;
    }
};

const int MAXN = 2e5 + 100;
ll arr[MAXN];
ll t[MAXN * 4];
dat T[MAXN * 4];
int n;

void update(int v, int tl, int tr, int pos, ll w) {
    if (tl + 1 == tr) {
        t[v] = w;
        return;
    }
    int tm = (tl + tr) >> 1;
    if (pos < tm) {
        update(v * 2 + 1, tl, tm, pos, w);
    }
    else {
        update(v * 2 + 2, tm, tr, pos, w);
    }
    t[v] = t[v * 2 + 1] + t[v * 2 + 2];
}

ll getsum(int v, int tl, int tr, int l, int r) {
    if (tl >= r || tr <= l) {
        return 0;
    }
    if (tl >= l && tr <= r) {
        return t[v];
    }
    int tm = (tl + tr) >> 1;
    ll a = getsum(v * 2 + 1, tl, tm, l, r);
    ll b = getsum(v * 2 + 2, tm, tr, l, r);
    return a + b;
}

int getpos(int l, int r) {
    ll sum = getsum(0, 0, n, l, r + 1);
    int lf = l, rg = r + 1, mid;
    while (lf + 1 < rg) {
        mid = (lf + rg) >> 1;
        ll cur = getsum(0, 0, n, l, mid + 1);
        if (cur * 2 <= sum) {
            lf = mid;
        }
        else {
            rg = mid;
        }
    }
    return rg;
}

void update2(int v, int tl, int tr, int pos, ll a, ll w) {
    if (tl + 1 == tr) {
        T[v].sumw = w;
        T[v].sumaw = (a * w) % mod;
        T[v].lf = w;
        T[v].rg = w;
        T[v].len = 1;
        return;
    }
    int tm = (tl + tr) >> 1;
    if (pos < tm) {
        update2(v * 2 + 1, tl, tm, pos, a, w);
    }
    else {
        update2(v * 2 + 2, tm, tr, pos, a, w);
    }
    T[v] = T[v * 2 + 1].merge(T[v * 2 + 2]);
}

dat get(int v, int tl, int tr, int l, int r) {
    if (tl >= r || tr <= l) {
        return dat();
    }
    if (tl >= l && tr <= r) {
        return T[v];
    }
    int tm = (tl + tr) >> 1;
    dat a = get(v * 2 + 1, tl, tm, l, r);
    dat b = get(v * 2 + 2, tm, tr, l, r);
    return a.merge(b);
}

signed main() {
    FAST_IO();
    int q;
    cin >> n >> q;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    for (int i = 0; i < n; ++i) {
        ll w;
        cin >> w;
        update(0, 0, n, i, w);
        update2(0, 0, n, i, arr[i], w);
    }
    while (q--) {
        ll x, y;
        cin >> x >> y;
        if (x < 0) {
            update(0, 0, n, -x - 1, y);
            update2(0, 0, n, -x - 1, arr[-x - 1], y);
        }
        else {
            ll l = x - 1, r = y - 1;
            int pos = getpos(l, r);
            dat a = get(0, 0, n, l, pos);
            dat b = get(0, 0, n, pos + 1, r + 1);
            ll ans = 0;
            ans = (ans + arr[pos] * a.sumw) % mod;
            ans = (ans - a.sumaw + mod) % mod;
            ans = (ans - a.lf + mod) % mod;
            ans = (ans - arr[pos] * b.sumw + mod * mod) % mod;
            ans = (ans + b.sumaw + mod) % mod;
            ans = (ans - b.rg + mod) % mod;
            cout << ans << '\n';
        }
    }
}

#include <bits/stdc++.h>

using namespace std;
#define sz(a) (int)(a).size()
#define rep(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define frep(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define debug(a) cerr << #a << ": " << (a) << '\n';
#define debug_two(a, b) cerr << #a << ": " << (a) << ", " << #b << ": " << (b) << '\n';

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;

const int INF = 1000000000 + 7;
const ll LL_INF  = 1ll * INF * INF;
const int MAX_N = 300000 + 7;

template <typename T>
inline void addmod(T& a, const ll& b, const int& MOD = INF) {
	a = (a + b) % MOD; if (a < 0) a += MOD;
}

int n, q;
int a[MAX_N], w[MAX_N];

class FenWickTree{
public:
  void update(int x, int val) {
    for (int t = x; t < MAX_N; t += t & -t) {
      L[t] += val;
      addmod(sum_weight[t], 1ll * val * a[x]);
      addmod(sum_level[t], 1ll * val * x);
    }
    addmod(::w[x], val);
  }

  ll get(int x) {
    ll res = 0;
    for (int t = x; t > 0; t -= t & -t) {
      res += L[t];
    }
    return res;
  }

  int get_sum_weight(int x) {
    int res = 0;
    for (int t = x; t > 0; t -= t & -t) {
      addmod(res, sum_weight[t]);
    }
    return res;
  }

  int get_weight_range(int u, int v) {
    int res = get_sum_weight(v);
    addmod(res, -get_sum_weight(u - 1));
    return res;
  }

  int get_sum_level(int u, int v) {
    int res = 0;
    for (int t = v; t > 0; t -= t & -t) {
      addmod(res, sum_level[t]);
    }
    for (int t = u - 1; t > 0; t -= t & -t) {
      addmod(res, -sum_level[t]);
    }
    return res;
  }

  ll get_range(int u, int v) {
    return get(v) - get(u - 1);
  }

private:
  static const int MAX_N = ::MAX_N;
  ll L[MAX_N];
  int sum_weight[MAX_N];
  int sum_level[MAX_N];

} fenwickTree;

int get_cost_left(int u, int v) {
  if (u > v)
    return 0;
  int res = (fenwickTree.get_weight_range(u, v) - fenwickTree.get_range(u, v) % INF * a[u]) % INF;
  addmod(res, (fenwickTree.get_range(u, v) * 1ll * u - fenwickTree.get_sum_level(u, v)));
  return res;
}

int get_cost_right(int u, int v) {
  if (u > v)
    return 0;
  int res = (fenwickTree.get_range(u, v) % INF * a[v] - fenwickTree.get_weight_range(u, v)) % INF;
  addmod(res, -((fenwickTree.get_range(u, v) * 1ll * v - fenwickTree.get_sum_level(u, v))));
  return res;
}

int calc(int u, int v) {
  if (u == v)
    return 0;

  ll total_sum = fenwickTree.get_range(u, v);

  int lo = u, hi = v - 1, res = v;
  while (lo <= hi) {
    int mid = (lo + hi) >> 1;
    ll tmp = fenwickTree.get_range(u, mid);
    if (tmp <= total_sum - tmp) {
      res = mid;
      lo = mid + 1;
    } else hi = mid - 1;
  }

  int found = res;
  ll mx_found = LL_INF * 8;

  for (int j = -2; j <= 2; ++j) {
    if (res + j >= u && res + j < v) {
      ll diff = abs(2 * fenwickTree.get_range(u, res + j) - total_sum);
      if (diff < mx_found) {
        mx_found = diff;
        found = res + j;
      }
    }
  }

  int ans = get_cost_right(u, found);
  addmod(ans, get_cost_left(found, v));
  return ans;
}

void solve() {
  cin >> n >> q;
  rep(i, 1, n + 1) cin >> a[i];
  rep(i, 1, n + 1) {
    int tmp; cin >> tmp;
    fenwickTree.update(i, tmp);
    assert(w[i] == tmp);
  }

  while (q-- > 0) {
    int u, v;
    cin >> u >> v;
    if (u < 0) {
      u = -u;
      fenwickTree.update(u, v - w[u]);
    } else {
      cout << calc(u, v) << '\n';
    }
  }

}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
  const bool multiple_test = false;
  int test = 1;
	if (multiple_test)
		cin >> test;

	for(int i = 0; i < test; ++i) {
		//printf("Case #%d: ", i + 1);
		solve();
	}
#ifdef _LOCAL_
	cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << "\n";
#endif
}

#include<iostream>
#include<ctime>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<climits>
#include<cstring>
#include<iomanip>
#include<string>
#include<bitset>
#include<unordered_map>
#include<unordered_set>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<algorithm>
#include<functional>
#include<chrono>
//#include<windows.h>
//#include<direct.h>
#include<random>
#include<sstream>

#define y0 asdahsdlkahsdad
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define taskname "C"
//#define BeztDonkey

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

template <typename T> inline void Cin(T &x)
{
    register char c;
    bool neg = 0;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        if (c == '-') neg = 1;
    for (x = 0; c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
    if (neg) x = -x;
}
template <typename T> inline void Cout(T x) { if (x > 9) Cout(x / 10); putchar(x % 10 + '0'); }

const int Mod = 1e9 + 7, maxN = 2e5 + 2;

int a[maxN], w[maxN], n, p1, q, l, r;

struct TBIT1
{
    ll lab[maxN];
    inline void Init() { memset(lab, 0, sizeof lab); }
    inline void Update(int i, int val) { for (; i <= n; i += i & -i) lab[i] += val; }
    inline ll Get(int i) { ll res = 0; for (; i > 0; i &= i - 1) res += lab[i]; return res; }
    inline int Find(ll t)
    {
        int x = 0, y;
        for (int p = p1; p > 0; p >>= 1)
        {
            y = x + p;
            if (y <= n && lab[y] <= t) x = y, t -= lab[x];
        }
        return x;
    }
} BIT1;
struct TBIT2
{
    int lab[maxN];
    inline void Init() { memset(lab, 0, sizeof lab); }
    inline void Update(int i, int val) { for (; i <= n; i += i & -i) if ((lab[i] += val) >= Mod) lab[i] -= Mod; }
    inline int Get(int i)
    { int res = 0; for (; i > 0; i &= i - 1) if ((res += lab[i]) >= Mod) res -= Mod; return res; }
} BIT2;

void Inp()
{
    Cin(n); Cin(q);
    BIT1.Init();
    BIT2.Init();
    for (p1 = 1; p1 << 1 <= n; p1 <<= 1);
    for (int i = 1; i <= n; ++i) Cin(a[i]), a[i] -= i;
    for (int i = 1; i <= n; ++i)
    {
        Cin(w[i]);
        BIT1.Update(i, w[i]);
        BIT2.Update(i, a[i] * (ll)w[i] % Mod);
    }
}

void Solve()
{
    /*for (int i = 1; i <= n; ++i) cout << a[i] << ' ';
    cout << '\n';
    for (int i = 1; i <= n; ++i) cout << w[i] << ' ';
    cout << '\n';
    for (int i = 1; i <= n; ++i) cout << BIT1.Get(i) - BIT1.Get(i - 1) << ' ';
    cout << '\n';
    for (int i = 1; i <= n; ++i) cout << BIT2.Get(i) - BIT2.Get(i - 1) << ' ';
    cout << '\n';
    cout << '\n';*/
    while (--q >= 0)
    {
        Cin(l); Cin(r);
        if (l < 0)
        {
            l = -l;
            BIT1.Update(l, r - w[l]);
            BIT2.Update(l, ll(r - w[l] + Mod) * a[l] % Mod);
            w[l] = r;
        }
        else
        {
            ll wl1 = BIT1.Get(l - 1), wlr = BIT1.Get(r) - wl1;
            ll key = (wlr >> 1) + wl1;
            int pos = BIT1.Find(key - 1);
            ll ans = -(BIT2.Get(pos) - BIT2.Get(l - 1)) - a[pos + 1] * (key - BIT1.Get(pos));
            //cout << ans << ' ';
            key += 1 + (wlr & 1);
            pos = BIT1.Find(key - 1) + 1;
            if (pos < r) ans += BIT2.Get(r) - BIT2.Get(pos);
            //cout << BIT2.Get(r) - BIT2.Get(pos + 1) << ' ';
            ans += a[pos] * (BIT1.Get(pos) - key + 1);
            cout << (ans + (ll)Mod * Mod + Mod) % Mod << '\n';
        }
        /*for (int i = 1; i <= n; ++i) cout << w[i] << ' ';
        cout << '\n';
        for (int i = 1; i <= n; ++i) cout << BIT1.Get(i) - BIT1.Get(i - 1) << ' ';
        cout << '\n';
        for (int i = 1; i <= n; ++i) cout << BIT2.Get(i) - BIT2.Get(i - 1) << ' ';
        cout << '\n';
        cout << '\n';*/
    }
}

int main()
{
    #ifdef BeztDonkey
    auto start = chrono::steady_clock::now();
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen(taskname".inp", "r", stdin);
    //freopen(taskname".out", "w", stdout);

    Inp();
    Solve();

    #ifdef BeztDonkey
    auto end = chrono::steady_clock::now();
    cerr << "In milliseconds : "
         << chrono::duration_cast<chrono::milliseconds>(end - start).count();
    cerr << '\n' << "In seconds : "
         << chrono::duration_cast<chrono::seconds>(end - start).count() << '\n';
    #endif
    return 0;

}

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
typedef long long ll;
const int MAXN=2e5+10;
const int MOD=1e9+7;
int INF;
struct BIT{
    int n;
    ll c[MAXN<<1];
    ll b[MAXN<<1];
    void init(int _n){
        n=_n;
        rep(i,0,n)c[i]=0,b[i]=0;
    }
    void update(int i,ll v){
        ll vv=-b[i]+v;
        b[i]=vv;
        for(;i<=n;i+=i&-i)c[i]+=vv;
    }
    ll query(int i){
        ll s=0;
        for(;i;i-=i&-i)s+=c[i];
        return s;
    }
    int findpos(ll v){
        ll sum=0;
        int pos=0;
        int i=1;
        for(;i<n;i<<=1);
        for(;i;i>>=1){
            if(pos+i<=n&&sum+c[pos+i]<v){
                sum+=c[pos+i];
                pos+=i;
            }
        }
        return pos+1;
    }
}bit1;
struct BITT{
    int n;
    ll c[MAXN<<1];
    ll b[MAXN<<1];
    void init(int _n){
        n=_n;
        rep(i,0,n)c[i]=0,b[i]=0;
    }
    void update(int i,ll v){
        ll vv=-b[i]+v;
        b[i]=vv;
        vv%=MOD;
        for(;i<=n;i+=i&-i){c[i]+=vv;if(c[i]>MOD)c[i]-=MOD;}
    }
    ll query(int i){
        ll s=0;
        for(;i;i-=i&-i){s+=c[i];if(s>MOD)s-=MOD;}
        return s;
    }
}bit2,bit3;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,q;
    cin>>n>>q;
    bit1.init(n);
    bit2.init(n);
    bit3.init(n);
    vector<int> a(n+1,0);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    INF=a[n];
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        bit1.update(i,x);
        bit2.update(i,1LL*x*(abs(a[i]-i)));
        bit3.update(i,1LL*x*abs(a[i]-(INF-n+i)));
    }
    while(q--){
        int x,y;
        cin>>x>>y;
        if(x<0){
            bit1.update(-x,y);
            bit2.update(-x,1LL*y*(abs(a[-x]+x)));
            bit3.update(-x,1LL*y*(abs(a[-x]-(INF-n-x))));
        }else{
            ll w1=bit1.query(x-1);
            ll w2=bit1.query(y);
            ll w=(w1+w2+1)/2;
            int pos=bit1.findpos(w);
            ll ans=(bit2.query(y)-bit2.query(pos-1)+MOD)%MOD;
            ll dis=abs(a[pos]-pos);
            ans-=dis*(bit1.query(y)-bit1.query(pos-1))%MOD;
            if(ans<0)ans+=MOD;
            ans+=(bit3.query(pos-1)-bit3.query(x-1)+MOD)%MOD;
            dis=abs(a[pos]-(INF-n+pos));
            ans-=dis*(bit1.query(pos-1)-bit1.query(x-1))%MOD;
            if(ans<0)ans+=MOD;
            cout<<ans<<endl;
        }
    }
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

const int MAXN = 200005;
const int S = 450;
const int MOD = 1e9 + 7;
const int INF = 1 << 30;

inline void add(int &a, int b)
{
	a += b;
	if (a >= MOD) a -= MOD;
}

inline void mul(int &a, int b)
{
	a = (long long)a * b % MOD;
}

struct Block
{
	int sum, movel, mover, l, r;
}b[S + 10];

long long sum_prev[MAXN];

int a[MAXN], w[MAXN];

int n, q, x, y;

#define SUM(x) (x < 0 ? 0 : sum_prev[x])

int calc(int l, int r)
{
	int x = l, y = r;
//	cout << "(" << l << "," << r << ")" << endl;
	while (l < r)
	{
		int mid = (l + r) >> 1;
		if (SUM(mid) - SUM(x - 1) >= SUM(y) - SUM(mid))
			r = mid;
		else
			l = mid + 1;
//		cout << (SUM(mid) - SUM(x - 1)) << " <-> " << SUM(y) - SUM(mid) << endl;
//		cout << "(" << l << "," << r << ")" << endl;
	}
	return l;
}

int main()
{
	scanf("%d%d", &n, &q);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (int i = 0; i < n; i++)
		scanf("%d", &w[i]);
	a[n] = INF;
	sum_prev[0] = w[0];
	for (int i = 1; i < n; i++)
		sum_prev[i] = w[i] + sum_prev[i - 1];
	for (int i = 0; i < n; i++)
		add(b[i / S].sum, w[i]);
	for (int i = 0; i < n; i++)
	{
		int l = i, r = i, id = i / S;
		while (id == (r + 1) / S && r + 1 < n)
			++r;
		for (int j = l; j <= r; j++)
			add(b[id].movel, (long long)(a[j] - a[l] - (j - l)) * w[j] % MOD);
		for (int j = r; j >= l; j--)
			add(b[id].mover, (long long)(a[r] - a[j] - (r - j)) * w[j] % MOD);
		b[id].l = l, b[id].r = r;
		i = r;
	}
	for (int i = 1; i <= q; i++)
	{
		scanf("%d%d", &x, &y);
		if (x < 0)
		{
			x = -x;
			--x;
			int id = x / S, l = b[id].l, r = b[id].r;
			add(b[id].sum, (y - w[x] + MOD) % MOD);
			add(b[id].movel, MOD - (long long)(a[x] - a[l] - (x - l)) * w[x] % MOD);
			add(b[id].movel, (long long)(a[x] - a[l] - (x - l)) * y % MOD);
			add(b[id].mover, MOD - (long long)(a[r] - a[x] - (r - x)) * w[x] % MOD);
			add(b[id].mover, (long long)(a[r] - a[x] - (r - x)) * y % MOD);
			w[x] = y;
		}
		else
		{
			if (x == y)
			{
				printf("0\n");
				continue;
			}
			--x, --y;
			int L = x, R = y, M = calc(L, R);
			int idl = L / S, idm = M / S, idr = R / S, res = 0, d = max(L, b[idm].l), u = min(R, b[idm].r);
			for (int j = M - 1; j >= d; j--)
				add(res, (long long)(a[M] - a[j] - (M - j)) * w[j] % MOD);
			for (int j = M + 1; j <= u; j++)
				add(res, (long long)(a[j] - a[M] - (j - M)) * w[j] % MOD);
			for (int j = idm - 1; j > idl; j--)
			{
				int x = b[j].r;
				add(res, ((long long)((a[M] - M) - (a[x] - x)) * b[j].sum % MOD + b[j].mover) % MOD);
			}
			for (int j = idm + 1; j < idr; j++)
			{
				int x = b[j].l;
				add(res, ((long long)((a[x] - x) - (a[M] - M)) * b[j].sum % MOD + b[j].movel) % MOD);
			}
			if (idl != idm)
				for (int j = b[idl].r; j >= L; j--)
					add(res, (long long)((a[M] - M) - (a[j] - j)) * w[j] % MOD);
			if (idr != idm)
				for (int j = b[idr].l; j <= R; j++)
					add(res, (long long)((a[j] - j) - (a[M] - M)) * w[j] % MOD);
			printf("%d\n", res);
		}
	}
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

const long long mod = 1e9 + 7;

int n, q, i, j, l, mid, r;
long long a[200010], w[200010];

////////////////////////// PARTEA I - simple partial sums on weight
long long aibpart[200010];
long long part(int poz)
{
    long long ret = 0LL;
    for(;poz;poz-=poz&-poz)
        ret = ret + aibpart[poz] ;
    return ret;
}
void updpart(int poz, int val)
{
    for(;poz<=n;poz+=poz&-poz)
        aibpart[poz] += val;
    return ;
}
//////////////////////////

////////////////////////// PARTEA II - simple partial sums on products between weight and position
long long aibprodus[200010];
int produs(int poz)
{
    int ret = 0;
    for(;poz;poz-=poz&-poz)
    {
        ret = ret + aibprodus[poz] ;
        ret = ( ret > mod ) ? ret - mod : ret ;
    }
    return ret;
}
void updprodus(int poz, int val)
{
    for(;poz<=n;poz+=poz&-poz)
        aibprodus[poz] = ( aibprodus[poz] + val >= mod ) ? aibprodus[poz] + val - mod : aibprodus[poz] + val ;
    return ;
}
//////////////////////////

////////////////////////// PARTEA III - first grade function
long long aibA[200010], aibB[200010], aibretard[200010];
int getA(int poz)
{
    int ret = 0;
    for(;poz;poz-=poz&-poz)
    {
        ret = ret + aibA[poz] ;
        ret = ( ret > mod ) ? ret - mod : ret ;
    }
    return ret;
}
void updA(int poz,long long val)
{
    for(;poz<=n;poz+=poz&-poz)
        aibA[poz] = ( aibA[poz] + val >= mod ) ? aibA[poz] + val - mod : aibA[poz] + val ;
    return ;
}

int getB(int poz)
{
    int ret = 0;
    for(;poz;poz-=poz&-poz)
    {
        ret = ret + aibB[poz] ;
        ret = ( ret > mod ) ? ret - mod : ret ;
    }
    return ret;
}
void updB(int poz,long long val)
{
    for(;poz<=n;poz+=poz&-poz)
        aibB[poz] = ( aibB[poz] + val >= mod ) ? aibB[poz] + val - mod : aibB[poz] + val ;
    return ;
}

int getthird(int poz)
{
    long long ret = ( getA(poz) * poz + getB(poz) ) % mod ;
    return ( ret < 0 ) ? ret + mod : ret ;
}

void updretard(int poz,int val)
{
    for(;poz<=n;poz+=poz&-poz)
        aibretard[poz] = ( aibretard[poz] + val >= mod ) ? aibretard[poz] + val - mod : aibretard[poz] + val;
    return ;
}
int retard(int poz)
{
    int ret = 0;
    for(;poz;poz-=poz&-poz)
        ret = ( ret + aibretard[poz] >= mod ) ? ret + aibretard[poz] - mod : ret + aibretard[poz];
    return ret;
}
//////////////////////////

int main()
{
    cin>>n>>q;
    for(i=1;i<=n;i++) cin >> a[i];
    for(i=1;i<=n;i++)
    {
        cin >> w[i];
        updpart   ( i , w[i] );
        updprodus ( i , ( w[i] * a[i] ) % mod );
        updA      ( i , w[i] );
        long long aux = ( w[i] * ( 1 - i ) ) % mod ;
        aux = ( aux < 0 ) ? aux + mod : aux ;
        updB      ( i , aux );
        updretard ( i , ( w[i] * i ) % mod );
    }

    for(;q;q--)
    {
        cin >> l >> r;

        if( l < 0 )
        {
            l = -l;
            long long dif = ( r - w[l] < 0 ) ? r - w[l] + mod : r - w[l] ;
            updpart   ( l , r - w[l] );
            updprodus ( l , ( dif * a[l] ) % mod );
            updA      ( l , dif );
            long long aux = ( dif * ( 1 - l ) ) % mod ;
            aux = ( aux < 0 ) ? aux + mod : aux ;
            updB      ( l , aux );
            updretard ( l , ( dif * l ) % mod );
            w[l] = r;
            continue ;
        }

        int laux=l, raux=r;long long L=part(l-1);long long total=part(r)-L;
        while( laux < raux )
        {
            mid = ( laux + raux ) / 2;
            if( ( part(mid) - L ) * 2 < total )
                laux = mid + 1;
            else
                raux = mid;
        }
        mid = laux;
        long long ans = 0;
//        for(j=l;j<mid;j++)    ans = ( ans + ( a[mid] - a[j] - ( mid - j ) ) * w[j] ) % mod;
//        for(j=mid+1;j<=r;j++) ans = ( ans + ( a[j] - a[mid] - ( j - mid ) ) * w[j] ) % mod;
//        cout << "ACTUAL ANSWER: " << ans << '\n';
//
//        cout << "MIDDLE : " << mid - l + 1 << '\n';
//        cout << "WEIGHTS: ";for(j=l;j<=r;j++) cout << part(j)-part(j-1) << ' ';cout<<'\n';
//        cout << "POSES  : ";for(j=l;j<=r;j++) cout << a[j] << ' ';cout<<'\n';
//        cout << "PRODUSE: ";for(j=l;j<=r;j++) cout << (produs(j)-produs(j-1)+mod)%mod << ' ';cout<<'\n';
//        cout << "A & B  : ";for(j=l;j<=r;j++) cout << getthird(j) << ' ';cout<<'\n';

//        ans = 0LL;
////////////////////////// PARTEA I
        ans = ( ans + a[mid] * ( ( part(mid-1) - part(l-1) ) % mod ) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans ;

        ans = ( ans - a[mid] * ( ( part(r)   -   part(mid) ) % mod ) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans ;
//        cout << " PARTEA I: " << ans << '\n';

        //ans = 0LL;
////////////////////////// PARTEA II
        ans = ( ans - ( produs(mid-1) - produs (l-1) ) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans ;

        ans = ( ans + ( produs(r) - produs(mid) ) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans ;
//        cout << " PARTEA II: " << ans << '\n';

        //ans = 0LL;
////////////////////////// PARTEA III
        ans = ( ans - getthird(mid-1) );
        ans = ( ans < 0 ) ? ans + mod : ans;
        ans = ( ans  +  getthird(l-1) );
        ans = ( ans < 0 ) ? ans + mod : ans;
        ans = ( ans  + ( ( mid - l ) * part(l-1) ) % mod ) % mod;

//        cout << " PARTEA III a: " << ans << '\n';

        //ans = 0LL;

        ans = ( ans - retard(r) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans;
        ans = ( ans + retard (mid) ) % mod;
        if(mid!=r)ans = ( ans + mid * ( part(r) - part(mid) ) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans;

//        cout << " PARTEA III b: " << ans << '\n';
        cout << ans << '\n';
    }
    return 0;
}

/*input
5 8
1 2 6 7 10
1 1 1 1 5
1 1
1 5
1 3
3 5
-3 5
-1 10
1 4
2 5

*/
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define red(i,r,l) for(int i=r;i>=l;i--)
#define re(i,n) for(int i=0;i<n;i++)
#define db(x) cout<<#x<<"="<<(x)<<" "
#define el cout<<endl
#define PII pair<int, int>
#define PIII pair<PII, int>
#define c0 first
#define c1 second
using namespace std;
typedef long long ll;
const int MXN = 2e5 + 10, MXM = 5010; ll MOD = 1e9 + 7;
int N, Q;
ll a[MXN], w[MXN];

template <typename T>
struct fenwick {
    T f[MXN] = {};
    void update(int x, T val) {
        for (; x <= N; x += x & -x)
            (f[x] = f[x] + val);
    }

    T get(int x) {
        T res = 0;
        for (; x; x -= x & -x) {
                (res = res + f[x]);
        }
        return res;
    }

    T get(int x1, int x2) {
        x1 = max(x1 - 1, 0);
        x2 = min(x2, N);
        return get(x2) - get(x1);
    }

    T findmid(int x1, int x2) {
        ll s1, s2, goal, res = 0;
        int x = 0;
        x1 = max(x1 - 1, 0);
        x2 = min(x2, N);
        s1 = get(x1);
        s2 = get(x2);
        goal = (s1 + s2 + 1) >> 1;
        for (int k = 20; k >= 0; --k)
        {
            if (x + (1 << k) <= N)
            if (res + f[x + (1 << k)] < goal) {
                res += f[x + (1 << k)];
                x += 1 << k;
            }
        }
        return x + 1;
    }
};

template <typename T>
struct fenwickMOD {
    T f[MXN] = {};
    void update(int x, T val) {
        for (; x <= N; x += x & -x)
            (f[x] = f[x] + val) % MOD;
    }

    T get(int x) {
        T res = 0;
        for (; x; x -= x & -x) {
                (res = res + f[x]) % MOD;
        }
        return res;
    }

    T get(int x1, int x2) {
        x1 = max(x1 - 1, 0);
        x2 = min(x2, N);
        return (get(x2) - get(x1) + MOD) % MOD;
    }
};

fenwick<ll> F;
fenwickMOD<ll> F2;

void upd(int x, int y) {
    ll d = y - w[x];
    F.update(x, d);
    F2.update(x, (a[x] - x) * d);
    w[x] = y;
}

void init()
{
    cin >> N >> Q;
    rep(i, 1, N)
    {
        cin >> a[i];
    }
    rep(i, 1, N)
    {
        int x;
        cin >> x;
        upd(i, x);
    }
}

namespace solve
{
    void solve()
    {
        re(t, Q) {
            int x, y;
            cin >> x >> y;
            if (x > 0) {
                int m = F.findmid(x, y);
                ll t = (F.get(x, m - 1) - F.get(m + 1, y)) % MOD * (a[m] - m) % MOD;
                ll t2 = F2.get(m + 1, y) - F2.get(x, m - 1);
                cout << ((t + t2) % MOD + MOD) % MOD << endl;
            }
            else {
                x = -x;
                upd(x, y);
            }
        }
    }
}

int main()
{
    init();
    solve::solve();
    return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define ll long long

template <typename T>
inline T read() {
	T s = 0,f = 1; char ch = getchar();
	while(!isdigit(ch)) {if(ch == '-') f = -1; ch = getchar();}
	while(isdigit(ch)) {s = (s << 3) + (s << 1) + ch - 48; ch = getchar();}
	return s * f;
}
#define gn() read<int>()
#define gl() read<ll>()

template <typename T>
inline void print(T x) {
	if(x < 0) putchar('-'), x = -x;
	if(x > 9) print(x / 10);
	putchar(x % 10 + '0');
}

const int N = 2e5 + 100;
const int mod = 1e9 + 7;

ll w[N], a[N];

struct Segment {
	static const int MAX = 2e5 + 100;
	#define lson node << 1
	#define rson node << 1 | 1
	ll sum[MAX << 2];

	void pushup(int node, int l, int r) {
		sum[node] = sum[lson] + sum[rson];
	}

	void build(int node, int l, int r) {
		if(l == r) {
			sum[node] = w[l];
			return ;
		}
		int mid = l + r >> 1;
		build(lson, l, mid);
		build(rson, mid + 1, r);
		pushup(node, l, r);
	}

	void change(int node, int l, int r, int idx, int val) {
		if(l == r) {
			sum[node] = val;
			return ;
		}
		int mid = l + r >> 1;
		if(idx <= mid) change(lson, l, mid, idx, val);
		else change(rson, mid + 1, r, idx, val);
		pushup(node, l, r);
	}

	int queryid(int node, int l, int r, int L, int R, ll val) {
        // cout << "queryid: " << node << " " << l << " " << r << " " << L << " " << R << " " << val << " " << sum[node] << endl;
		if(l == r) return l;
		int mid = l + r >> 1;
		if(R <= mid) return queryid(lson, l, mid, L, R, val);
		else if(L > mid) return queryid(rson, mid + 1, r, L, R, val);
		else {
            ll lsum = querysum(lson, l, mid, L, mid);
			if(lsum >= val) return queryid(lson, l, mid, L, mid, val);
			else return queryid(rson, mid + 1, r, mid + 1, R, val - lsum);
		}
	}

	ll querysum(int node, int l, int r, int L, int R) {
		if(L <= l && R >= r) {
			return sum[node];
		}
		int mid = l + r >> 1;
		ll val = 0;
		if(L <= mid) val += querysum(lson, l, mid, L, R);
		if(R > mid) val += querysum(rson, mid + 1, r, L, R);
		return val;
	}
} treeans;

struct SegmentTree {
	static const int MAX = 2e5 + 100;
	#define lson node << 1
	#define rson node << 1 | 1
	ll sum[MAX << 2];

	void pushup(int node, int l, int r) {
		sum[node] = sum[lson] + sum[rson] % mod;
	}

	void build(int node, int l, int r) {
		if(l == r) {
			sum[node] = w[l] * (a[l] - l) % mod;
			return ;
		}
		int mid = l + r >> 1;
		build(lson, l, mid);
		build(rson, mid + 1, r);
		pushup(node, l, r);
	}

	void change(int node, int l, int r, int idx, ll val) {
		if(l == r) {
			sum[node] = val * (a[l] - l) % mod;
			return ;
		}
		int mid = l + r >> 1;
		if(idx <= mid) change(lson, l, mid, idx, val);
		else change(rson, mid + 1, r, idx, val);
		pushup(node, l, r);
	}

	ll querysum(int node, int l, int r, int L, int R) {
		if(L <= l && R >= r) {
			return sum[node];
		}
		int mid = l + r >> 1;
		ll val = 0;
		if(L <= mid) val += querysum(lson, l, mid, L, R), val %= mod;
		if(R > mid) val += querysum(rson, mid + 1, r, L, R), val %= mod;
		return val % mod;
	}
} tree;

// w[i] build tree sum array = w[i] * a[i]

int main() {

#if ONLINE_JUDGE
#else
	freopen("./sml/in.txt", "r", stdin);
	freopen("./sml/out.txt", "w", stdout);
#endif

	int n = gn(), m = gn();
	for(int i = 1; i <= n; ++i) {
		a[i] = gl();
	}
	for(int i = 1; i <= n; ++i) {
		w[i] = gl();
	}
	tree.build(1, 1, n);
	treeans.build(1, 1, n);
	for(int i = 1; i <= m; ++i) {
		ll l = gl(), r = gl();
		// cout << l << " " << r << endl;
		if(l < 0){
			l = -l;
			tree.change(1, 1, n, l, r);
			treeans.change(1, 1, n, l, r);
            w[l] = r;
		} else {
			ll k = treeans.querysum(1, 1, n, l, r);
			// cout << "k: " <<  k << endl;
			if(k & 1) {
				k = (k + 1) / 2;
				int id = treeans.queryid(1, 1, n, l, r, k);
				ll ans = 0;
				ans = (((a[id] - id) % mod * treeans.querysum(1, 1, n, l, id) % mod) % mod - tree.querysum(1, 1, n, l, id) % mod + mod) % mod;
				ans = (ans + tree.querysum(1, 1, n, id, r) % mod - ((a[id] - id) % mod * treeans.querysum(1, 1, n, id, r) % mod) % mod + mod) % mod;
				printf("%lld\n", ans % mod);
			} else {
                k /= 2;
				int idone = treeans.queryid(1, 1, n, l, r, k);
				int idtwo = treeans.queryid(1, 1, n, l, r, k + 1);
				ll valmidlf = (a[idone] + a[idtwo]) / 2;
                ll valmidrt = valmidlf;
                if(idone != idtwo) valmidrt += 1;
                // cout << "debug: " << k << " " << idone << " " << idtwo << " " << valmidlf << " " << valmidrt << endl;
                ll ans = 0;
                //(valmidlf - a[idone]) * w[idone] + (a[idtwo] - valmidrt) * w[idtwo];
				ans = ((valmidlf - idone) % mod * treeans.querysum(1, 1, n, l, idone) % mod - tree.querysum(1, 1, n, l, idone) % mod + mod) % mod;
				ans = (ans + tree.querysum(1, 1, n, idtwo, r) % mod - (valmidrt - idtwo) % mod * treeans.querysum(1, 1, n, idtwo, r) % mod + mod) % mod;
				printf("%lld\n", ans % mod);
			}
		}
	}

}
/**
* In every life we have some trouble
* When you worry you make it double
* Don't worry,be happy.
**/

/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 2e5 + 10, mod = 1e9 + 7;

ll a[N], w[N], tree[4 * N][2];

void update(int i, int l, int r, int p, ll w);
ll query(int i, int l, int r, int ql, int qr, int type);

int main() {
	fast_cin();
	int n, q;
	cin >> n >> q;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; ++i) {
		cin >> w[i];
		update(1, 1, n, i, w[i]);
	}
	while (q--) {
		int x, y;
		cin >> x >> y;
		if (x < 0) {
			update(1, 1, n, -x, y);
			w[-x] = y;
		} else {
			int l = x, r = y, i = -1;
			while (x <= y) {
				int mid = (x + y) / 2;
				ll z1 = query(1, 1, n, l, mid - 1, 0);
				ll z2 = query(1, 1, n, mid + 1, r, 0);
				if (w[mid] < z2 - z1) {
					x = mid + 1;
				} else if (w[mid] < z1 - z2) {
					y = mid - 1;
				} else {
					i = mid;
					break;
				}
			}
			ll ans = query(1, 1, n, i + 1, r, 1) + (i - a[i]) * (query(1, 1, n, i + 1, r, 0) % mod);
			ans   -= query(1, 1, n, l, i - 1, 1) + (i - a[i]) * (query(1, 1, n, l, i - 1, 0) % mod);
			cout << ((ans % mod) + mod) % mod << '\n';
		}
	}
}

void update(int i, int l, int r, int p, ll nw) {
	if (l == r) {
		tree[i][0] = nw;
		tree[i][1] = (nw * (a[p] - p)) % mod;
	} else {
		int mid = (l + r) / 2, lc = 2 * i, rc = lc + 1;
		if (p <= mid) {
			update(lc, l, mid, p, nw);
		} else {
			update(rc, mid + 1, r, p, nw);
		}
		tree[i][0] = (tree[lc][0] + tree[rc][0]) % mod;
		tree[i][1] = (tree[lc][1] + tree[rc][1]) % mod;
	}
}

ll query(int i, int l, int r, int ql, int qr, int type) {
	if (l > qr or ql > r) {
		return 0;
	} else if (ql <= l and r <= qr) {
		return tree[i][type];
	} else {
		int mid = (l + r) / 2, lc = 2 * i, rc = lc + 1;
		return query(lc, l, mid, ql, qr, type) + query(rc, mid + 1, r, ql, qr, type);
	}
}

#include <bits/stdc++.h>

using namespace std;

#define sz(a) int(a.size())

struct Node {
	long long xL, xR, sum, costTL, costTR;

	Node () {
		xL = xR = sum = costTL = costTR = 0;
	}
	Node (long long x, long long w) {
		xL = xR = x;
		sum = w;
		costTL = costTR = 0;
	}
	void updateN (long long w) {
		sum = w;
	}
};

const int MOD = 1e9+7;
Node join (Node p1, Node p2) {
	Node r;
	r.xL = p1.xL, r.xR = p2.xR;
	r.sum = p1.sum + p2.sum;
	r.costTL = p1.costTL + p2.costTL + ((p2.xL-p1.xL)%MOD)*(p2.sum%MOD);
	r.costTL %= MOD;
	r.costTR = p1.costTR + p2.costTR + ((p2.xR-p1.xR)%MOD)*(p1.sum%MOD);
	r.costTR %= MOD;
	return r;
}

int N;
int A [200010], W[200010];
Node st [800010];

void create (int n = 1, int l = 0, int r = N) {
	if (l == r) st[n] = Node(A[l], W[l]);
	else {
		int m = (l+r)/2;
		create(2*n,l,m);
		create(2*n+1,m+1,r);
		st[n] = join(st[2*n],st[2*n+1]);
	}
}

Node query (int x, int y, int n = 1, int l = 0, int r = N) {
	if (x <= l && r <= y) return st[n];
	else {
		int m = (l+r)/2;

		if (y <= m) return query(x,y,2*n,l,m);
		if (x > m) return query(x,y,2*n+1,m+1,r);
		return join(query(x,y,2*n,l,m),query(x,y,2*n+1,m+1,r));
	}
}

void update (int x, int v, int n = 1, int l = 0, int r = N) {
	if (l == r) st[n].updateN(v);
	else {
		int m = (l+r)/2;

		if (x <= m) update(x,v,2*n,l,m);
		else update(x,v,2*n+1,m+1,r);

		st[n] = join(st[2*n],st[2*n+1]);
	}
}

int getMid (long long v, int n = 1, int l = 0, int r = N) {
	if (l == r) return l;
	int m = (l+r)/2;
	if (st[2*n].sum < v) {
		v -= st[2*n].sum;
		return getMid(v,2*n+1,m+1,r);
	}
	return getMid(v,2*n,l,m);
}

int main () {
	int n, q;
	scanf("%d%d",&n, &q);
	for (int i = 0; i < n; i++) scanf("%d",&A[i]);
	for (int i = 0; i < n; i++) scanf("%d",&W[i]);

	N = n-1;
	create();

	while (q--) {
		int x, y;
		scanf("%d%d",&x,&y);
		if (x < 0) update(-x-1,y);
		else {
			x--,y--;
			if (x == y) {
				puts("0");
				continue;
			}

			long long ms = query(x,y).sum/2;
			if (x) ms += query(0,x-1).sum;

			int m = getMid(ms+1);
			if (m == x) m++;
			if (m > y) m = y;
//			cout << x << " " << y << " " << m << endl;
			Node t1 = query(x,m-1), t2 = query(m,y);
			long long ans = t1.costTR + t2.costTL;
//			cout << " " << ans;
			ans += ((t2.xL-t1.xR)%MOD)*(min(t1.sum,t2.sum)%MOD);
			ans %= MOD;
//			cout << " " << ans << endl;
			printf("%I64d\n",ans);

		}
	}
}

#include <iostream>
using namespace std;

typedef long long ll;

const int maxn = 2e5 + 1;
const int mod = 1e9 + 7;

ll f[2][maxn];

void upd(int r, ll x, ll ix=0) {
	for(; r < maxn; r += r & -r) {
		f[ix][r] += x;
	}
}

ll getf(int r, int ix) {
	ll ans = 0;
	for(; r > 0; r -= r & -r) {
		ans += f[ix][r];
	}
	return ans;
}

ll get(int l, int r, int ix = 0) {
	if(l > r) return 0;
	ll ans = getf(r, ix) - getf(l - 1, ix);
	return ans;
}

ll getm(int l, int r, int ix = 0) {
	return get(l, r, ix) % mod;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, q;
	cin >> n >> q;
	ll a[n + 1], w[n + 1];
	for(int i = 0; i < n; i++) {
		cin >> a[i + 1];
		a[i + 1] -= i;
	}
	for(int i = 1; i <= n; i++) {
		cin >> w[i];
		upd(i, w[i], 0);
		upd(i, a[i] * w[i], 1);
	}
	while(q--) {
		ll l, r;
		cin >> l >> r;
		if(l < 0) {
			upd(-l, -w[-l] + r);
			upd(-l, a[-l] * (-w[-l] + r), 1);
			w[-l] = r;
		}
		else {
			ll lo = l, hi = r + 1, mid = l;
			ll s = get(l, r);
			while(lo < hi - 1) {
				int mid = (lo + hi) / 2;
				ll s1 = get(l, mid - 1);
				if(s1 * 2 > s) hi = mid;
				else lo = mid;
			}
			ll ansl = (((a[lo] * getm(l, lo - 1) - getm(l, lo - 1, 1)) % mod) + mod) % mod;
			ll ansr = (((getm(lo, r, 1) - a[lo] * getm(lo, r)) % mod) + mod) % mod;
			cout << (ansl + ansr) % mod << '\n';
		}
	}
	return 0;
}

#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;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> opset;
#define SZ(X) ((int)X.size())
#define ALL(I) I.begin(), I.end()
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define eps 1e-12
#define MXN 200005
#define p 1000000007
#define INF (LL)1e18 + 5
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

inline LL add(LL a, LL b, LL mod = p){
	if(a + b >= mod) return (a + b) % mod;
	if(a + b < 0) return ((a + b) % mod + mod) % mod;
	return a + b;
}
inline LL mul(LL a, LL b, LL mod = p){
	return a * b >= mod ? a * b : a * b % mod;
}

LL aw[MXN], pre[MXN], suf[MXN], a[MXN], w[MXN], s[MXN];
int n, q;

inline void md(LL *bit, int pos, LL val, LL mod = p){
	for(int i = pos; i <= n; i += (i & -i)) bit[i] = add(bit[i], val, mod);
}
inline LL ak(LL *bit, int pos, LL mod = p){
	LL res = 0;
	for(int i = pos; i; i -= (i & -i)) res = add(res, bit[i], mod);
	return res;
}
inline LL qr(LL *bit, int l, int r, LL mod = p){
	if(r < l) return 0LL;
	return add(ak(bit, r, mod), -ak(bit, l - 1, mod), mod);
}

int main(){
	scanf("%d%d", &n, &q);
	for(int i = 1; i <= n; i ++) scanf("%lld", &a[i]);
	for(int i = 1; i <= n; i ++){
		scanf("%lld", &w[i]);
		md(s, i, w[i], INF);
		md(aw, i, mul(a[i], w[i]));
		md(pre, i, mul(i, w[i]));
		md(suf, i, mul(n - i + 1, w[i]));
	}
	LL x, y;
	int l, r;
	while(q --){
		scanf("%lld%lld", &x, &y);
		if(x < 0){
			x = -x;
			LL val = add(y, -w[x]);
			w[x] = y;
			md(s, x, val, INF);
			md(aw, x, mul(a[x], val));
			md(pre, x, mul(x, val));
			md(suf, x, mul(n - x + 1, val));
		} else {
			l = x; r = y + 1;
			while(l != r - 1){
				int mid = l + r >> 1;
				if(qr(s, x, mid - 1, INF) <= qr(s, mid + 1, y, INF)) l = mid;
				else r = mid;
			}
			LL ans = 0, rs = qr(s, l + 1, y), ls = qr(s, x, l - 1);;
			ans = add(ans, add(qr(aw, l + 1, y), -mul(a[l], rs)));
			ans = add(ans, -add(qr(pre, l + 1, y), -mul(rs, l)));
			ans = add(ans, add(-qr(aw, x, l - 1), mul(a[l], ls)));
			ans = add(ans, -add(qr(suf, x, l - 1), -mul(ls, n - l + 1)));
			printf("%lld\n", ans);
		}
	}
}

#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
#define dbg(x) cerr<<#x": "<<(x)<<'\n'
#define dbg_p(x) cerr<<#x": "<<(x).first<<' '<<(x).second<<'\n'
#define dbg_v(x, n) {cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<(x)[_]<<' ';cerr<<'\n';}
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define INF 2000000010
#define MOD 1000000007
#define ST_SIZE 1048600
#define QMAX
#define NMAX 200010

template<typename T1, typename T2>
ostream& operator <<(ostream &out, const pair<T1, T2> &item) {
	out << '(' << item.first << ", " << item.second << ')';
	return out;
}

template<typename T>
ostream& operator <<(ostream &out, const vector<T> &v) {
	for(const auto &item : v) out << item << ' ';
	return out;
}

int n;
int a[NMAX], w[NMAX];
ll bit1[NMAX], bit2[NMAX];

void update(ll bit[], int p, int val, bool modulo = false) {
	for(; p <= n; p += p & (-p)) {
		bit[p] += val;
		if(modulo && bit[p] >= MOD) bit[p] -= MOD;
	}
}

ll query(ll bit[], int p, bool modulo = false) {
	ll res;
	for(res = 0; p; p &= p - 1) {
		res += bit[p];
		if(modulo && res >= MOD) res -= MOD;
	}

	return res;
}

ll query(ll bit[], int l, int r, bool modulo = false) {
	if(l > r) return 0;

	ll ans = query(bit, r, modulo) - query(bit, l - 1, modulo);
	if(modulo && ans < 0) ans += MOD;

	return ans;
}

int get(int x, int y) {
	int l, r, mid;

	ll sum = query(bit1, x, y);
	for(l = x, r = y; l < r; ) {
		mid = (l + r) / 2;
		if(2 * query(bit1, l, mid) >= sum) r = mid;
		else l = mid + 1;
	}

	return l;
}

int main()
{
	ios_base::sync_with_stdio(false);

	int i, q, x, y, k, ans;

	cin >> n >> q;
	for(i = 1; i <= n; ++i) cin >> a[i];
	for(i = 1; i <= n; ++i) {
		cin >> w[i];
		update(bit1, i, w[i]);
		update(bit2, i, (1LL * w[i] * (a[i] - i)) % MOD, true);
	}

	while(q--) {
		cin >> x >> y;

		if(x < 0) {
			i = -x;
			update(bit1, i, MOD - w[i]);
			update(bit2, i, (MOD - (1LL * w[i] * (a[i] - i)) % MOD) % MOD, true);

			w[i] = y;

			update(bit1, i, w[i]);
			update(bit2, i, (1LL * w[i] * (a[i] - i)) % MOD, true);
		} else {
			k = get(x, y);
			ans = 1LL * (a[k] - k) * query(bit1, x, k - 1, true) % MOD;

			ans -= query(bit2, x, k - 1, true);
			if(ans < 0) ans += MOD;

			ans += query(bit2, k + 1, y, true);
			if(ans >= MOD) ans -= MOD;

			ans -= 1LL * (a[k] - k) * query(bit1, k + 1, y, true) % MOD;
			if(ans < 0) ans += MOD;

			cout << ans << '\n';
		}
	}

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;

const int N = 200100;
const ll MOD = 1e9+7;

int n;

ll a[N], b[N];

ll fenw[2][N];

inline void upd(int v, ll x, int f){
    for (int i = v; i <= n; i += (i & (-i))){
        if (f == 0)
            fenw[f][i] += x;
        else
            fenw[f][i] = (fenw[f][i] + x + MOD) % MOD;
    }
}

inline ll get(int v, int f){
    ll ans = 0;
    for (int i = v; i >= 1; i -= (i & (-i))){
        if (f == 0)
            ans += fenw[f][i];
        else
            ans = (ans + fenw[f][i] + MOD) % MOD;
    }
    return ans;
}

inline ll getSum(int l, int r, int f){
    if (l > r)
        return 0;
    if (f == 0)
        return get(r, f) - get(l-1, f);
    return (get(r, f) - get(l-1, f) + MOD) % MOD;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int tt;

    cin >> n >> tt;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        a[i] = (a[i] - i + MOD) % MOD;
    }
    for (int i = 1; i <= n; i++){
        cin >> b[i];
        upd(i, b[i], 0);
        //cout << "kek " << (a[i]*b[i])%MOD << "\n";
        upd(i, (a[i]*b[i])%MOD, 1);
    }

    //cout << get(3, 1) << endl;
    cout << endl;
    cout << get(2, 1) << endl;
    cout << get(3, 1) << endl;

    while(tt--){
        int x, y;
        cin >> x >> y;
        if (x < 0){
            x *= -1;
            upd(x, -b[x], 0);
            upd(x, (-( (a[x]*b[x])%MOD)+MOD)%MOD, 1);
            b[x] = y;
            upd(x, b[x], 0);
            upd(x, (a[x]*b[x])%MOD, 1);
        } else {
            int l = x, r = y;
            ll mySum = getSum(l, r, 0);
            while(l < r){
                int mid = (l+r+1)>>1;
                //cout << mid << ' ' << getSum(l, mid-1, 0)*2 << ' ' << getSum(l, mid, 0)*2 << endl;
                if (getSum(x, mid-1, 0) * 2 <= mySum && getSum(x, mid, 0) * 2 >= mySum)
                    l = mid; else
                    r = mid-1;
            }
            int k = l;
            ll ans;
            ans = ((a[k]*getSum(x, k-1, 0))%MOD-getSum(x, k-1, 1)+MOD)%MOD;
            ans = (ans + ( (getSum(k+1, y, 1)+MOD)%MOD-(a[k]*getSum(k+1, y, 0))%MOD + MOD)%MOD)%MOD;
            //ans = (a[k]*getSum(x, k-1, 0));
            //cout << "GOFORIT " << k << ' ' << ans << ' ' << getSum(l, k-1, 1) << ' ' << get(k-1, 1) << ' ' << get(x-1, 1) << "\n";
            cout << ans << "\n";
        }
    }

}

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;

const int maxn = 2e5 + 10;
const LL mod = 1e9 + 7;

int n, q;
LL A[maxn], W[maxn];
LL Ta[maxn], Tai[maxn];

void Add(LL *B, int i, LL x){
    while(i < maxn){
        B[i] = (B[i] + x) % mod;
        i += i & -i;
    }
}

//单个树状数组求前缀和
LL Sum(LL *B, int i){
    LL res = 0;
    while(i){
        res = (res + B[i]) % mod;
        i -= i & -i;
    }
    return res;
}

int get_pos(int x, int y){
    int lb = x, rb = y;
    while(lb <= rb){
        int mid = (lb + rb) >> 1;
        if((Sum(Ta, mid) - Sum(Ta, x - 1)) * 2 >= Sum(Ta, y) - Sum(Ta, x - 1)) rb = mid - 1;
        else lb = mid + 1;
    }
    return lb;
}

LL solve(int x, int y){
    int p = get_pos(x, y);
    LL res = 0;

    res = (res + (A[p] - p) * (Sum(Ta, p - 1) - Sum(Ta, x - 1)) % mod) % mod;
    res = (res - (Sum(Tai, p - 1) - Sum(Tai, x - 1))) % mod;

    res = (res - (A[p] - p) * (Sum(Ta, y) - Sum(Ta, p)) % mod) % mod;
    res = (res + Sum(Tai, y) - Sum(Tai, p)) % mod;

    return (res % mod + mod) % mod;
}

int main(){
//    freopen("in.txt", "r", stdin);

    scanf("%d %d", &n, &q);
    for(int i = 1; i <= n; i++){
        scanf("%lld", A + i);
    }
    for(int i = 1; i <= n; i++){
        scanf("%lld", W + i);
        Add(Ta, i, W[i]);
        Add(Tai, i, W[i] * (A[i] - i));
    }

    while(q--){
        LL x, y;
        scanf("%lld %lld", &x, &y);
        if(x < 0){
            x = -x;
            W[x] = y;
            Add(Ta, x, (y - (Sum(Ta, x) - Sum(Ta, x-1))));
            Add(Tai, x, (W[x] * (A[x] - x) % mod - (Sum(Tai, x) - Sum(Tai, x - 1))) % mod);
        }else{
            printf("%lld\n", solve(x, y));
        }
    }

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
const lli N=100009;
lli n, q, a[N], b[N], w[N], low[4*N], high[4*N], sw[4*N], leaf[N];
vector<lli> vb[4*N];
void Built(lli v, lli l, lli h)
{
	low[v]=l;
	high[v]=h;
	if(l==h)
	{
		sw[v]=w[l];
		leaf[l]=v;
	}
	else
	{
		lli m=(l+h)/2;
		Built(v*2, l, m);
		Built(v*2+1, m+1, h);
		sw[v]=sw[v*2]+sw[v*2+1];
	}
}
void Inp()
{
	cin>>n>>q;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		cin>>w[i];
	}
	Built(1, 1, n);
}
lli Update(lli k, lli val)
{
	lli v=leaf[k];
	sw[v]=val;
	v=v/2;
	while(v!=0)
	{
		sw[v]=sw[v*2]+sw[v*2+1];
		v=v/2;
	}
}
lli Sumw(lli v, lli l, lli h)
{
	if(low[v]>h||high[v]<l)
	{
		return 0;
	}
	if(low[v]>=l&&high[v]<=h)
	{
		return sw[v];
	}
	return Sumw(v*2, l, h)+Sumw(v*2+1, l, h);
}
lli Calc(lli l, lli r, lli k)
{
	lli kq=0;
	for(int i=l;i<=r;i++)
	{
		kq+=w[i]*abs(k+i-l-a[i]);
	}
	return kq;
}
void Query(lli p, lli q)
{
	lli l=p, h=q, s=Sumw(1, p, q);
	while(l<=h)
	{
		lli m=(l+h)/2;
		if(Sumw(1, p, m)<=s/2)
		{
			l=m+1;
		}
		else
		{
			h=m-1;
		}
	}
	cout<<min(Calc(p, q, a[l]-(l-p)), Calc(p, q, a[h]-(h-p)))<<endl;
}
void Solve()
{
	for(int i=1;i<=q;i++)
	{
		lli x, y;
		cin>>x>>y;
		if(x<0)
		{
			Update(-x, y);
			w[-x]=y;
		}
		else
		{
			Query(x, y);
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("test.inp","r",stdin);
	Inp();
	Solve();
}

#pragma comment(linker, "/STACK:102400000,102400000")
#ifndef ONLINE_JUDGE
#include "stdafx.h"
#else
#include<bits/stdc++.h>
#endif
using namespace std;
#define rep(i,a,b) for (int i=(a);i<=(b);i++)
#define per(i,a,b) for (int i=(a);i>=(b);i--)
#define trav(a,x) for (auto &a:x)
#define mp(a,b) make_pair(a,b)
#define all(x) x.begin(),x.end()
#define fill(x,c) memset(x,c,sizeof(x))
#define write(x) cout<<(x)<<' '
#define writeln(x) cout<<(x)<<endl
#define ADDMOD(x,a,m) x=(((x)+(a)%m)%(m)+m)%m
#define MLTMOD(x,a,m) x=(((x)*((a)%m))%(m)+m)%m
typedef long long lnt;
typedef vector<int> VI;
typedef vector<lnt> VL;
typedef pair<int, int> PII;
typedef pair<lnt, lnt> PLL;
typedef vector<pair<int, int>> VPI;
typedef vector<pair<lnt, lnt>> VPL;
typedef queue<int> QI;
typedef queue<lnt> QL;
typedef map<int, int> MII;
typedef map<lnt, lnt> MLL;
typedef map<int, pair<int, int>> MPI;
typedef map<lnt, pair<lnt, lnt>> MPL;
typedef map<int, vector<int>> MVI;
typedef map<lnt, vector<lnt>> MVL;
typedef set<int> SI;
typedef set<lnt> SL;
typedef set<pair<int, int>> SPI;
typedef set<pair<lnt, lnt>> SPL;

inline lnt pow(lnt a, lnt b, lnt p) {
    lnt rtn = 1;
    while (b) {
        if (b & 1) rtn = rtn * a % p;
        a = a * a % p;
        b >>= 1;
    }
    return rtn;
}
lnt inv(lnt a, lnt p) {
    return pow(a, p - 2, p);
}
long long gcd(long long a, long long b) {
    long long k;
    while (b != 0) {
        k = b;
        b = a % b;
        a = k;
    }
    return a;
}
void makedata() {
    freopen("input.txt", "w", stdout);
    srand((unsigned)time(NULL));
    fclose(stdout);
}
template <typename T> class SegmentTree {
    /*
    type:
    0:sum
    1:max
    2:min
    */
private:
    T *data, *lazy;
    int type, ll, rr;
    inline void pushup(int rt) {
        if (type == 0) data[rt] = data[rt << 1] + data[((rt << 1) | 1)];
        else if (type == 1) data[rt] = max(data[rt << 1], data[((rt << 1) | 1)]);
        else if (type == 2) data[rt] = min(data[rt << 1], data[((rt << 1) | 1)]);
    }
    inline void pushdown(int rt, T m) {
        if (lazy[rt] == 0) return;
        lazy[rt << 1] += lazy[rt];
        lazy[((rt << 1) | 1)] += lazy[rt];
        if (type == 0) {
            data[rt << 1] += (m - (m >> 1)) * lazy[rt];
            data[((rt << 1) | 1)] += (m >> 1) * lazy[rt];
        } else if (type == 1) {
            data[rt << 1] += lazy[rt];
            data[((rt << 1) | 1)] += lazy[rt];
        } else if (type == 2) {
            data[rt << 1] += lazy[rt];
            data[((rt << 1) | 1)] += lazy[rt];
        }
        lazy[rt] = 0;
    }
    void build_(T * base, int l, int r, int rt) {
        lazy[rt] = 0;
        if (l == r) data[rt] = base[l];
        else {
            int mid = (l + r) >> 1;
            build_(base, l, mid, rt << 1);
            build_(base, mid + 1, r, ((rt << 1) | 1));
            pushup(rt);
        }
    }
    void modify_(int l, int r, int rt, int L, int R, T v) {
        if (L <= l && r <= R) {
            lazy[rt] += v;
            if (type == 0) data[rt] += v * (r - l + 1);
            else if (type == 1) data[rt] += v;
            else if (type == 2) data[rt] += v;
            return;
        }
        pushdown(rt, r - l + 1);
        int mid = (l + r) >> 1;
        if (L <= mid) modify_(l, mid, rt << 1, L, R, v);
        if (R > mid) modify_(mid + 1, r, ((rt << 1) | 1), L, R, v);
        pushup(rt);
    }
    T query_(int l, int r, int rt, int val) {
        if (l == r) return data[rt];
        pushdown(rt, r - l + 1);
        int mid = (l + r) >> 1;
        T ret = 0;
        if (val <= mid) ret = query_(l, mid, rt << 1, val);
        else ret = query_(mid + 1, r, ((rt << 1) | 1), val);
        pushup(rt);
        return ret;
    }
    T query_(int l, int r, int rt, int L, int R) {
        pushdown(rt, r - l + 1);
        if (L == l && R == r) return data[rt];
        int mid = (l + r) >> 1;
        if (R <= mid) return query_(l, mid, rt << 1, L, R);
        if (mid < L) return query_(mid + 1, r, ((rt << 1) | 1), L, R);
        if (type == 0) return query_(l, mid, rt << 1, L, mid) + query_(mid + 1, r, ((rt << 1) | 1), mid + 1, R);
        else if (type == 1) return max(query_(l, mid, rt << 1, L, mid), query_(mid + 1, r, ((rt << 1) | 1), mid + 1, R));
        else if (type == 2) return min(query_(l, mid, rt << 1, L, mid), query_(mid + 1, r, ((rt << 1) | 1), mid + 1, R));
    }
public:
    SegmentTree(int n, int t) : data(new T[n << 3]), lazy(new T[n << 3]), type(t) {}
    void build(T* base, int l, int r) {
        ll = l, rr = r;
        build_(base, ll, rr, 1);
    }
    void modify(int l, int r, int v) {
        if (l > r || l < ll || rr < r) return;
        modify_(ll, rr, 1, l, r, v);
    }
    void modify(int p, int v) {
        if (p < ll || rr < p) return;
        modify_(ll, rr, 1, p, p, v);
    }
    T query(int l, int r) {
        if (l > r || l < ll || rr < r) return (T)(-1);
        return query_(ll, rr, 1, l, r);
    }
    T query(int p) {
        if (p < ll || rr < p) return (T)(-1);
        return query(ll, rr, 1, p);
    }
    ~SegmentTree() {
        delete[] data, delete[] lazy;
    }
};
SegmentTree<lnt> sw(220000, 0), swa(220000, 0);
const lnt mod = 1000000007;
lnt a[220000], w[220000], wa[220000];

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    //makedata();
    std::ios::sync_with_stdio(0), cin.tie(0);
    int n, q, x, y, l, r, k;
    cin >> n >> q;
    rep(i, 1, n) {
        cin >> a[i];
        a[i] -= i;
    }
    rep(i, 1, n) {
        cin >> w[i];
        wa[i] = w[i] * a[i] % mod;
    }
    sw.build(w, 1, n);
    swa.build(wa, 1, n);
    rep(i, 1, q) {
        cin >> x >> y;
        if (x < 0) {
            sw.modify(-x, y - w[-x]);
            swa.modify(-x, (y - w[-x])*a[-x]);
            w[-x] = y;
        } else {
            if (x == y) {
                writeln(0);
                continue;
            }
            lnt sxy = sw.query(x, y) / 2;
            l = x, r = y;
            while (l + 1 < r) {
                k = (l + r) / 2;
                if (sw.query(x, k) <= sxy) l = k;
                else r = k;
            }
            k = l + 1;
            lnt ans = 0;
            if (x < k) {
                ADDMOD(ans, a[k] * sw.query(x, k - 1), mod);
                ADDMOD(ans, -1 * swa.query(x, k - 1), mod);
            }
            if (k < y) {
                ADDMOD(ans, -1 * a[k] * sw.query(k + 1, y), mod);
                ADDMOD(ans, swa.query(k + 1, y), mod);
            }
            writeln(ans);
        }
    }
    return 0;
}

#pragma comment(linker, "/STACK:102400000,102400000")
#ifndef ONLINE_JUDGE
#include "stdafx.h"
#else
#include<bits/stdc++.h>
#endif
using namespace std;
#define rep(i,a,b) for (int i=(a);i<=(b);i++)
#define per(i,a,b) for (int i=(a);i>=(b);i--)
#define trav(a,x) for (auto &a:x)
#define mp(a,b) make_pair(a,b)
#define all(x) x.begin(),x.end()
#define fill(x,c) memset(x,c,sizeof(x))
#define write(x) cout<<(x)<<' '
#define writeln(x) cout<<(x)<<endl
#define ADDMOD(x,a,m) x=((x)+(a)%m)%(m)
#define MLTMOD(x,a,m) x=((x)*((a)%m))%(m)
typedef long long lnt;
typedef vector<int> VI;
typedef vector<lnt> VL;
typedef pair<int, int> PII;
typedef pair<lnt, lnt> PLL;
typedef vector<pair<int, int>> VPI;
typedef vector<pair<lnt, lnt>> VPL;
typedef queue<int> QI;
typedef queue<lnt> QL;
typedef map<int, int> MII;
typedef map<lnt, lnt> MLL;
typedef map<int, pair<int, int>> MPI;
typedef map<lnt, pair<lnt, lnt>> MPL;
typedef map<int, vector<int>> MVI;
typedef map<lnt, vector<lnt>> MVL;
typedef set<int> SI;
typedef set<lnt> SL;
typedef set<pair<int, int>> SPI;
typedef set<pair<lnt, lnt>> SPL;

inline lnt pow(lnt a, lnt b, lnt p) {
    lnt rtn = 1;
    while (b) {
        if (b & 1) rtn = rtn * a % p;
        a = a * a % p;
        b >>= 1;
    }
    return rtn;
}
lnt inv(lnt a, lnt p) {
    return pow(a, p - 2, p);
}
long long gcd(long long a, long long b) {
    long long k;
    while (b != 0) {
        k = b;
        b = a % b;
        a = k;
    }
    return a;
}
void makedata() {
    freopen("input.txt", "w", stdout);
    srand((unsigned)time(NULL));
    fclose(stdout);
}
template <typename T> class SegmentTree {
    /*
    type:
    0:sum
    1:max
    2:min
    */
private:
    T *data, *lazy;
    int type, ll, rr;
    inline void pushup(int rt) {
        if (type == 0) data[rt] = data[rt << 1] + data[((rt << 1) | 1)];
        else if (type == 1) data[rt] = max(data[rt << 1], data[((rt << 1) | 1)]);
        else if (type == 2) data[rt] = min(data[rt << 1], data[((rt << 1) | 1)]);
    }
    inline void pushdown(int rt, T m) {
        if (lazy[rt] == 0) return;
        lazy[rt << 1] += lazy[rt];
        lazy[((rt << 1) | 1)] += lazy[rt];
        if (type == 0) {
            data[rt << 1] += (m - (m >> 1)) * lazy[rt];
            data[((rt << 1) | 1)] += (m >> 1) * lazy[rt];
        } else if (type == 1) {
            data[rt << 1] += lazy[rt];
            data[((rt << 1) | 1)] += lazy[rt];
        } else if (type == 2) {
            data[rt << 1] += lazy[rt];
            data[((rt << 1) | 1)] += lazy[rt];
        }
        lazy[rt] = 0;
    }
    void build_(T * base, int l, int r, int rt) {
        lazy[rt] = 0;
        if (l == r) data[rt] = base[l];
        else {
            int mid = (l + r) >> 1;
            build_(base, l, mid, rt << 1);
            build_(base, mid + 1, r, ((rt << 1) | 1));
            pushup(rt);
        }
    }
    void modify_(int l, int r, int rt, int L, int R, T v) {
        if (L <= l && r <= R) {
            lazy[rt] += v;
            if (type == 0) data[rt] += v * (r - l + 1);
            else if (type == 1) data[rt] += v;
            else if (type == 2) data[rt] += v;
            return;
        }
        pushdown(rt, r - l + 1);
        int mid = (l + r) >> 1;
        if (L <= mid) modify_(l, mid, rt << 1, L, R, v);
        if (R > mid) modify_(mid + 1, r, ((rt << 1) | 1), L, R, v);
        pushup(rt);
    }
    T query_(int l, int r, int rt, int val) {
        if (l == r) return data[rt];
        pushdown(rt, r - l + 1);
        int mid = (l + r) >> 1;
        T ret = 0;
        if (val <= mid) ret = query_(l, mid, rt << 1, val);
        else ret = query_(mid + 1, r, ((rt << 1) | 1), val);
        pushup(rt);
        return ret;
    }
    T query_(int l, int r, int rt, int L, int R) {
        pushdown(rt, r - l + 1);
        if (L == l && R == r) return data[rt];
        int mid = (l + r) >> 1;
        if (R <= mid) return query_(l, mid, rt << 1, L, R);
        if (mid < L) return query_(mid + 1, r, ((rt << 1) | 1), L, R);
        if (type == 0) return query_(l, mid, rt << 1, L, mid) + query_(mid + 1, r, ((rt << 1) | 1), mid + 1, R);
        else if (type == 1) return max(query_(l, mid, rt << 1, L, mid), query_(mid + 1, r, ((rt << 1) | 1), mid + 1, R));
        else if (type == 2) return min(query_(l, mid, rt << 1, L, mid), query_(mid + 1, r, ((rt << 1) | 1), mid + 1, R));
    }
public:
    SegmentTree(int n, int t) : data(new T[n << 3]), lazy(new T[n << 3]), type(t) {}
    void build(T* base, int l, int r) {
        ll = l, rr = r;
        build_(base, ll, rr, 1);
    }
    void modify(int l, int r, int v) {
        if (l > r || l < ll || rr < r) return;
        modify_(ll, rr, 1, l, r, v);
    }
    void modify(int p, int v) {
        if (p < ll || rr < p) return;
        modify_(ll, rr, 1, p, p, v);
    }
    T query(int l, int r) {
        if (l > r || l < ll || rr < r) return (T)(-1);
        return query_(ll, rr, 1, l, r);
    }
    T query(int p) {
        if (p < ll || rr < p) return (T)(-1);
        return query(ll, rr, 1, p);
    }
    ~SegmentTree() {
        delete[] data, delete[] lazy;
    }
};
SegmentTree<lnt> sw(220000, 0), swa(220000, 0);
const lnt mod = 1000000007;
lnt a[220000], w[220000], wa[220000];

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    //makedata();
    std::ios::sync_with_stdio(0), cin.tie(0);
    int n, q, x, y, l, r, k;
    cin >> n >> q;
    rep(i, 1, n) {
        cin >> a[i];
        a[i] -= i;
    }
    rep(i, 1, n) {
        cin >> w[i];
        wa[i] = w[i] * a[i] % mod;
    }
    sw.build(w, 1, n);
    swa.build(wa, 1, n);
    rep(i, 1, q) {
        cin >> x >> y;
        if (x < 0) {
            sw.modify(-x, y - w[-x]);
            swa.modify(-x, (y - w[-x])*a[-x]);
            w[-x] = y;
        } else {
            lnt sxy = sw.query(x, y) / 2;
            l = x, r = y;
            while (l + 1 < r) {
                k = (l + r) / 2;
                if (sw.query(x, k) <= sxy) l = k;
                else r = k;
            }
            k = l + 1;
            lnt ans = 0;
            if (x < k) {
                ADDMOD(ans, a[k] * sw.query(x, k - 1), mod);
                ADDMOD(ans, -1 * swa.query(x, k - 1), mod);
            }
            if (k < y) {
                ADDMOD(ans, -1 * a[k] * sw.query(k + 1, y), mod);
                ADDMOD(ans, swa.query(k + 1, y), mod);
            }
            writeln(ans);
        }
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

/// Typedef
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector< pii > vii;

#define pb                  push_back
#define ppb                 pop_back
#define MP                  make_pair
#define ff                  first
#define ss                  second
#define sf                  scanf
#define pf                  printf
#define loop(i, y)          for(int i=0; i<int(y); i++)
#define FOR(i, x, y)        for(int i=int(x); i<int(y); i++)
#define ROF(i, x, y)        for(int i=int(x-1); i>=int(y); i--)
#define tr(it, container)   for(auto it = container.begin(); it != container.end(); it++)
#define Binary(x,b)         std::bitset< b >( x ).to_string()
#define fastIO              ios::sync_with_stdio(false);    cin.tie(nullptr);   cout.tie(nullptr)
#define ran(a, b)           ((((rand() << 15) ^ rand()) % ((b) - (a) + 1)) + (a))
#define CLR(x, y)           memset(x, y, sizeof(x))
#define Read(x)             freopen(x,"r",stdin)
#define Write(x)            freopen(x,"w",stdout)
#define sc(n)               sf("%d",&n)
#define sc2(a,b)            sf("%d%d",&a,&b)
#define sc3(a,b,c)          sf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d)        sf("%d%d%d%d",&a,&b,&c,&d)
#define scll(n)             sf("%lld",&n)
#define scll2(a,b)          sf("%lld%lld",&a,&b)
#define scll3(a,b,c)        sf("%lld%lld%lld",&a,&b,&c)
#define scll4(a,b,c,d)      sf("%lld%lld%lld%lld",&a,&b,&c,&d)
#define bitCheck(N,in)      ((bool)(N&(1<<(in))))
#define bitOff(N,in)        (N&(~(1LL<<(in))))
#define bitOn(N,in)         (N|(1LL<<(in)))
#define bitFlip(a,k)        (a^(1LL<<(k)))
#define bitCount(a)         __builtin_popcount(a)
#define bitCountLL(a)       __builtin_popcountll(a)
#define bitRightMost(a)     __builtin_ctzll(a)
#define bitLeftMost(a)      (63-__builtin_clzll(a))
#define SQR(x)              ((x)*(x))
#define mxEq(a,b)           (a = max(a,b))
#define all(c)              c.begin(), c.end()
#define unq(v)              sort(all(v)), (v).resize(unique(all(v)) - v.begin())
#define common(a,b)         sort(all(a)), sort(all(b)), a.erase(set_intersection(all(a),all(b),a.begin()),a.end())
#define uncommon(a,b)       sort(all(a)), sort(all(b)), a.erase(set_symmetric_difference(all(a),all(b),a.begin()),a.end())

// uniform random generator -->
// uniform_int_distribution<int> dist(0, 1);
// default_random_engine gen;

// *X.find_by_order(k) //returns the kth largest element.(0-based)
// X.order_of_key(val) //returns the no. of values less than val
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // C++98
// template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline T bigMod(T p,T e,T M){ ll ret = 1; for(; e > 0; e >>= 1){ if(e & 1) ret = (ret * p) % M; p = (p * p) % M; } return (T) ret;}
template <class T> inline T modInverse(T a,T M){return bigMod(a,M-2,M);}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/gcd(a,b))*b;}
template <class T> inline string int2String(T a){ostringstream str; str<<a; return str.str();}
const int dr[] = { 0,  1,  0, -1,        -1,  1,  1, -1,     -2, -2,  2,  2, -1, -1,  1,  1};
const int dc[] = { 1,  0, -1,  0,         1,  1, -1, -1,     -1,  1, -1,  1, -2,  2, -2,  2};

/// Constants
#define MAX                 2250000000000
#define MOD                 1000000007
//#define base                1000000007
#define eps                 1e-9
#define INF                 LLONG_MAX
#define inf                 2000000000
#define PI                  (2.0*acos(0.0))  // 3.1415926535897932
#define Log(b,x)            (log(x)/log(b))

/// Debug
#define dbg(x)              cout << #x << " = " << x << endl
#define out2(a,b)           cout<<a<<" "<<b<<endl
#define out3(a,b,c)         cout<<a<<" "<<b<<" "<<c<<endl
#define out4(a,b,c,d)       cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define out5(a,b,c,d,e)     cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl
void fileIO()
{
	#ifndef ONLINE_JUDGE
        Read("//home//pranto//Desktop//input.txt");
        Write("//home//pranto//Desktop//output.txt");
    #else
      // Read("immetric.in");
      // Write("immetric.out");
    #endif
}

/// Priority Queue custom compare
// std::priority_queue<int, std::vector<int>, decltype(&cmp) > pq(cmp);

int norm(int a) { 		return a >= MOD ? a - MOD : (a + MOD)%MOD;}
int norm(const ll &a) {	return norm(int(a % MOD));	}
int mul(int a, int b) { return int((a * 1ll * b) % MOD);}
const int N = 200 * 1000 + 555;
int n, q;
int a[N], w[N];
inline bool read() { // reads inputs
	if(!(cin >> n >> q))	return false;

	FOR(i, 0, n)	assert(scanf("%d", &a[i]) == 1);
	FOR(i, 0, n)	assert(scanf("%d", &w[i]) == 1);
	return true;
}
ll fW[N], fAW[N];
void inc(ll f[N], int pos, ll val) { // in BIT array update pos to N by val

	for(; pos < N; pos |= pos + 1)	f[pos] += val;
}
ll sum(ll f[N], int pos) { // retruns sum upto pos
	ll ans = 0;
	for(; pos >= 0; pos = (pos & (pos + 1)) - 1)	ans += f[pos];
	return ans;
}
ll getSum(ll f[N], int l, int r) { // returns sum of segment l to r

	return sum(f, r - 1) - sum(f, l - 1);
}
int getNSum(ll f[N], int l, int r) { // as like getSum() but it does MOD

	return norm(sum(f, r - 1) - sum(f, l - 1));
}
inline void solve() {
	FOR(i, 0, n) { // initiates fW and fAW arrays
		//out2(a[i],a[i]-i-1);
		a[i] -= i+1; // a[i] replaced by number of empty slot before it
		inc(fW, i, w[i]);
		inc(fAW, i, mul(a[i], w[i]));
	}	//cout << endl;
	FOR(_, 0, q) {
		int x, y;
		assert(scanf("%d%d", &x, &y) == 2);
		if(x < 0) { // update new weights
			x = -x - 1;
			inc(fW, x, -w[x]);
			inc(fAW, x, -mul(a[x], w[x]));

			w[x] = y;
			inc(fW, x, w[x]);
			inc(fAW, x, mul(a[x], w[x]));
		} else {
			x--;
			ll sum = getSum(fW, x, y); // sum of weigths of x-y segment

			int lf = x, rg = y; // lo = lf, hi = rg
			while(lf+1 < rg) { // find optimal mid point by BS ans lf is that point
				int mid = (lf + rg) >> 1, cost = getSum(fW, x, mid);
				if(2*cost > sum)	rg = mid;
				else				lf = mid;
			} assert(x <= lf && lf < y);
			/*if(x == 0 && y == 5){
				dbg(lf);
				dbg(a[lf]);
				cout << getNSum(fW,x,lf)  << " " << mul(a[lf], getNSum(fW, x, lf)) << " " << getNSum(fAW, x, lf) << endl;
				cout << getNSum(fAW,lf,y) << " " << mul(a[lf], getNSum(fW, lf, y)) << endl;

				int ans = norm( mul(a[lf], getNSum(fW, x, lf) ) - getNSum(fAW, x, lf));
				ans = norm(ans + norm(getNSum(fAW, lf, y) - mul(a[lf], getNSum(fW, lf, y))) );
				printf("%d\n", ans);
				return;
			}*/
			int ans = norm( mul(a[lf], getNSum(fW, x, lf) ) - getNSum(fAW, x, lf));
			ans = norm(ans + norm(getNSum(fAW, lf, y) - mul(a[lf], getNSum(fW, lf, y))) );
			printf("%d\n", ans);
		}
	}
}

int main()
{
	//fastIO;
    fileIO();  int start_s=clock();

    read();
    solve();

    //int end_s=clock();
    //printf("\nTime :: %.2lf\n", (double)(end_s-start_s)/CLOCKS_PER_SEC);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,q;
const int maxn=2e5+5;
const ll mod=1e9+7;
ll a[maxn],w[maxn];
ll lowbit(ll x) {return x&-x;}
void add(ll t[],ll x,ll d)
{
    for(;x<maxn;x+=lowbit(x))
    {
        t[x]+=d;
    }
}

ll ask(ll t[],ll x,int typ)
{
    ll ret=0;
    for(;x;x-=lowbit(x))
    {
        ret+=t[x];
        if(typ) ret%=mod;
    }
    return ret;
}
ll sum[maxn];
ll t[maxn];
int main()
{
    scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++) {scanf("%lld",a+i);a[i]-=i;}
    for(int i=1;i<=n;i++) {scanf("%lld",w+i);add(t,i,w[i]);add(sum,i,w[i]*a[i]);}

    while(q--)
    {
        ll l,r;
        scanf("%lld%lld",&l,&r);
        if(l<0)
        {
            add(t,-l,r-w[-l]);
            add(sum,-l,a[-l]*(r-w[-l]));
            w[-l]=r;
        }
        else
        {
            ll L=l-1,R=r;
            ll all=ask(t,r,0)-ask(t,l-1,0);
            while(L+1<R)
            {
                ll mid=(L+R)/2;
                if(ask(t,mid,0)-ask(t,l-1,0)>all/2) R=mid;
                else L=mid;
            }
            ll k=R;
            ll ans=a[k]*(ask(t,k-1,1)-ask(t,l-1,1)+mod)%mod;
            ans-=(ask(sum,k-1,1)-ask(sum,l-1,1)+mod)%mod;
            ans=(ans+mod)%mod;
            (ans+=(ask(sum,r,1)-ask(sum,k,1)+mod))%=mod;
            ans-=a[k]*(ask(t,r,1)-ask(t,k,1)+mod)%mod;
            ans=(ans+mod)%mod;
            printf("%lld\n",ans);
        }
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) begin(a), end(a)
#define has(a, b) (a.find(b) != a.end())
#define fora(i, n) for(int i = 0; i < n; i++)
#define forb(i, n) for(int i = 1; i <= n; i++)
#define forc(a, b) for(const auto &a : b)
#define ford(i, n) for(int i = n; i >= 0; i--)
#define maxval(t) numeric_limits<t>::max()
#define minval(t) numeric_limits<t>::min()
#define imin(a, b) a = min(a, b)
#define imax(a, b) a = max(a, b)
#define sz(x) (int)(x).size()
#define pvec(v) copy(all(v), ostream_iterator<decltype(v)::value_type>(cout, " "))

#define dbgs(x) #x << " = " << x
#define dbgs2(x, y) dbgs(x) << ", " << dbgs(y)
#define dbgs3(x, y, z) dbgs2(x, y) << ", " << dbgs(z)
#define dbgs4(w, x, y, z) dbgs3(w, x, y) << ", " << dbgs(z)

using ll = long long;
using ld = long double;

constexpr ll mod = 1000000007;

struct modft {
    vector<ll> tree;

    void update(int i, ll val) {
        i++; while(i < sz(tree)) { tree[i] += val; tree[i] %= mod; i += (i & (-i)); }
    }

    modft(int n) {
        tree.assign(n + 1, 0);
    }

    ll prefix_sum(int i) {
        ll sum = 0; i++;
        while(i > 0) { sum += tree[i]; sum %= mod; i -= (i & (-i)); }
        return sum;
    }

    // [l, r)
    ll query(int l, int r) {
        if (l == r) return 0;
        --r; --l;
        ll res = prefix_sum(r);
        if (l >= 0) res -= prefix_sum(l);
        return ((res % mod) + mod) % mod;
    }

    void set(int i, ll val) {
        ll cur = query(i, i + 1);
        update(i, (((val - cur) % mod) + mod) % mod);
    }
};

struct ft {
    vector<ll> tree;

    void update(int i, ll val) {
        i++; while(i < sz(tree)) { tree[i] += val; i += (i & (-i)); }
    }

    ft(int n) {
        tree.assign(n + 1, 0);
    }

    ll prefix_sum(int i) {
        ll sum = 0; i++;
        while(i > 0) { sum += tree[i]; i -= (i & (-i)); }
        return sum;
    }

    // [l, r)
    ll query(int l, int r) {
        if (l == r) return 0;
        --r; --l;
        ll res = prefix_sum(r);
        if (l >= 0) res -= prefix_sum(l);
        return res;
    }

    void set(int i, ll val) {
        ll cur = query(i, i + 1);
        update(i, val - cur);
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, q;
    cin >> n >> q;

    vector<ll> a(n), w(n);

    ft raw(n);
    modft lin(n), space(n);

    fora(i, n) cin >> a[i];
    fora(i, n) {
        cin >> w[i];
        raw.update(i, w[i]);
        lin.update(i, (i * w[i]) % mod);
        space.update(i, (a[i] * w[i]) % mod);
    }

    fora(_, q) {
        ll x, y;
        cin >> x >> y;
        if (x < 0) {
            int i = (int)(-x - 1);
            w[i] = y;
            raw.set(i, w[i]);
            lin.set(i, (i * w[i]) % mod);
            space.set(i, (a[i] * w[i]) % mod);
        } else {
            // Step 1: Find optimal k

            --x;
            // [x, y)

            int lo = (int)x;
            int hi = (int)y;
            ll sum = raw.query(lo, hi);

            // [lo, hi)
            while (hi - lo > 1) {
                int mid = (lo + hi) / 2;
                if (raw.query((int)x, mid) * 2 >= sum) {
                    hi = mid;
                } else {
                    lo = mid;
                }
            }

            int _x = (int)x;
            int _y = (int)y;
            int k = lo;

            // Step 2: Calculate answer
            ll left = ((a[k] - k) * raw.query(_x, k)) % mod;
            left = (left - space.query(_x, k)) % mod;
            left = (left + lin.query(_x, k)) % mod;

            ll right = ((k - a[k]) * raw.query(k + 1, _y)) % mod;
            right = (right + space.query(k + 1, _y)) % mod;
            right = (right - lin.query(k + 1, _y)) % mod;

            ll ans = (((left + right) % mod) + mod) % mod;
            cout << ans << '\n';
        }
    }

}

#include <bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
    ios_base::sync_with_stdio(0); cin.tie(0);
    freopen((s+".in").c_str(),"r",stdin);
    freopen((s+".out").c_str(),"w",stdout);
}
ll seg[800001],seg1[800001];
ll seg2[800001],seg3[800001];
ll cura[200001];
ve initial,fat,nowi,nowi1;
ll n;
ll BIT[800001];
ll curi[800001],casi[800001];
void build(ll p,ll l,ll r,ll yo)
{
    if(l==r)
    {
        if(!yo)
        {
            if(!l)seg[p]=0;
            else seg[p]=(nowi[l]*((fat[l]-(fat[l-1]+1)+MOD)%MOD))%MOD;
        }
        else
        {
            if(l==(n-1))seg1[p]=0;
            else seg1[p]=(nowi1[l]*((fat[l+1]-(fat[l]+1)+MOD)%MOD))%MOD;
        }
        return;
    }
    ll med=(l+r)/2;
    build(p*2,l,med,yo);
    build(p*2+1,med+1,r,yo);
    if(!yo)
    {
        seg[p]=(seg[p*2]+seg[p*2+1])%MOD;
    }
    else seg1[p]=(seg1[p*2]+seg1[p*2+1])%MOD;
}

void build3(ll p,ll l,ll r)
{
    if(l==r)
    {
        ll ka = fat[l-1]+1;
        ll sa = fat[l]+1;
        if(!l)seg2[p]=0;

        else seg2[p]=(fat[l]-ka+MOD)%MOD;
        if(l==(n-1))seg3[p]=0;

        else seg3[p]=(fat[l+1]-sa+MOD)%MOD;
        cura[l]=seg2[p];
        casi[l]=seg3[p];
        return;
    }
    ll med=(l+r)/2;
    build3(p*2,l,med);
    build3(p*2+1,med+1,r);
    seg2[p]=(seg2[p*2]+seg2[p*2+1]);
    seg3[p]=(seg3[p*2]+seg3[p*2+1]);
}

dos queri(ll p,ll l,ll r,ll l1,ll r1)
{
    if(l>r1 || l1>r)return {0,0};
    if(l>=l1 && r<=r1)return{seg2[p],seg3[p]};
    ll med=(l+r)/2;
    auto u = queri(p*2,l,med,l1,r1);
    auto v = queri(p*2+1,med+1,r,l1,r1);
    return {(u.first+v.first),(u.second+v.second)};
}
ve bos,fos;
ll lazy[800001],lazy1[800001];
ll l;
void prop(ll node,ll l,ll r,ll in)
{
    if(l!=r)
    {
        ll med=(l+r)/2;

        auto u = 0;
        auto v = 0;
        if(!in)
        {
        if(!l)u=fos[med];
        else u=fos[med]-fos[l-1];
        if(!(med+1))v=fos[r];
        else v=fos[r]-fos[med];
        seg[node*2]=(seg[node*2]+(((u)*lazy[node])%MOD))%MOD;
        seg[node*2+1]=(seg[node*2+1]+(((v)*lazy[node])%MOD))%MOD;
        //debugs(seg[node*2],seg[node*2+1])
        lazy[node*2]+=lazy[node];
        lazy[node*2+1]+=lazy[node];
        lazy[node]=0;
        }
        else
        {
        if(!l)u=bos[med];
        else u=bos[med]-bos[l-1];
        if(!(med+1))v=bos[r];
        else v=bos[r]-bos[med];
        seg1[node*2]=(seg1[node*2]+((u)*lazy1[node])%MOD)%MOD;
        seg1[node*2+1]=(seg1[node*2+1]+((v)*lazy1[node])%MOD)%MOD;
        lazy1[node*2]+=lazy1[node];
        lazy1[node*2+1]+=lazy1[node];
        lazy1[node]=0;
        }
    }
}
void badel(ll p,ll l,ll r,ll l1,ll r1,ll val,ll sasy)
{
    if(l1>r1)return;
    if(l>r1||r<l1)return;
    if(l>=l1 && r<=r1)
    {
        auto cur = 0;
        if(!sasy)
        {
            if(!l)cur=fos[r];
            else cur=fos[r]-fos[l-1];
            seg[p]=(seg[p]+((cur)*val)%MOD)%MOD;
            lazy[p]+=val;
        }
        else
        {
            if(!l)cur=bos[r];
            else cur=bos[r]-bos[l-1];
            seg1[p]=(seg1[p]+((cur)*val)%MOD)%MOD;
            lazy1[p]+=val;
        }
        prop(p,l,r,sasy);
        return;
    }
    prop(p,l,r,sasy);
    ll med=(l+r)/2;
    badel(p*2,l,med,l1,r1,val,sasy);
    badel(p*2+1,med+1,r,l1,r1,val,sasy);
    if(!sasy)
    {
        seg[p]=(seg[p*2]+seg[p*2+1])%MOD;
    }
    else seg1[p]=(seg1[p*2]+seg1[p*2+1])%MOD;
}
ll lawej(ll p,ll l,ll r,ll l1,ll r1,ll sasy)
{
    if(l1>r1)return 0;
    if(l>r1||r<l1)return 0;
    if(l>=l1 && r<=r1)
    {
         if(!sasy)return seg[p];
         return seg1[p];
    }
    prop(p,l,r,sasy);
    ll med=(l+r)/2;
    return (lawej(p*2,l,med,l1,r1,sasy)+lawej(p*2+1,med+1,r,l1,r1,sasy));
}
void update(ll index,ll val)
{
    for (index++; index <= n; index+=(index&(-index)))
    {
        BIT[index]+=val;
    }
}
ll query(ll index)
{
    ll result=0;
    for (index++;index>0;index-=(index&(-index)))
    {
        result=(result+BIT[index]);
    }
    return result;
}
ll range(ll l,ll r)
{
    if(l>r)return 0;
    return ((query(r)-query(l-1)));
}
int main()
{
    flash;
    ll q;
    cin>>n>>q;
    l=log2(n);
    for (ll i = 0; i < n; ++i)
    {
        ll xo;
        cin>>xo;
        fat.pb(xo);
    }
    for (ll i = 0; i < n; ++i)
    {
        ll yo;
        cin>>yo;
        initial.pb(yo);
        curi[i]=yo;
        update(i,yo);
    }
    ll cumi=0;
    ve useful;
    for (ll i = 0; i < n; ++i)
    {
       nowi.pb(cumi);
       cumi=(cumi+initial[i]);
       useful.pb(cumi);
    }
    cumi=0;
    for (ll i = n-1; i >= 0; --i)
    {
       nowi1.pb(cumi);
       cumi=(cumi+initial[i]);
    }
    reverse(nowi1.begin(),nowi1.end());
    build(1,0,n-1,0);
    build(1,0,n-1,1);
    build3(1,0,n-1);
    cumi=0;
    for (int i = 0; i < n; ++i)
    {
        cumi+=cura[i];
        fos.pb(cumi);
    }
    cumi=0;
    for (int i = 0; i < n; ++i)
    {
        cumi+=casi[i];
        bos.pb(cumi);
    }
    while(q--)
    {
        ll x;
        cin>>x;
        if(x<0)
        {
            x=-x-1;
            ll newi;
            ll lasti=curi[x];
            cin>>newi;
            update(x,newi-lasti);
            //debug(newi-lasti)
            badel(1,0,n-1,x+1,n-1,newi-lasti,0);
            badel(1,0,n-1,0,x-1,newi-lasti,1);
            curi[x]=newi;
        }
        else
        {
            ll r;
            cin>>r;
            ll l=x;
            l--,r--;
            ll low=l;
            ll high=r;
            ll besti=l;
            while(low<=high)
            {
                ll med=(low+high)/2;
                ll k = range(l,med-1);
                ll f = range(med,r);
                if((k-f)<0)
                {
                    besti=med;
                    low=med+1;
                }
                else
                {
                    high=med-1;
                }
            }
            ll fol=0;
            if(!l)fol=fos[besti];
            else fol = fos[besti]-fos[l-1];
            ll sol=0;
            if(!besti)sol=bos[r];
            else sol = bos[r]-bos[besti-1];
            auto kal = range(0,l-1)%MOD;
            auto nal = range(r+1,n-1)%MOD;
            //debugs(kal,nal)
            auto fin1 = lawej(1,0,n-1,l,besti,0)%MOD;
            auto fin2 = lawej(1,0,n-1,besti,r,1)%MOD;
            fin1 = ((fin1-((fol%MOD*kal%MOD)%MOD))+MOD)%MOD;
            fin2 = ((fin2-((sol%MOD*nal%MOD)%MOD))+MOD)%MOD;
            cout<<(fin1+fin2)%MOD<<'\n';
        }
    }
  return 0;
}
//code the AC sol !
// BS/queue/map

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int base = 1e6 + 3;

struct Number {
    long long fi, se;
    Number (long long fi = 0, long long se = 0): fi(fi), se(se) {}
    Number operator + (const Number &rhs) const {
        long long curfi = fi + rhs.fi;
        long long curse = se + rhs.se;
        curfi += curse / base;
        curse %= base;
        return Number(curfi, curse);
    }

    Number operator - (const Number &rhs) const {
        long long curfi = fi, curse = se;
        if (curse < rhs.se) {
            curfi--;
            curse += base;
        }

        curfi -= rhs.fi;
        curse -= rhs.se;
        curfi += curse / base;
        curse %= base;
        return Number(curfi, curse);
    }

    Number operator * (const Number &rhs) const {
        long long curfi = fi, curse = se;
        curfi = curfi * rhs.fi * base + fi * rhs.se + se * rhs.fi;
        curse = se * rhs.se;
        curfi += curse / base;
        curse %= base;
        return Number(curfi, curse);
    }

    bool operator < (const Number &rhs) const {
        return fi < rhs.fi || (fi == rhs.fi && se < rhs.se);
    }

    bool operator > (const Number &rhs) const {
        return fi > rhs.fi || (fi == rhs.fi && se > rhs.se);
    }

    bool operator == (const Number &rhs) const {
        return fi == rhs.fi && se == rhs.se;
    }

    bool operator != (const Number &rhs) const {
        return fi != rhs.fi || se != rhs.se;
    }
};

int n, q;
Number a[N], w[N];

struct seg {
    struct Node {
        Number sum, pref, suff, mul;
        Node (Number sum = Number(), Number pref = Number(), Number suff = Number(), Number mul = Number()): sum(sum), pref(pref), suff(suff), mul(mul) {}
        Node operator + (const Node &rhs) const {
            return Node(sum + rhs.sum, pref + rhs.pref, suff + rhs.suff, mul + rhs.mul);
        }
    } node[4 * N];

    void init (int i, int l, int r) {
        if (l == r) {
            Number L = Number(l / base, l % base);
            Number NL = Number((n - l + 1) / base, (n - l + 1) % base);
            node[i].sum = w[l];
            node[i].pref = L * w[l];
            node[i].suff = NL * w[l];
            node[i].mul = w[l] * a[l];
            return;
        }

        int m = (l + r) >> 1;
        init(i << 1, l, m);
        init(i << 1 | 1, m + 1, r);
        node[i] = node[i << 1] + node[i << 1 | 1];
    }

    void update (int i, int l, int r, int pos, int val) {
        if (l == r) {
            Number L = Number(l / base, l % base);
            Number NL = Number((n - l + 1) / base, (n - l + 1) % base);
            Number Val = Number(val / base, val % base);
            node[i].sum = Val;
            node[i].pref = L * Val;
            node[i].suff = NL * Val;
            node[i].mul = a[l] * Val;
            return;
        }

        int m = (l + r) >> 1;
        if (pos <= m) update(i << 1, l, m, pos, val);
        else update(i << 1 | 1, m + 1, r, pos, val);
        node[i] = node[i << 1] + node[i << 1 | 1];
    }

    Node get (int i, int l, int r, int a, int b) {
        if (l > r || a > r || b < l) return Node();
        if (a <= l && r <= b) return node[i];

        int m = (l + r) >> 1;
        return get(i << 1, l, m, a, b) + get(i << 1 | 1, m + 1, r, a, b);
    }
} it;

Number calc (int x, int l, int r) {
    Number X = Number(x / base, x % base);
    Number NX = Number((n - x + 1) / base, (n - x + 1) % base);
    Number lefw = it.get(1, 1, n, l, x - 1).sum;
    Number rigw = it.get(1, 1, n, x + 1, r).sum;
    Number ans = a[x] * (lefw - rigw);
    Number lefmul = it.get(1, 1, n, l, x - 1).mul;
    Number rigmul = it.get(1, 1, n, x + 1, r).mul;
    ans = ans + rigmul - lefmul;
    Number rigpref = it.get(1, 1, n, x + 1, r).pref - X * rigw;
    Number lefsuff = it.get(1, 1, n, l, x - 1).suff - NX * lefw;
    ans = ans - (lefsuff + rigpref);
    return ans;
}

void solve (int x, int y) {
    int l = x, r = y;
    while (r - l > 2) {
        int mid1 = l + (r - l) / 3;
        int mid2 = r - (r - l) / 3;
        if (calc(mid1, x, y) > calc(mid2, x, y)) l = mid1;
        else r = mid2;
    }

    Number ans = calc(l, x, y);
    for (int i = l + 1; i <= r; i++) if (calc(i, x, y) < ans) ans = calc(i, x, y);
    long long res = (1LL * ans.fi % mod * base % mod + ans.se) % mod;
    printf("%lld\n", res);
}

int main(){
    scanf("%d %d", &n, &q);
    for (int i = 1; i <= n; i++) {
        int x;
        scanf("%d", &x);
        a[i].fi = x / base; a[i].se = x % base;
    }

    for (int i = 1; i <= n; i++) {
        int x;
        scanf("%d", &x);
        w[i].fi = x / base; w[i].se = x % base;
    }

    it.init(1, 1, n);
    while (q--) {
        int l, r;
        scanf("%d %d", &l, &r);
        if (l < 0) it.update(1, 1, n, -l, r);
        else solve(l, r);
    }
    return 0;
}
/*
5 1
1 2 6 7 10
1 1 1 1 2
1 5
*/

#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

namespace IO {
    const int BUFFER_SIZE = 4096;

    char input_buffer[BUFFER_SIZE];
    int input_pos = BUFFER_SIZE;
    int input_read = BUFFER_SIZE;

    char output_buffer[BUFFER_SIZE];
    int output_pos = 0;

    void _update_input_buffer() {
        if (input_pos >= input_read && input_read == BUFFER_SIZE) {
            input_read = fread(input_buffer, sizeof(char), BUFFER_SIZE, stdin);
            input_pos = 0;
        }
    }

    char next_char(bool advance = true) {
        _update_input_buffer();
        return input_buffer[advance ? input_pos++ : input_pos];
    }

    void skip_whitespace() {
        while (isspace(next_char(false)))
            next_char();
    }

    bool input_finished() {
        skip_whitespace();
        return input_pos >= input_read && input_read < BUFFER_SIZE;
    }

    template<typename T>
    void read_int(T &number) {
        skip_whitespace();
        bool negative = next_char(false) == '-';

        if (negative)
            next_char();

        number = 0;

        while (isdigit(next_char(false)))
            number = 10 * number + (next_char() - '0');

        if (negative)
            number = -number;
    }

    void flush_output() {
        fwrite(output_buffer, sizeof(char), output_pos, stdout);
        output_pos = 0;
    }

    void write_char(char c) {
        if (output_pos == BUFFER_SIZE)
            flush_output();

        output_buffer[output_pos++] = c;
    }

    template<typename T>
    void write_int(T number, char after = 0) {
        if (number < 0) {
            write_char('-');
            number = -number;
        }

        static char number_buffer[100];
        int length = 0;

        do {
            number_buffer[length++] = number % 10 + '0';
            number /= 10;
        } while (number > 0);

        for (int i = length - 1; i >= 0; i--)
            write_char(number_buffer[i]);

        if (after)
            write_char(after);
    }

    // Make sure flush_output() is called at the end of the program.
    bool exit_success = atexit(flush_output) == 0;
}

const int MOD = 1e9 + 7;

struct tree_node {
    long long w_sum, aw_sum;

    tree_node() : w_sum(0), aw_sum(0) {}

    void join(const tree_node &other) {
        w_sum += other.w_sum;
        aw_sum += other.aw_sum;
    }
};

int N, LOG, Q;
vector<int> A, W;
vector<tree_node> tree;

// O(N) initialization of our BIT.
void build_tree() {
    for (int i = 1; i <= N; i++) {
        for (int k = (i & -i) >> 1; k > 0; k >>= 1)
            tree[i].join(tree[i - k]);

        tree[i].w_sum += W[i - 1];
        tree[i].aw_sum = (tree[i].aw_sum + (long long) W[i - 1] * A[i - 1]) % MOD;
    }
}

void tree_update(int index, long long w_change, int a) {
    int aw_change = (MOD + w_change) * a % MOD;

    for (int i = index + 1; i <= N; i += i & -i) {
        tree[i].w_sum += w_change;
        tree[i].aw_sum += aw_change;
    }
}

tree_node tree_query(int count) {
    tree_node answer;

    for (int i = count; i > 0; i -= i & -i)
        answer.join(tree[i]);

    return answer;
}

int solve(int start, int end) {
    tree_node end_range = tree_query(end);
    tree_node start_range = tree_query(start);
    long long search = (start_range.w_sum + end_range.w_sum + 1) / 2;
    int goal = 0;
    tree_node goal_range;

    for (int k = LOG - 1; k >= 0; k--)
        if (goal + (1 << k) <= N && goal_range.w_sum + tree[goal + (1 << k)].w_sum < search) {
            goal += 1 << k;
            goal_range.join(tree[goal]);
        }

    // goal is the last point such that the w_sum of [start, goal) < the w_sum of [goal, end)
    assert(start <= goal && goal < end);
    long long left_w_sum = goal_range.w_sum - start_range.w_sum;
    long long right_w_sum = end_range.w_sum - goal_range.w_sum;
    assert(left_w_sum < right_w_sum);
    int left_aw_sum = goal_range.aw_sum - start_range.aw_sum;
    int right_aw_sum = end_range.aw_sum - goal_range.aw_sum;

    // result = sum W[i] * |A[i] - A[goal]|
    long long result = ((left_w_sum - right_w_sum) % MOD * A[goal] + right_aw_sum - left_aw_sum) % MOD;
    if (result < 0) result += MOD;
    return result;
}

int main() {
    assert(IO::exit_success);
    IO::read_int(N);
    IO::read_int(Q);
    A.resize(N);
    W.resize(N);
    LOG = 32 - __builtin_clz(N);
    assert(1 << LOG > N);
    tree.resize(N + 1);

    for (int i = 0; i < N; i++) {
        IO::read_int(A[i]);
        A[i] -= i;
    }

    for (int i = 0; i < N; i++)
        IO::read_int(W[i]);

    build_tree();

    for (int q = 0; q < Q; q++) {
        int x, y;
        IO::read_int(x);
        IO::read_int(y);

        if (x < 0) {
            x = -x - 1;
            tree_update(x, y - W[x], A[x]);
            W[x] = y;
        } else {
            IO::write_int(solve(x - 1, y), '\n');
        }
    }
}

/*

Code for problem F1 by savkinsd2089
Generated 04 Oct 2018 at 07.12 pm
The Moon is Waning Crescent (25% of Full)

█▒▒▒▒▒▒▒▒▒
10%
███▒▒▒▒▒▒▒
30%
█████▒▒▒▒▒
50%
███████▒▒▒
70%
██████████
100%

~_^
-_-
>_<

*/

#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <complex>
#include <cassert>
#include <random>
#include <cstring>
#define ll long long
#define ld long double
#define null NULL
#define all(a) a.begin(), a.end()
#define debug(a) cerr << #a << " = " << a << endl
#define forn(i, n) for (int i = 0; i < n; ++i)

#ifndef TESTING
	#define endl '\n'
#endif

using namespace std;

template<class T> int chkmax(T &a, T b) {
	if (b > a) {
		a = b;
		return 1;
	}
	return 0;
}

template<class T> int chkmin(T &a, T b) {
	if (b < a) {
		a = b;
		return 1;
	}
	return 0;
}

template<class iterator> void output(iterator begin, iterator end, ostream& out = cerr) {
	while (begin != end) {
		out << (*begin) << " ";
		begin++;
	}
	out << endl;
}

template<class T> void output(T x, ostream& out = cerr) {
	output(x.begin(), x.end(), out);
}

void fast_io() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

const ll MOD = 1e9 + 7;
/*
istream& operator >> (istream &is, ll &a) {
	long long _a;
	is >> _a;
	a = (ll)_a;
	return is;
}

ostream& operator << (ostream &os, ll a) {
	long long a1;
	a1 = (long long)a;
	os << a1;
	return os;
}
*/
struct data {
	ll val, cnt, sum;
	data(): val(0), cnt(0), sum(0) {}
	data(ll _x): val(0), cnt(1), sum(_x) {}
	data(ll _val, ll _cnt, ll _sum): val(_val), cnt(_cnt), sum(_sum) {}
};

data merge(data a, data b) {
	return data(a.val + b.val + b.sum * a.cnt, a.cnt + b.cnt, a.sum + b.sum);
}

struct st {
	vector<data> t;
	int n;

	void init(int _n) {
		n = _n;
		t.resize(4 * n);
	}

	void update(int pos, ll val, int v, int tl, int tr) {
		if (tl == tr) {
			t[v] = data(val);
		}
		else {
			int tm = (tl + tr) >> 1;
			if (pos <= tm)
				update(pos, val, v * 2, tl, tm);
			else
				update(pos, val, v * 2 + 1, tm + 1, tr);
			t[v] = merge(t[v * 2], t[v * 2 + 1]);
		}
	}

	void output(int v, int tl, int tr) {
		cerr << tl << ".." << tr << ": " << t[v].val << " " << t[v].cnt << " " << t[v].sum << endl;
		if (tl < tr) {
			int tm = (tl + tr) >> 1;
			output(v * 2, tl, tm);
			output(v * 2 + 1, tm + 1, tr);
		}
	}

	data get(int l, int r, int v, int tl, int tr) {
		if (l > r)
			return data();
		if (l == tl && r == tr)
			return t[v];
		int tm = (tl + tr) >> 1;
		data res_l = get(l, min(r, tm), v * 2, tl, tm);
		data res_r = get(max(l, tm + 1), r, v * 2 + 1, tm + 1, tr);
		return merge(res_l, res_r);
	}

	void update(int pos, ll val) {
		update(pos, val, 1, 0, n - 1);
	}

	ll get(int l, int r) {
		data x = get(l, r, 1, 0, n - 1);
		return x.val;
	}
};

struct fenwick {
	vector<ll> t;
	int n;

	void init(int _n) {
		n = _n;
		t.resize(n);
	}

	void update(int pos, ll val) {
		while (pos < n) {
			t[pos] += val;
			pos = (pos | (pos + 1));
		}
	}

	ll get(int r) {
		ll res = 0;
		while (r >= 0) {
			res += t[r];
			r = (r & (r + 1)) - 1;
		}
		return res;
	}

	ll get(int l, int r) {
		return get(r) - get(l - 1);
	}
};

const int mx = 2e5 + 228;
int n, q;
ll a[mx], w[mx];
fenwick f_w, f_aw;
st t, t_rev;

void update_index(int pos, ll new_w, ll old_w) {
	//cerr << ">>>> updating index " << pos << " " << new_w << " " << old_w << endl;
	f_w.update(pos, new_w - old_w);
	f_aw.update(pos, a[pos] * (new_w - old_w));
	t.update(pos, new_w);
	t_rev.update(n - pos - 1, new_w);
}

void init() {
	f_w.init(n);
	f_aw.init(n);
	t.init(n);
	t_rev.init(n);
	for (int i = 0; i < n; ++i) {
		update_index(i, w[i], 0);
	}
}

void update_query(int pos, ll new_w) {
	update_index(pos, new_w, w[pos]);
	w[pos] = new_w;
}

int get_max_left_pos(int l0, int r0, ll L) {
	int l = l0 - 1, r = r0;
	while (l != r) {
		int mid = (l + r) >> 1;
		if (a[mid + 1] < L + (ll)(mid + 1 - l0))
			l = mid + 1;
		else
			r = mid;
	}
	//cerr << "max_left_pos " << l0 << " " << r0 << " " << L << " is " << l << endl;
	return l;
}

int get_min_right_pos(int l0, int r0, ll L) {
	int l = l0, r = r0 + 1;
	while (l != r) {
		int mid = (l + r) >> 1;
		if (a[mid] > L + (ll)(mid - l0))
			r = mid;
		else
			l = mid + 1;
	}
	//cerr << "min_right_pos " << l0 << " " << r0 << " " << L << " is " << l << endl;
	return l;
}

ll get_l(int l0, int r0, ll R) {
	ll res = R * f_w.get(l0, r0) - f_aw.get(l0, r0) - t_rev.get(n - 1 - r0, n - 1 - l0);
	//cerr << "get_l " << l0 << " " << r0 << " " << R << " = " << res << endl;
	return res;
}

ll get_r(int l0, int r0, ll L) {
	ll res = f_aw.get(l0, r0) - f_w.get(l0, r0) * L - t.get(l0, r0);
	//cerr << "get_r " << l0 << " " << r0 << " " << L << " = " << res << endl;
	//cerr << f_aw.get(l0, r0) << endl;
	//cerr << -f_w.get(l0, r0) * L << endl;
	//cerr << -t.get(l0, r0) << endl;
	return res;
}

ll get(int l0, int r0, ll L) {
	int mid_pos = get_max_left_pos(l0, r0, L);
	ll res = get_l(l0, mid_pos, L + mid_pos - l0) + get_r(mid_pos + 1, r0, L + mid_pos + 1 - l0);
	return res;
}

const ll BBINF = 1e18;

ll get_query(int l0, int r0) {
	/*cerr << "--------------------------" << endl;
	cerr << "get_query " << l0 << " " << r0 << endl;
	cerr << "aw" << endl;
	output(a, a + n);
	output(w, w + n);*/
	ll len = (ll)(r0 - l0 + 1), L = a[l0], R = a[r0] - len + 1;
	while (R - L > 1) {
		ll MID = (L + R) >> 1;
		//cerr << "MID = " << MID << endl;
		int max_left_pos = get_max_left_pos(l0, r0, MID), min_right_pos = get_min_right_pos(l0, r0, MID);
		ll wl = f_w.get(l0, max_left_pos), wr = f_w.get(min_right_pos, r0);
		//cerr << "wl, wr = " << wl << " " << wr << endl;
		if (wl == wr) {
			L = MID;
			R = MID;
			break;
		}
		if (wl < wr) {
			L = MID;
		}
		else {
			R = MID;
		}
	}
	//cerr << "L = " << L << endl;
	//cerr << "R = " << R << endl;
	ll ans = BBINF;
	for (ll i = L; i <= R; ++i) {
		ans = min(ans, get(l0, r0, i));
	}
	return ans % MOD;
}
/*
void check_st() {
	st t;
	t.init(5);
	for (int i = 0; i < 4; ++i) {
		t.update(i, 1);
	}
	t.update(4, 2);
	t.output(1, 0, 4);
	t.update(2, 5);
	cerr << "out2" << endl;
	t.output(1, 0, 4);
	t.update(0, 10);
	cout << t.get(0, 3) << endl;
}
*/
signed main() {
	//check_st();
	fast_io();
	cin >> n >> q;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> w[i];
	}
	init();
	for (int i = 0; i < q; ++i) {
		int id;
		ll val;
		cin >> id >> val;
		if (id < 0) {
			update_query(-id - 1, val);
		}
		else {
			cout << get_query(id - 1, (int)val - 1) << endl;
		}
	}
}

#include <bits/stdc++.h>

typedef long double ld ;
#define long long long int
using namespace std;
#define mp make_pair
#define pb push_back
#define INF 1e18
#define INF2 1e9
// #define pi 3.141592653589
#define x first
#define y second
// #define endl "\n"

long cons;
long check(long a)
{
    if(a>=cons)a%=cons;
    return a;
}
long check2(long a)
{
	a%=cons;
	if(a<0)
		a+=cons;
	return a;
}

long fast_check(long a)
{
	if(a>=cons)
		a-=cons;
	return a;
}

long GCD(long a,long b)
{
	while(a && b)
	{
		a=a%b;
		if(a!=0)
			b=b%a;
	}
	return a+b;
}

long exp(long a,long n)
{
	long ans=1;
	a=check(a);
	while(n)
	{
		if(n&1)
			ans=check(ans*a);
		a=check(a*a);
		n=(n>>1);
	}
	return ans;
}

void print_pair(pair<int,int> p)
{
	cout<<p.x<<" "<<p.y<<endl;
}

long nc2(long a)
{
	return (a*(a-1))/2;
}

const int N=2e5+10;
const int M=4*N;

long tree[M],lr[M];
long pos[N],w[N];
int n,q;
// long cumu_pos[N];

void buildtree(int s,int e,int n)
{
	if(s==e)
	{
		tree[n]=w[s];
		return;
	}
	int mid=(s+e)>>1;
	buildtree(s,mid,n+n);
	buildtree(mid+1,e,n+n+1);
	tree[n]=tree[n+n]+tree[n+n+1];
}

void buildlr(int s,int e,int n)
{
	if(s==e)
	{
		lr[n]=(pos[s]-s+1)*w[s];
		lr[n]=check(lr[n]);
		return;
	}
	int mid=(s+e)>>1;
	buildlr(s,mid,n+n);
	buildlr(mid+1,e,n+n+1);
	lr[n]=check(lr[n+n]+lr[n+n+1]);
}
long lef,rig,cumu_sum;
int ind(int s,int e,int n)
{
	if(s==e)
		return s;
	long sum2=tree[n+n]+cumu_sum;
	int mid=(s+e)>>1;
	if(sum2-lef>=rig-sum2)
		return ind(s,mid,n+n);
	else
	{
		cumu_sum+=tree[n+n];
		return ind(mid+1,e,n+n+1);
	}
}

void update(int s,int e,int n,int ind)
{
	if(s==e)
	{
		tree[n]=w[s];
		lr[n]=(pos[s]-s+1)*w[s];
		lr[n]=check(lr[n]);
		return;
	}
	if(e<ind || s>ind)
		return;
	int mid=(s+e)>>1;
	update(s,mid,n+n,ind);
	update(mid+1,e,n+n+1,ind);
	lr[n]=check(lr[n+n]+lr[n+n+1]);
	tree[n]=tree[n+n]+tree[n+n+1];
}

long sum(int s,int e,int n,int qs,int qe)
{
	if(s>=qs && e<=qe)
		return tree[n];
	if(s>qe || qs>e)
		return 0;
	int mid=(s+e)>>1;
	return sum(s,mid,n+n,qs,qe)+sum(mid+1,e,n+n+1,qs,qe);
}
long other_sum(int s,int e,int n,int qs,int qe)
{
	if(qe<qs)
		return 0;
	if(s>=qs && e<=qe)
		return lr[n];
	if(s>qe || qs>e)
		return 0;
	int mid=(s+e)>>1;
	return check(other_sum(s,mid,n+n,qs,qe)+other_sum(mid+1,e,n+n+1,qs,qe));
}

long query(long x,long y)
{
	lef=sum(1,n,1,1,x-1);
	rig=sum(1,n,1,1,y);
	cumu_sum=0;
	int inde=ind(1,n,1);

	lef=cumu_sum-lef;
	rig=rig-cumu_sum-w[inde];

	long ss=check2(other_sum(1,n,1,inde+1,y)-(pos[inde]-(inde-1))*rig);
	long ss2=check2((pos[n]-n)*lef-other_sum(1,n,1,x,inde-1));
	ss2=check2(ss2-(pos[n]-pos[inde]-(n-inde+1))*lef);

	return check(ss+ss2);
}

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	cons=1e9+7;

	cin>>n>>q;

	for(int i=1;i<=n;i++)
	{
		cin>>pos[i];
		// cumu_pos[i]=cumu_pos[i-1]+pos[i];
	}
	for(int i=1;i<=n;i++)
		cin>>w[i];

	buildtree(1,n,1);
	buildlr(1,n,1);

	while(q--)
	{
		int x,y;
		cin>>x>>y;
		if(x<0)
		{
			x=-x;
			w[x]=y;
			update(1,n,1,x);
		}
		else
		{
			cout<<query(x,y)<<"\n";
		}
	}

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

template<typename T>
struct SegmentTree{
    using F=function<T(T,T)>;

    int n;
    vector<T> dat;
    F f;
    T ti;

    SegmentTree(int n_ ,F f ,T ti) :f(f),ti(ti){
        n=1;
        while(n<n_) n*=2;
        dat.assign(2*n-1,ti);
    }

    SegmentTree(int n_ ,vector<T> &v ,F f,T ti) :f(f),ti(ti){
        n=1;
        while(n<n_) n*=2;
        dat.assign(2*n-1,ti);

        for(int i=n-1;i-(n-1)<v.size();i++) dat[i]=v[i-(n-1)];

        for(int i=n-2;i>=0;i--) dat[i]=f(dat[i*2+1],dat[i*2+2]);
    }

    void update(int k,T x){
        k+=n-1;
        dat[k]=x;

        while(k){
            k=(k-1)/2;
            dat[k]=f(dat[k*2+1],dat[k*2+2]);
        }
    }

    void set(int k,T x){
        dat[n-1+k]=x;
    }

    void built(){
        for(int i=n-2;i>=0;i--) dat[i]=f(dat[i*2+1],dat[i*2+2]);
    }

    T query_(int a,int b,int k,int l,int r){
        if(r<=a||b<=l) return ti;
        if(a<=l&&r<=b) return dat[k];
        else{
            T vl=query_(a,b,2*k+1,l,(l+r)/2);
            T vr=query_(a,b,2*k+2,(l+r)/2,r);
            return f(vl,vr);
        }
    }

    T query(int a,int b){
        return query_(a,b,0,0,n);
    }

    T get(int k){
        return dat[k+n-1];
    }

    template<typename C>
    int findright(int st,C &check,T &acc,int k,int l,int r){
        if(l+1==r){
            acc=f(acc,dat[k]);
            return check(acc)?k-(n-1):-1;
        }
        int m=(l+r)/2;
        if(m<=st) return findright(st,check,acc,2*k+2,m,r);
        if(st<=l&&!check(f(acc,dat[k]))){
            acc=f(acc,dat[k]);
            return -1;
        }
        int vl=findright(st,check,acc,2*k+1,l,m);
        if(~vl) return vl;
        return findright(st,check,acc,2*k+2,m,r);
    }

    template<typename C>
    int findright(int st,C &check){
        T acc=ti;
        return findright(st,check,acc,0,0,n);
    }//条件を満たす最小のidxを返す

    template<typename C>
    int findleft(int st,C &check,T &acc,int k,int l,int r){
        if(l+1==r){
            acc=f(acc,dat[k]);
            return check(acc)?k-(n-1):INF;
        }
        int m=(l+r)/2;
        if(m>=st) return findleft(st,check,acc,2*k+1,l,m);
        if(st>=r&&!check(f(acc,dat[k]))){
            acc=f(acc,dat[k]);
            return INF;
        }
        int vr=findleft(st,check,acc,2*k+2,m,r);
        if(vr!=INF) return vr;
        return findleft(st,check,acc,2*k+1,l,m);
    }

    template<typename C>
    int findleft(int st,C &check){
        T acc=ti;
        return findleft(st,check,acc,0,0,n);
    }//条件を満たす最大のidxを返す

};

int main(){

    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N,Q;cin>>N>>Q;
    vector<ll> pos(N);
    vector<ll> w(N);

    for(int i=0;i<N;i++){
        cin>>pos[i];
        pos[i]-=i;
    }

    for(int i=0;i<N;i++){
        cin>>w[i];
    }

    SegmentTree<pair<ll,ll>> seg(N,
                                 [](pair<ll,ll> a,pair<ll,ll> b){return mp((a.fi+b.fi)%mod,(a.se+b.se)%mod);},
                                 mp(0,0));

    SegmentTree<ll> wsum(N,
                         w,
                         [](ll a,ll b){return a+b;},
                         0);

    for(int i=0;i<N;i++){
        seg.update(i,mp(w[i]*pos[i]%mod,(w[i]*(mod-pos[i]))%mod));
    }

    while(Q--){
        ll l,r;cin>>l>>r;
        if(l<0){
            l*=-1;
            l--;
            seg.update(l,mp(r*pos[l]%mod,(r*(mod-pos[l]))%mod));
            wsum.update(l,r);
            w[l]=r;
        }else{
            l--;
            r--;

            ll left=l,right=r+1;

            ll sum=wsum.query(left,right);

            while(right-left>1){
                ll mid=(left+right)/2;
                ll a=wsum.query(l,mid),b=wsum.query(l,mid+1);

                if(a*2<=sum&&b*2>=sum){
                    left=mid;
                    break;
                }else if(a*2>sum) right=mid;
                else left=mid;
            }

            int d=left;

            ll lsum=0,rsum=0;

            lsum+=seg.query(l,d).se-(wsum.query(l,d)*(mod-pos[d]))%mod+mod;
            rsum+=seg.query(d,r+1).fi-wsum.query(d,r+1)*pos[d]%mod+mod;

            /*ll ans=0;

            for(int i=l;i<=r;i++){
                ans+=abs(pos[d]-pos[i])*w[i];
                ans%=mod;
            }

            cout<<ans<<"\n";*/

            cout<<(lsum+rsum)%mod<<"\n";

        }
    }
}

#include <bits/stdc++.h>

using namespace std;

const long long mod = 1e9 + 7;

int n, q, i, j, l, mid, r;
long long a[200010], w[200010];

////////////////////////// PARTEA I - simple partial sums on weight
long long aibpart[200010];
long long part(int poz)
{
    long long ret = 0LL;
    for(;poz;poz-=poz&-poz)
        ret = ret + aibpart[poz] ;
    return ret;
}
void updpart(int poz, int val)
{
    for(;poz<=n;poz+=poz&-poz)
        aibpart[poz] += val;
    return ;
}
//////////////////////////

////////////////////////// PARTEA II - simple partial sums on products between weight and position
long long aibprodus[200010];
int produs(int poz)
{
    int ret = 0;
    for(;poz;poz-=poz&-poz)
    {
        ret = ret + aibprodus[poz] ;
        ret = ( ret > mod ) ? ret - mod : ret ;
    }
    return ret;
}
void updprodus(int poz, int val)
{
    for(;poz<=n;poz+=poz&-poz)
        aibprodus[poz] = ( aibprodus[poz] + val >= mod ) ? aibprodus[poz] + val - mod : aibprodus[poz] + val ;
    return ;
}
//////////////////////////

////////////////////////// PARTEA III - first grade function
long long aibA[200010], aibB[200010], aibretard[200010];
int getA(int poz)
{
    int ret = 0;
    for(;poz;poz-=poz&-poz)
    {
        ret = ret + aibA[poz] ;
        ret = ( ret > mod ) ? ret - mod : ret ;
    }
    return ret;
}
void updA(int poz,long long val)
{
    for(;poz<=n;poz+=poz&-poz)
        aibA[poz] = ( aibA[poz] + val >= mod ) ? aibA[poz] + val - mod : aibA[poz] + val ;
    return ;
}

int getB(int poz)
{
    int ret = 0;
    for(;poz;poz-=poz&-poz)
    {
        ret = ret + aibB[poz] ;
        ret = ( ret > mod ) ? ret - mod : ret ;
    }
    return ret;
}
void updB(int poz,long long val)
{
    for(;poz<=n;poz+=poz&-poz)
        aibB[poz] = ( aibB[poz] + val >= mod ) ? aibB[poz] + val - mod : aibB[poz] + val ;
    return ;
}

int getthird(int poz)
{
    long long ret = ( getA(poz) * poz + getB(poz) ) % mod ;
    return ( ret < 0 ) ? ret + mod : ret ;
}

void updretard(int poz,int val)
{
    for(;poz<=n;poz+=poz&-poz)
        aibretard[poz] = ( aibretard[poz] + val >= mod ) ? aibretard[poz] + val - mod : aibretard[poz] + val;
    return ;
}
int retard(int poz)
{
    int ret = 0;
    for(;poz;poz-=poz&-poz)
        ret = ( ret + aibretard[poz] >= mod ) ? ret + aibretard[poz] - mod : ret + aibretard[poz];
    return ret;
}
//////////////////////////

int main()
{
    cin>>n>>q;
    for(i=1;i<=n;i++) cin >> a[i];
    for(i=1;i<=n;i++)
    {
        cin >> w[i];
        updpart   ( i , w[i] );
        updprodus ( i , ( w[i] * a[i] ) % mod );
        updA      ( i , w[i] );
        long long aux = ( w[i] * ( 1 - i ) ) % mod ;
        aux = ( aux < 0 ) ? aux + mod : aux ;
        updB      ( i , aux );
        updretard ( i , ( w[i] * i ) % mod );
    }

    for(;q;q--)
    {
        cin >> l >> r;

        if( l < 0 )
        {
            l = -l;
            long long dif = ( r - w[l] < 0 ) ? r - w[l] + mod : r - w[l] ;
            updpart   ( l , dif );
            updprodus ( l , ( dif * a[l] ) % mod );
            updA      ( l , dif );
            long long aux = ( dif * ( 1 - l ) ) % mod ;
            aux = ( aux < 0 ) ? aux + mod : aux ;
            updB      ( l , aux );
            updretard ( l , ( dif * l ) % mod );
            w[l] = r;
            continue ;
        }

        int laux=l, raux=r, L=part(l-1);int total=part(r)-L;
        while( laux < raux )
        {
            mid = ( laux + raux ) / 2;
            if( ( part(mid) - L ) * 2 < total )
                laux = mid + 1;
            else
                raux = mid;
        }
        mid = laux;
        long long ans = 0;
//        for(j=l;j<mid;j++)    ans = ( ans + ( a[mid] - a[j] - ( mid - j ) ) * w[j] ) % mod;
//        for(j=mid+1;j<=r;j++) ans = ( ans + ( a[j] - a[mid] - ( j - mid ) ) * w[j] ) % mod;
//        cout << "ACTUAL ANSWER: " << ans << '\n';
//
//        cout << "MIDDLE : " << mid << '\n';
//        cout << "WEIGHTS: ";for(j=1;j<=n;j++) cout << part(j)-part(j-1) << ' ';cout<<'\n';
//        cout << "POSES  : ";for(j=1;j<=n;j++) cout << a[j] << ' ';cout<<'\n';
//        cout << "PRODUSE: ";for(j=1;j<=n;j++) cout << produs(j)-produs(j-1) << ' ';cout<<'\n';
//        cout << "A & B  : ";for(j=1;j<=n;j++) cout << getthird(j) << ' ';cout<<'\n';

        //ans = 0LL;
////////////////////////// PARTEA I
        ans = ( ans + a[mid] * ( ( part(mid-1) - part(l-1) ) % mod ) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans ;

        ans = ( ans - a[mid] * ( ( part(r)   -   part(mid) ) % mod ) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans ;
        //cout << " PARTEA I: " << ans << '\n';

        //ans = 0LL;
////////////////////////// PARTEA II
        ans = ( ans - ( produs(mid-1) - produs (l-1) ) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans ;

        ans = ( ans + ( produs(r) - produs(mid) ) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans ;
        //cout << " PARTEA II: " << ans << '\n';

        //ans = 0LL;
////////////////////////// PARTEA III
        ans = ( ans - getthird(mid-1) );
        ans = ( ans < 0 ) ? ans + mod : ans;
        ans = ( ans  +  getthird(l-1) );
        ans = ( ans < 0 ) ? ans + mod : ans;
        ans = ( ans  + ( ( mid - l ) * part(l-1) ) % mod ) % mod;

        //cout << " PARTEA III a: " << ans << '\n';

        //ans = 0LL;

        ans = ( ans - retard(r) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans;
        ans = ( ans + retard (mid) ) % mod;
        if(mid!=r)ans = ( ans + mid * ( part(r) - part(mid) ) ) % mod;
        ans = ( ans < 0 ) ? ans + mod : ans;

        //cout << " PARTEA III b: " << ans << '\n';
        cout << ans << '\n';
    }
    return 0;
}

#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define f first
#define s second

using namespace std;

const ll mod=1LL*1000*1000*1000+7;
ll ftree_S[200005];
ll ftree_wa[200005];
ll a[200005],w[200005];

void upd(ll *ftree,ll x,ll d)
{
          for(int i=x;i<200005;i|=i+1)
                    ftree[i]=(ftree[i]+d)%mod;
}

ll s(ll *ftree,ll x)
{
          ll res=0;
          for(int i=x;i>=0;i=(i&(i+1))-1)
                    res=(res+ftree[i])%mod;
          return res;
}

ll s(ll *ftree,ll l,ll r)
{
          return (s(ftree,r)-s(ftree,l-1)+mod)%mod;
}

int n,q;

int main()
{
          //freopen("INPUT.txt","r",stdin);
          ios_base::sync_with_stdio(0);
          cin>>n>>q;
          for(int i=1;i<=n;i++)
          {
                    cin>>a[i];
                    a[i]-=i;
          }
          for(int i=1;i<=n;i++)
          {
                    cin>>w[i];
                    upd(ftree_S,i,w[i]);
                    upd(ftree_wa,i,w[i]*a[i]%mod);
          }

          for(int i=0;i<q;i++)
          {
                    ll x,y;
                    cin>>x>>y;
                    if(x<0)
                    {
                              upd(ftree_S,-x,-w[-x]);
                              upd(ftree_wa,-x,-w[-x]*a[-x]);
                              w[-x]=y;
                              upd(ftree_S,-x,w[-x]);
                              upd(ftree_wa,-x,w[-x]*a[-x]%mod);
                    }
                    else
                    {
                              ll l=x,r=y;
                              while(r-l>1)
                              {
                                        ll mid=(r+l)/2;
                                        if(2*s(ftree_S,x,mid)>s(ftree_S,x,y))
                                                  r=mid;
                                        else
                                                  l=mid;
                              }
                              ll res=0;
                              res=(s(ftree_S,x,r-1)*a[r]%mod-s(ftree_wa,x,r-1)+mod)%mod;
                              res=(res+s(ftree_wa,r+1,y)+mod-s(ftree_S,r+1,y)*a[r]%mod)%mod;
                              cout<<res<<endl;
                    }
          }
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,q;
const int maxn=2e5+5;
const ll mod=1e9+7;
ll a[maxn],w[maxn];
ll lowbit(ll x) {return x&-x;}
void add(ll t[],ll x,ll d)
{
    for(;x<maxn;x+=lowbit(x))
    {
        t[x]+=d;
    }
}

ll ask(ll t[],ll x,int typ)
{
    ll ret=0;
    for(;x;x-=lowbit(x))
    {
        ret+=t[x];
        if(typ) ret%=mod;
    }
    return ret;
}
ll sum[maxn];
ll t[maxn];
int main()
{
    scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++) {scanf("%lld",a+i);a[i]-=i;}
    for(int i=1;i<=n;i++) {scanf("%lld",w+i);add(t,i,w[i]);add(sum,i,w[i]*a[i]);}

    while(q--)
    {
        ll l,r;
        scanf("%lld%lld",&l,&r);
        if(l<0)
        {
            add(t,-l,r-w[-l]);
            add(sum,-l,a[-l]*(r-w[-l]));
            w[-l]=r;
        }
        else
        {
            ll L=l,R=r;
            ll all=ask(t,r,0)-ask(t,l-1,0);
            while(L<R)
            {
                ll mid=(L+R)/2;
                if(ask(t,mid,0)-ask(t,l-1,0)>=all/2) R=mid;
                else L=mid+1;
            }
            ll k=L;
            ll ans=a[k]*(ask(t,k-1,1)-ask(t,l-1,1)+mod)%mod;
            ans-=(ask(sum,k-1,1)-ask(sum,l-1,1)+mod)%mod;
            ans=(ans+mod)%mod;
            (ans+=(ask(sum,r,1)-ask(sum,k,1)+mod))%=mod;
            ans-=a[k]*(ask(t,r,1)-ask(t,k,1)+mod)%mod;
            ans=(ans+mod)%mod;
            printf("%lld\n",ans);
        }
    }
    return 0;
}

#include <iostream>
#include <ios>
#include <cstdint>
#include <vector>

using ul = std::uint32_t;
using ull = std::uint64_t;
using li = std::int32_t;
using ll = std::int64_t;
using vull = std::vector<ull>;
using vul = std::vector<ul>;

const ul sz = 1 << 18;
const ul base = 1e9 + 7;

class scaler {
public:
    ul v = 0;
    scaler()=default;
    scaler(ul x): v(x) { }
};

scaler operator+(scaler a, scaler b)
{
    return scaler(a.v + b.v < base ? a.v + b.v : a.v + b.v - base);
}

scaler operator-(scaler a, scaler b)
{
    return scaler(a.v < b.v ? a.v + base - b.v : a.v - b.v);
}

scaler operator*(scaler a, scaler b)
{
    return scaler(ull(a.v) * b.v % base);
}

template<typename T>
void change(ul pos, const T& v, std::vector<T>& tree)
{
    for (tree[pos |= sz] = v, pos >>= 1; pos; pos >>= 1) {
        tree[pos] = tree[pos << 1] + tree[pos << 1 | 1];
    }
}

template<typename T>
T query(ul l, ul r, const std::vector<T>& tree)
{
    T ret;
    for (l = l - 1 | sz, r = r + 1 | sz; l ^ r ^ 1; l >>= 1, r >>= 1) {
        if (~l & 1) {
            ret = ret + tree[l ^ 1];
        }
        if (r & 1) {
            ret = ret + tree[r ^ 1];
        }
    }
    return ret;
}

std::vector<scaler> atree(sz << 1, ul(0));
vull tree(sz << 1, ul(0));
ul n, q;
vul a(2e5 + 1);

scaler compute(ul l, ul r, ul cut)
{
    return scaler(query(l, cut - 1, tree)) * scaler(a[cut]) - query(l, cut - 1, atree)
     + query(cut + 1, r, atree) - scaler(query(cut + 1, r, tree)) * scaler(a[cut]);
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cin >> n >> q;
    for (ul i = 1; i <= n; ++i) {
        std::cin >> a[i];
        a[i] -= i;
    }
    for (ul i = 1; i <= n; ++i) {
        ul w;
        std::cin >> w;
        change(i, ull(w), tree);
        change(i, scaler(a[i]) * scaler(w), atree);
    }
    for (ul i = 0; i != q; ++i) {
        li x, y;
        std::cin >> x >> y;
        if (x < 0) {
            ul id = -x;
            ul w = y;
            change(id, ull(w), tree);
            change(id, scaler(a[id]) * scaler(w), atree);
        } else {
            ul l = x, r = y;
            ull temp = query(l, r, tree);
            ul lans = l - 1, rans = r;
            while (lans + 1 != rans) {
                ul mid = lans + rans >> 1;
                if ((query(l, mid, tree) << 1) < temp) {
                    lans = mid;
                } else {
                    rans = mid;
                }
            }
            std::cout << compute(l, r, std::max(rans, l)).v << std::endl;
        }
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define y1 y114514
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define all(a) a.begin(), a.end()
typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef long long ll;
const int M = 1000000007;
#define ls t << 1
#define rs (t << 1) | 1

const int maxn = 400005;
int n, q;
int a[maxn], w[maxn];
ll sum[maxn];
int s2[maxn];
ll s;
int md;
int x, y;

void build(int t, int l, int r){
	if(l == r){
		sum[t] = w[l];
		s2[t] = (ll)a[l] * w[l] % M;
		return;
	}
	int mid = (l + r) >> 1;
	build(t << 1, l, mid);
	build((t << 1) | 1, mid + 1, r);
	sum[t] = sum[ls] + sum[rs];
	s2[t] = (s2[ls] + s2[rs]) % M;
}

void modify(int t, int l, int r, int x, int v){
	if(l == r){
		sum[t] = v;
		s2[t] = (ll)a[l] * v % M;
		return;
	}
	int mid = (l + r) >> 1;
	if(x <= mid) modify(ls, l, mid, x, v);
	else modify(rs, mid + 1, r, x, v);
	sum[t] = sum[ls] + sum[rs];
	s2[t] = (s2[ls] + s2[rs]) % M;
}

ll getsum(int t, int l, int r, int x, int y){
	if(l >= x && r <= y) return sum[t];
	int mid = (l + r) >> 1;
	return (x <= mid ? getsum(ls, l, mid, x, y) : 0) +
		(y > mid ? getsum(rs, mid + 1, r, x, y) : 0);
}

void find_mid(int t, int l, int r, int x, int y){
	int mid = (l + r) >> 1;

	if(l >= x && r <= y){
		if(sum[t] < s) s -= sum[t];
		else{
			if(l == r) { md = l; return; }
			if(sum[ls] < s){
				s -= sum[ls];
				find_mid(rs, mid + 1, r, x, y);
			}else{
				find_mid(ls, l, mid, x, y);
			}
		}
		return;
	}

	if(x <= mid) find_mid(ls, l, mid, x, y);
	if(y > mid && s) find_mid(rs, mid + 1, r, x, y);
}

pii cal_cnt(int t, int l, int r, int x, int y){
	if(l >= x && r <= y) return mkp(sum[t] % M, s2[t]);
	int mid = (l + r) >> 1;
	auto tmp1 = x <= mid ? cal_cnt(ls, l, mid, x, y) : mkp(0, 0);
	auto tmp2 = y > mid ? cal_cnt(rs, mid + 1, r, x, y) : mkp(0, 0);
	return mkp((tmp1.fi + tmp2.fi) % M, (tmp1.se + tmp2.se) % M);
}

int main(){
	scanf("%d%d", &n, &q);
	for(int i = 1; i <= n; ++i) scanf("%d", a + i), a[i] -= i;
	for(int i = 1; i <= n; ++i) scanf("%d", w + i);

	build(1, 1, n);

	while(q--){
		scanf("%d%d", &x, &y);
		if(x < 0){
			modify(1, 1, n, -x, y);
		}else{
			s = getsum(1, 1, n, x, y);
			s = (s + 1) / 2;
			find_mid(1, 1, n, x, y);

			auto tmp1 = cal_cnt(1, 1, n, x, md);
			auto tmp2 = md < y ? cal_cnt(1, 1, n, md + 1, y) : mkp(0, 0);

			int res = (tmp2.se - tmp1.se + (tmp1.fi - tmp2.fi) * a[md]) % M;
			if(res < 0) res += M;

			printf("%d\n", res);
		}
	}

#ifndef ONLINE_JUDGE
	system("pause");
#endif
	return 0;
}

#include<bits/stdc++.h>
#define lowbit(x) x&-x
using namespace std;

const int mod = 1e9 + 7;
const int maxn = 2e5 + 10;

typedef long long ll;

int n,q;
ll a[maxn],w[maxn];

void update(ll *b,int x,ll val){
    while(x <= n){
        b[x] += val;
        x += lowbit(x);
    }
}
ll query(ll *b,int x){
    ll res = 0;
    while(x){
        res += b[x];
        x -= lowbit(x);
    }
    return res;
}
ll sum(ll *b,int l,int r){
    return query(b,r) - query(b,l-1);
}
ll summod(ll *b,int l,int r){
    return (query(b,r) - query(b,l-1))*1ll + mod % mod;
}
ll mul(ll a,ll b){
    return a * b % mod;
}

ll bw[maxn],bwa[maxn];
int main(){
    //cout << INT_MAX << endl;
    //freopen("in.txt","r",stdin);
    scanf("%d%d",&n,&q);
    for(int i = 1;i <= n;i++) scanf("%lld",&a[i]);
    for(int i = 1;i <= n;i++) scanf("%lld",&w[i]);
    for(int i = 1;i <= n;i++) {
        a[i] -= i;
        update(bw,i,w[i]);
        update(bwa,i,mul(a[i],w[i]));
    }
    while(q--){
        int x,y;
        scanf("%d%d",&x,&y);
        if(x < 0){
            x = -x;
            update(bw,x,-w[x]);
            update(bwa,x,-mul(a[x],w[x]));
            w[x] = y;
            update(bw,x,w[x]);
            update(bwa,x,mul(a[x],w[x]));
        }
        else{
            int l = x,r = y;
            ll tot = sum(bw,l,r);
            while(r > l){
                int mid = (l + r) >> 1;
                if(sum(bw,x,mid) * 2 > tot) r = mid;
                else l = mid + 1;
            }
            //printf(">> %d\n",l);
            ll ans = 0;
            ans += mul(a[l],sum(bw,x,l)) - summod(bwa,x,l);
            ans += summod(bwa,l,y) - mul(a[l],sum(bw,l,y));
            printf("%lld\n",(ans % mod + mod) % mod);
        }
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ull = unsigned ll;

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x first
#define y second

const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};
const char dir[] = {'R', 'L', 'D', 'U'};

int add(int a, int b){ //(a + b) % 1e9 + 7
    a += b;
    if(a >= MOD){
        a -= MOD;
    }
    return a;
}

int sub(int a, int b){
    a -= b;
    if(a < 0) a += MOD;
    return a;
}

int mult(int a, int b){
    return ((ll) a * b) % MOD;
}

void setIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
//    freopen((s+".in").c_str(),"r",stdin);
//    freopen((s+".text").c_str(),"w",stdout);
}

const int mxN = 200'000;

struct bit{
    ll tree[mxN + 5];
    void update(int index, ll val) {
        index++;
        while(index < mxN + 5) {
            tree[index] += val;
            index += index & -index;
        }
    }
    ll query(int index) {
        ll ret = 0;
        index++;
        while(index > 0) {
            ret += tree[index];
            index -= index & -index;
        }
        return ret;
    }
    ll rquery(int a, int b) {
        return query(b)-query(a-1);
    }
};
struct bit2{
    int tree[mxN + 5];
    void update(int index, int val) {
        index++;
        while(index < mxN + 5) {
            tree[index] = add(tree[index], val);
            index += index & -index;
        }
    }
    int query(int index) {
        int ret = 0;
        index++;
        while(index > 0) {
            ret = add(ret, tree[index]);
            index -= index & -index;
        }
        return ret;
    }
    int rquery(int a, int b) {
        return sub(query(b), query(a-1));
    }
};
int n, q;
int a[mxN], w[mxN];

int main(){
    setIO();
    //CHECK FOR LONG LONG!!!
    //LONG LONG OVERFLOW??
    cin >> n >> q;
    bit s;
    bit2 wa;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        a[i] -= i;
    }
    for(int i = 0; i < n; ++i){
        cin >> w[i];
        s.update(i, w[i]);
        wa.update(i, mult(a[i], w[i]));
    }
    while(q--){
        int x, y; cin >> x >> y;
        if(x < 0){
            x = -x; --x;
            s.update(x, -w[x]);
            wa.update(x, -mult(w[x], a[x]));
            w[x] = y;
            s.update(x, w[x]);
            wa.update(x, mult(w[x], a[x]));
        }
        else{
            --x; --y;
            if(x == y){
                cout << "0\n";
                continue;
            }
            ll tot = s.rquery(x, y);
            int l = x, r = y;
            while(l < r){
                int m = (l + r + 1) / 2;
                if(2 * s.rquery(x, m) <= tot){
                    l = m;
                }
                else{
                    r = m - 1;
                }
            }
            ++l;
            int left = sub(mult(s.rquery(x, l - 1), a[l]), wa.rquery(x, l - 1));
            int right = sub(wa.rquery(l, y), mult(s.rquery(l, y), a[l]));
            cout << add(left, right) << "\n";
        }
    }
    //CHECK FOR LONG LONG!!!
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <stdlib.h>
#include <stack>
#include <numeric>
#include <bitset>
#include <cctype>
#include <list>
#include <assert.h>
#include <random>
#include <unordered_map>
#include <ctime>
typedef  long long ll;
using namespace std;
#define INF 2147483647
#define infL (1LL<<60)
#define inf (1<<30)
#define inf9 (1000000000)
#define MOD 1000000007
#define EPS 1e-9
#define Gr 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define lch (rt<<1)
#define rch (rt<<1|1)
#define readmp(n) for(int i=0,u,v;i<n;i++) {scanf("%d%d",&u,&v); mp[u].push_back(v); mp[v].push_back(u);}
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef ll ValType;
template<typename  T> void maxtt(T& t1, T t2) {
    t1=max(t1,t2);
}
template<typename  T> void mintt(T& t1, T t2) {
    t1=min(t1,t2);
}
#define MAX 200105

bool debug = 0;
int n,m,k;
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
string direc="RDLU";
ll ln, lk, lm;
void etp(bool f = 0) {
    puts(f ?"YES" : "NO");
    exit(0);
}
void addmod(int &x, int y, int mod = MOD) {
    assert(y>=0);
    x+=y; if (x>=mod) x-=mod;
    assert(x>=0 && x<mod);
}
void et(int x=-1) {
    printf("%d\n", x); exit(0);
}
ll fastPow(ll x, ll y, int mod=MOD) {
    ll ans = 1;
    while(y>0) {
        if(y&1) ans = (x * ans)%mod;
        x = x*x%mod;
        y>>=1;
    }
    return ans;
}
ll gcd1(ll x, ll y) { return y?gcd1(y,x%y):x;}

struct fw1{
    ll b[MAX];
    void update(int x, ll val) {
        for(int i=x;i<=n;i += i&-i) {
            b[i]+=val;
        }
    }
    ll query(int x) {
        ll ret = 0;
        for ( ; x > 0; ret+=b[x], x -= x&-x);
        return ret;
    }
    ll qy(int l, int r) {
        if(r<l) return 0;
        return query(r)-query(l-1);
    }
}pw;
struct fw{
    int b[MAX];
    void update(int x, int val) {
        for(int i=x;i<=n;i += i&-i) {
            addmod(b[i], val);
        }
    }
    int query(int x) {
        int ret = 0;
        for ( ; x > 0; addmod(ret ,b[x]), x -= x&-x);
        return ret;
    }
    int qy(int l, int r) {
        if(r<l) return 0;
        return (query(r)-query(l-1)+MOD)%MOD;
    }
}pwa;
int a[MAX],w[MAX], aw[MAX];
void upt(int id, int nw) {
    pw.update(id, (nw+MOD-w[id])%MOD);
    w[id]=nw;
    int naw = (ll)a[id]*nw%MOD;
    pwa.update(id, (naw+MOD-aw[id])%MOD);
    aw[id]=naw;
}
int cal(int l, int r) {
    if(l==r) return 0;
    ll S=pw.qy(l, r);
    int L=l,R=r;
    while(L+1<R){
        int mid=(L+R)/2;
        ll z=pw.qy(l, mid);
        if (z+z<S) L=mid+1;
        else R=mid;
    }
    ll z=pw.qy(l, L);
    int pos;
    if (z+z<S) pos=R; else pos=L;

    int ans=pw.qy(l,pos-1) % MOD * a[pos] % MOD;
    addmod(ans, MOD-pwa.qy(l, pos-1));
    addmod(ans, pwa.qy(pos+1, r));
    addmod(ans, MOD-pw.qy(pos+1, r)%MOD*a[pos]%MOD);
    return ans;
}
void fmain(int ID) {
    scanf("%d%d",&n,&m);
    REQ(i,n) scanf("%d", a+i);
    REQ(i,n) scanf("%d", w+i);
    REQ(i,n) pw.update(i, w[i]);
    REQ(i,n) {
        addmod(a[i], MOD-i);
        aw[i]=(ll)a[i]*w[i]%MOD;
        pwa.update(i, aw[i]);
    }
    REQ(i,m) {
        int x,y; scanf("%d%d",&x,&y);
        if(x<0) {
            upt(-x, y);
        } else {
            printf("%d\n",cal(x,y));
        }
    }
}
int main() {
    int t=1;
//    scanf("%d", &t);
    REQ(i,t) {
        fmain(i);
    }
    return 0;
}

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int N = 300010, LGN = 20, X = 1 << LGN, P = 1000000007;

int n, q;
int a[N], w[N];
int fw[N];
ll wfw[X];

int lowBit(int k) { return k & -k; }
ll lq(int k);
void lch(int k, int x);
int bound(ll v);
int qr(int k);
void ch(int k, int x);

int main() {
#ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
	int nol_cl = clock();
#endif

	scanf("%d%d", &n, &q);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		a[i] -= i;
	}
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &w[i]);
		ch(i, w[i] * (ll)a[i] % P);
		lch(i, w[i]);
	}
	while (q--) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x < 0) {
			x = -x;
			int delt = y - w[x];
			lch(x, delt);
			if ((delt %= P) < 0)
				delt += P;
			ch(x, delt * (ll)a[x] % P);
		} else {
			int pos = bound((lq(y) + lq(x - 1)) / 2);
			int ans = ((qr(y) - qr(pos)) % P - (lq(y) - lq(pos)) % P * a[pos] % P) % P;
			if (ans < 0)
				ans += P;
			ans = (ans + (lq(pos - 1) - lq(x - 1)) % P * a[pos] % P - (qr(pos - 1) - qr(x - 1)) % P) % P;
			if (ans < 0)
				ans += P;
			printf("%d\n", ans);
		}
	}

#ifndef ONLINE_JUDGE
	LOG("Time: %dms\n", int((clock() - nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
	return 0;
}

int qr(int k) {
	int ret = 0;
	for (; k; k -= lowBit(k))
		if ((ret += fw[k]) >= P)
			ret -= P;
	return ret;
}

void ch(int k, int x) {
	for (; k <= n; k += lowBit(k))
		if ((fw[k] += x) >= P)
			fw[k] -= P;
}

ll lq(int k) {
	ll ret = 0;
	for (; k; k -= lowBit(k))
		ret += wfw[k];
	return ret;
}

void lch(int k, int x) {
	for (; k < X; k += lowBit(k))
		wfw[k] += x;
}

int bound(ll x) {
	int ret = 0;
	for (int k = LGN - 1; k >= 0; --k)
		if (x > wfw[ret | (1 << k)])
			x -= wfw[ret |= 1 << k];
	return ret + 1;
}

#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

const int MAXN = 200010;

// Modular operations
const int MOD = 1E9 + 7;

int Add(int a, int b, int m = MOD){
  a += b;
  if(a >= m) a -= m;
  return a;
}

int Sub(int a, int b, int m = MOD){
  a -= b;
  if(a < 0) a += m;
  return a;
}

int AddTo(int& to, int w, int m = MOD){
  to += w;
  if(to >= m) to -= m;
  return to;
}

int SubTo(int& to, int w, int m = MOD){
  to -= w;
  if(to < 0) to += m;
  return to;
}

int Mult(int a, int b, int m = MOD){
  return (a * 1LL * b) % m;
}

// Bit
struct Bit {
  vi sum;

  Bit(){
    sum.resize(MAXN, 0);
  }

  void BitAdd(int pos, int w){
    for(++pos;pos < MAXN;pos += (pos & (-pos)))
      AddTo(sum[pos], w);
  }

  void BitSub(int pos, int w){
    for(++pos;pos < MAXN;pos += (pos & (-pos)))
      SubTo(sum[pos], w);
  }

  int BitGet(int l, int r){
    int res = 0;
    for(++r;r > 0;r -= (r & (-r)))
      AddTo(res, sum[r]);
    for(;l > 0;l -= (l & (-l)))
      SubTo(res, sum[l]);
    return res;
  }
};

struct BitReg {
  vector<ll> sum;

  BitReg(){
    sum.resize(MAXN, 0);
  }

  void BitAdd(int pos, int w){
    for(++pos;pos < MAXN;pos += (pos & (-pos)))
      sum[pos] += w;
  }

  void BitSub(int pos, int w){
    for(++pos;pos < MAXN;pos += (pos & (-pos)))
      sum[pos] -= w;
  }

  ll BitGet(int l, int r){
    ll res = 0;
    for(++r;r > 0;r -= (r & (-r)))
      res += sum[r];
    for(;l > 0;l -= (l & (-l)))
      res -= sum[l];
    return res;
  }
};

// Solution
int n, q;
int a_[MAXN], w_[MAXN];
int a[MAXN], w[MAXN];

Bit lr, rl;
BitReg sumw;

void Update(int i, int na, int nw){
  sumw.BitSub(i, w[i]);
  lr.BitSub(i, Mult(Sub(i, a[i]), w[i]));
  rl.BitSub(i, Mult(Sub(a[i], i), w[i]));

  a[i] = na;
  w[i] = nw;

  sumw.BitAdd(i, w[i]);
  lr.BitAdd(i, Mult(Sub(i, a[i]), w[i]));
  rl.BitAdd(i, Mult(Sub(a[i], i), w[i]));
}

int Eval(int l, int r, int mid, int start){
  int ans = 0;

  if(l <= mid){
    int koef = Sub(start, l);
    AddTo(ans, lr.BitGet(l, mid));
    AddTo(ans, Mult(koef, sumw.BitGet(l, mid)));
  }

  if(mid + 1 <= r){
    int pos = start + mid + 1 - l;
    int koef = Sub(mid + 1, pos);
    AddTo(ans, rl.BitGet(mid + 1, r));
    AddTo(ans, Mult(koef, sumw.BitGet(mid + 1, r)));
  }

  return ans;
}

int GetMid(int l, int r, int start){
  if(a[l] > start) return l - 1;
  int lo = l, hi = r, mid;
  for(;;){
    if(lo + 1 >= hi){
      if(a[hi] <= start + hi - l) return hi;
      else return lo;
    }
    mid = (lo + hi) >> 1;
    if(a[mid] <= start + mid - l)
      lo = mid;
    else
      hi = mid;
  }
}

int EvalAtStart(int l, int r, int start){
  int mid = GetMid(l, r, start);
  return Eval(l, r, mid, start);
}

int Solve(int l, int r){
  ll total = sumw.BitGet(l, r);
  int lo = l, hi = r, mid;
  for(;;){
    if(lo + 1 >= hi){
      if(2 * sumw.BitGet(l, lo) >= total) mid = lo;
      else mid = hi;
      break;
    }
    mid = (lo + hi) >> 1;
    if(2 * sumw.BitGet(l, mid) <= total) lo = mid;
    else hi = mid;
  }

  return EvalAtStart(l, r, a[mid] - (mid - l));
}

int main(){
  scanf("%d%d", &n, &q);
  for(int i = 0;i < n;++i) scanf("%d", &a_[i]);
  for(int i = 0;i < n;++i) scanf("%d", &w_[i]);

  for(int i = 0;i < n;++i)
    Update(i, a_[i], w_[i]);

  for(int i = 0;i < q;++i){
    int x, y;
    scanf("%d%d", &x, &y);
    if(x > 0){
      --x, --y;
      printf("%d\n", Solve(x, y));
    } else {
      x = -x - 1;
      Update(x, a[x], y);
    }
  }

  return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
pair<double, LL> operator+(pair<double, LL> a, pair<double, LL> b) {
  return make_pair(a.first + b.first, (a.second + b.second) % MOD);
}
struct seg{
  double to_cmp = 0;
  LL sum = 0;
  seg* ch[2] = {nullptr, nullptr};
  int l, r, m;
  void pull() {
    (sum = ch[0] -> sum + ch[1] -> sum) %= MOD;
    to_cmp = ch[0] -> to_cmp + ch[1] -> to_cmp;
  }
  seg(int l, int r, vector<LL> &A) : l(l), r(r) {
    if (r - l > 1) {
      m = l + r >> 1;
      ch[0] = new seg(l, m, A);
      ch[1] = new seg(m, r, A);
      pull();
    }
    else to_cmp = sum = A[l], sum = (sum % MOD + MOD) % MOD;
  }
  void modify(int x, LL val) {
    if (r - l == 1) return to_cmp = sum = val, sum = (sum % MOD + MOD) % MOD, void();
    if (x < m) ch[0] -> modify(x, val);
    if (m <= x) ch[1] -> modify(x, val);
    pull();
  }
  pair<double, LL> query(int L, int R) {
    if (L >= R) return {0., 0ll};
    if (L <= l and r <= R) return {to_cmp, sum};
    pair<double, LL> ans = make_pair(0. , 0ll);
    if (L < m) ans = ans + ch[0] -> query(L, R);
    if (m < R) ans = ans + ch[1] -> query(L, R);
    return ans;
  }
};
signed main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n, q; cin >> n >> q;
  vector<LL> w(n), wr(n), a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> w[i], wr[i] = w[i] * (i - a[i]);
  seg *wrT = new seg(0, n, wr), *wT = new seg(0, n, w);
  auto askd = [&](int l, int r, int m) {
    assert(m < n);
    return (a[m] - m) * wT->query(l, r).first + wrT->query(l, r).first;
  };
  auto askL = [&](int l, int r, int m) {
    return ((a[m] - m) * wT->query(l, r).second + wrT->query(l, r).second) % MOD;
  };
  auto queryL = [&](int l, int r, int m) {
    LL ans = askL(l, m, m) - askL(m, r, m);
    return (ans % MOD + MOD) % MOD;
  };
  auto queryd = [&](int l, int r, int m) {
    return askd(l, m, m) - askd(m, r, m);
  };
  while (q--) {
    LL m = 0, l, r; cin >> l >> r;
    if (l < 0) l = -l - 1, wT->modify(l, r), wrT->modify(l, r * (l - a[l]));
    else {
      --l;
      int ml = l, mr = r - 1;
      while (mr - ml > 1) {
        m = 1 + mr + ml >> 1;
        if (queryd(l, r, m) - queryd(l, r, m - 1) >= 0) mr = m;
        else ml = m;
      } m = mr;
      if (m - 1 >= l and queryd(l, r, m) > queryd(l, r, m - 1))
        cout << queryL(l, r, m - 1) << '\n';
      else
        cout << queryL(l, r, m) << '\n';
    }
  }
}

#include <bits/stdc++.h>
// #include "lib.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define LLINF 1234567890987654321
#define INF 1234567890
#define pb push_back
#define ins insert
#define f first
#define s second
#define db 0
#define MAXN 200006
#define MAXK 200006
#define MAXX 15000006
#define rep(kk, l1, l2)for(ll kk = l1; kk < l2; kk++)
#define bg(ms) *ms.begin()
#define ed(ms) *prev(ms.end(), 1)
#define addedge(a, b, c) v[a].pb(pi(b, c)); v[b].pb(pi(a, c))
#define MOD 1000000007
#define ph push
#define all(x) x.begin(), x.end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef long long ll;
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
ll n, q, fw[MAXN], total, ans;
ll l, r, lefty, righty;
ll st, en, mid;
ll mody(ll x)
{
	if(x > 0 && x >= MOD)x-=MOD;
	else if(x < 0 && x <= -MOD)x += MOD;
	return x;
}
void update(ll x, ll v)
{
  for(; x<=n; x+=x&(-x))fw[x] += v;
}
ll sum(ll x)
{
  ll res = 0;
  for(; x; x-=x&(-x))res += fw[x];
  return res;
}
ll range_sum(ll a, ll b)
{
  if(a > b)return 0;
  return sum(b) - sum(a-1);
}
struct box
{
  ll p=0, w=0;
} A[MAXN];
struct fen2
{
  ll fw[MAXN];
  void init() { rep(i, 0, MAXN)fw[i] = 0; }
  void update(ll x, ll nv)
  {
    for(; x<=n; x+=x&(-x))fw[x] += nv;
  }
  ll sum(ll x)
  {
    ll res = 0;
    for(; x; x-=x&(-x))res += fw[x];
    return res;
  }
  ll range_sum(ll a, ll b)
  {
    if(a > b)return 0;
    return (mody(sum(b) - sum(a-1)));
  }
} f2;
int main()
{
  f2.init();
  cin >> n >> q;
  rep(i, 0, n)cin >> A[i].p;
  rep(i, 0, n)cin >> A[i].w;
  rep(i, 0, n)update(i+1, A[i].w), f2.update(i+1, ( mody((A[i].w*(((i+1)-A[i].p))))) );
  rep(_, 0, q)
  {
    cin >> l >> r;
    st = l-1, en = r, mid = 0, ans = 0;
    if(l < 0)
    {
      //means update
      l = -l;
      ll ol = A[l-1].w;
      ll original = f2.range_sum(l, l);
      A[l-1].w = r;
      update(l, (A[l-1].w-ol)); //l(given in input) is one-indexed, but A is 0-indexed
      f2.update(l, -original);
      f2.update(l, ( mody(( A[l-1].w*(l-A[l-1].p) ))) );
      continue;
    }
    total = range_sum(l, r);
    // cout << total << '\n';
    while(en-st > 1)
    {
      mid = ( (st+en) / 2);
      if(range_sum(l, mid) <= total/2) st = mid;
      else en = mid;
    }
    ++st;
    lefty = range_sum(l, st-1), righty = range_sum(st+1, r);
    ans = mody(( (mody(lefty*A[st-1].p)) - (mody(lefty*st)) + mody((f2.range_sum(l, st-1))) ) );
    // cout << ans << ' ';
    ans = mody(( (ans - (mody(righty*A[st-1].p)) + (mody(righty*st)) + mody((- f2.range_sum(st+1, r))) )));
    // cout << ans << ' ' << st << '\n';
    cout << mody(ans) << '\n';
  }
}

/*

F() Wi(Ak - Ai - k + i )
TwAk - Twk + F() WiI - WiAi

4 10
1 333333333 666666666 1000000000
1000000000 1000000000 1000000000 1000000000
1 4
*/

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ull = unsigned ll;

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x first
#define y second

const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};
const char dir[] = {'R', 'L', 'D', 'U'};

double add(double a, double b){ //(a + b) % 1e9 + 7
    a += b;
    return a;
}

double subtract(double a, double b){
    a -= b;
    return a;
}

double mult(double a, double b){
    return a * b;
}

void setIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
//    freopen((s+".in").c_str(),"r",stdin);
//    freopen((s+".text").c_str(),"w",stdout);
}

const int mxN = 200'000;

int n, q;
double a[mxN], w[mxN];

struct node{
    double toLeft, toRight, total, l, r, inSeg;
    node(int tl, int tr, int tt, int left, int right, int is){
        toLeft = tl;
        toRight = tr;
        total = tt;
        l = left;
        r = right;
        inSeg = is;
    }
    node(){
        toLeft = 0, toRight = 0, total = 0;
        l = 0, r = 0;
        inSeg = 0;
    }
};

node st[mxN << 2];

void update(node& t, int ind){
    t = node(0, 0, w[ind], a[ind], a[ind], 1);
}

node merge(node& a, node& b){
    if(a.inSeg == 0) return b;
    if(b.inSeg == 0) return a;
    node c;
    c.r = b.r;
    c.l = a.l;
    int nextRight = b.r - b.inSeg;
    c.toRight = b.toRight + a.toRight + a.total * (nextRight - a.r);
    int nextLeft = a.l + a.inSeg;
    c.toLeft = a.toLeft + b.toLeft + b.total * (b.l - nextLeft);
    c.total = a.total + b.total;
    c.inSeg = a.inSeg + b.inSeg;
    return c;
}

void build(int v, int l, int r){
    if(l == r){
        st[v] = node(0, 0, w[l], a[l], a[l], 1);
        return;
    }
    int m = (l + r) / 2;
    build(v * 2 + 1, l, m);
    build(v * 2 + 2, m + 1, r);
    st[v] = merge(st[v * 2 + 1], st[v * 2 + 2]);
}

void update(int v, int l, int r, int ind){
    if(r < ind || l > ind) return;
    if(l == r){
        update(st[v], ind);
        return;
    }
    int m = (l + r) / 2;
    build(v * 2 + 1, l, m);
    build(v * 2 + 2, m + 1, r);
    st[v] = merge(st[v * 2 + 1], st[v * 2 + 2]);
}

node get(int v, int l, int r, int L, int R){
    if(L > R || r < L || l > R) return node();
    if(L == l && r == R){
        return st[v];
    }
    int m = (l + r) / 2;
    node left = get(v * 2 + 1, l, m, L, min(R, m));
    node right = get(v * 2 + 2, m + 1, r, max(L, m + 1), R);
    return merge(left, right);
}

int main(){
    setIO();
    //CHECK FOR LONG LONG!!!
    //LONG LONG OVERFLOW??
    cin >> n >> q;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    for(int i = 0; i < n; ++i){
        cin >> w[i];
    }
    build(0, 0, n - 1);
    while(q--){
        int x, y; cin >> x >> y;
        if(x < 0){
            x = -x; --x;
            w[x] = y;
            update(0, 0, n - 1, x);
        }
        else{
            --x; --y;
            int l = x, r = y;
            while(l < r){
                int m = l + (r - l) / 2;
                int curloc = a[m];
                double amt1 = 0;
                if(m == x){
                    node cur = get(0, 0, n - 1, m + 1, y);
                    amt1 = add(cur.toLeft, mult(cur.total, cur.l - curloc - 1));
                }
                else {
                    node right = get(0, 0, n - 1, m + 1, y);
                    node left = get(0, 0, n - 1, x, m - 1);
                    amt1 = add(add(right.toLeft, mult(right.total, right.l - curloc - 1)), add(left.toRight, mult(left.total, curloc - left.r - 1)));
                }
                double amt2 = 0;
                int mm = m + 1;
                curloc = a[mm];
                if(mm == y){
                    node cur = get(0, 0, n - 1, x, mm - 1);
                    amt2 = add(cur.toRight, mult(cur.total, curloc - cur.r - 1));
                }
                else{
                    node right = get(0, 0, n - 1, mm + 1, y);
                    node left = get(0, 0, n - 1, x, mm - 1);
                    amt2 = add(add(right.toLeft, mult(right.total, right.l - curloc - 1)), add(left.toRight, mult(left.total, curloc - left.r - 1)));
                }
                if(amt1 < amt2){
                    r = m;
                }
                else{
                    l = m + 1;
                }
            }
            int curloc = a[l];
            if(l == x){
                node cur = get(0, 0, n - 1, l + 1, y);
                cout << add(cur.toLeft, mult(cur.total, cur.l - curloc - 1)) << "\n";
            }
            else if(l == y){
                node cur = get(0, 0, n - 1, x, l - 1);
                cout << add(cur.toRight, mult(cur.total, curloc - cur.r - 1)) << "\n";;
            }
            else{
                node right = get(0, 0, n - 1, l + 1, y);
                node left = get(0, 0, n - 1, x, l - 1);
                cout << add(add(right.toLeft, mult(right.total, right.l - curloc - 1)), add(left.toRight, mult(left.total, curloc - left.r - 1))) << "\n";
            }
        }
    }
    //CHECK FOR LONG LONG!!!
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

const int MAXN = 200005;
const int S = 450;
const int MOD = 1e9 + 7;
const int INF = 1 << 30;

inline void add(int &a, int b)
{
	a = ((long long)a + b) % MOD;
}

inline void mul(int &a, int b)
{
	a = (long long)a * b % MOD;
}

struct Block
{
	int sum, movel, mover, l, r;
}b[S + 10];

long long sum_prev[MAXN], a[MAXN], w[MAXN];

int n, q, x, y;

#define SUM(x) (x < 0 ? 0 : sum_prev[x])

int calc(int l, int r)
{
	int d = l, u = r;
	while (l < r)
	{
		int mid = (l + r) >> 1;
		if (SUM(mid) - SUM(d - 1) >= SUM(u) - SUM(mid))
			r = mid;
		else
			l = mid + 1;
	}
	return l;
}

int main()
{
	scanf("%d%d", &n, &q);
	for (int i = 0; i < n; i++)
		scanf("%I64d", &a[i]);
	for (int i = 0; i < n; i++)
		scanf("%I64d", &w[i]);
	sum_prev[0] = w[0];
	for (int i = 1; i < n; i++)
		sum_prev[i] = sum_prev[i - 1] + w[i];
	for (int i = 0; i < n; i++)
		add(b[i / S].sum, w[i]);
	for (int i = 0; i < n; i++)
	{
		int l = i, r = i, id = i / S;
		while (id == (r + 1) / S && r + 1 < n)
			++r;
		for (int j = l; j <= r; j++)
			add(b[id].movel, (long long)(a[j] - a[l] - (j - l)) * w[j] % MOD);
		for (int j = r; j >= l; j--)
			add(b[id].mover, (long long)(a[r] - a[j] - (r - j)) * w[j] % MOD);
		b[id].l = l, b[id].r = r;
		i = r;
	}
	for (int i = 1; i <= q; i++)
	{
		scanf("%d%d", &x, &y);
		if (x < 0)
		{
			x = -x;
			--x;
			int id = x / S, l = b[id].l, r = b[id].r;
			add(b[id].sum, (y - w[x] + MOD) % MOD);
			add(b[id].movel, MOD - (long long)(a[x] - a[l] - (x - l)) * w[x] % MOD);
			add(b[id].movel, (long long)(a[x] - a[l] - (x - l)) * y % MOD);
			add(b[id].mover, MOD - (long long)(a[r] - a[x] - (r - x)) * w[x] % MOD);
			add(b[id].mover, (long long)(a[r] - a[x] - (r - x)) * y % MOD);
			w[x] = y;
		}
		else
		{
			if (x == y)
			{
				printf("0\n");
				continue;
			}
			--x, --y;
			int L = x, R = y, M = calc(L, R);
			int idl = L / S, idm = M / S, idr = R / S, res = 0, d = max(L, b[idm].l), u = min(R, b[idm].r);
			for (int j = M - 1; j >= d; j--)
				add(res, (long long)(a[M] - a[j] - (M - j)) * w[j] % MOD);
			for (int j = M + 1; j <= u; j++)
				add(res, (long long)(a[j] - a[M] - (j - M)) * w[j] % MOD);
			for (int j = idm - 1; j > idl; j--)
			{
				int x = b[j].r;
				add(res, ((long long)((a[M] - M) - (a[x] - x)) * b[j].sum % MOD + b[j].mover) % MOD);
			}
			for (int j = idm + 1; j < idr; j++)
			{
				int x = b[j].l;
				add(res, ((long long)((a[x] - x) - (a[M] - M)) * b[j].sum % MOD + b[j].movel) % MOD);
			}
			if (idl != idm)
				for (int j = b[idl].r; j >= L; j--)
					add(res, (long long)((a[M] - M) - (a[j] - j)) * w[j] % MOD);
			if (idr != idm)
				for (int j = b[idr].l; j <= R; j++)
					add(res, (long long)((a[j] - j) - (a[M] - M)) * w[j] % MOD);
			printf("%d\n", res);
		}
	}
	return 0;
}

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
const int maxn=212345;
const long long mod=1e9+7;
int n,q,w[maxn],a[maxn];
long long bit1[maxn],bit2[maxn];
long double bit11[maxn],bit22[maxn];
inline void update(long long *bit,int x,long long v,bool flag=false) {
    if (flag) v=(v%mod+mod)%mod;
    while (x<=n) {
        bit[x]+=v;
        if (flag) bit[x]%=mod;
        x+=x&-x;
    }
}
inline long long sum(long long *bit,int x,bool flag=false) {
    long long ret=0;
    while (x) {
        ret+=bit[x];
        if (flag) ret%=mod;
        x-=x&-x;
    }
    return ret;
}
inline void update(long double *bit,int x,long long v) {
    while (x<=n) {
        bit[x]+=v;
        x+=x&-x;
    }
}
inline long double sum(long double *bit,int x) {
    long double ret=0;
    while (x) {
        ret+=bit[x];
        x-=x&-x;
    }
    return ret;
}
inline long long getans(int x,int y,int res) {
    long long sum1=(sum(bit1,res)-sum(bit1,x-1))%mod*a[res]%mod-(sum(bit2,res,true)-sum(bit2,x-1,true))%mod;
    long long sum2=(sum(bit2,y,true)-sum(bit2,res,true))%mod-(sum(bit1,y)-sum(bit1,res))%mod*a[res]%mod;
    return ((sum1+sum2)%mod+mod)%mod;
}
inline long double getcost(int x,int y,int res) {
    //printf("x=%d y=%d res=%d\n",x,y,res);
    long double sum1=(sum(bit11,res)-sum(bit11,x-1))*a[res]-sum(bit22,res)-sum(bit22,x-1);
    long double sum2=sum(bit22,y)-sum(bit22,res)-(sum(bit11,y)-sum(bit11,res))*a[res];
    return sum1+sum2;
}
inline int getpos(int left,int right) {
    long double l=left,r=right;
    for (int i=0;r-l>10;++i) {
        long double mid=l+(r-l)/3,midmid=l+2*(r-l)/3;
        long double cost1=getcost(left,right,(int)floor(mid));
        long double cost2=getcost(left,right,(int)ceil(midmid));
        if (cost1>=cost2) l=mid;
        else r=midmid;
    }
    int pos=(int)((l+r)/2.0);
    long double mmin=getcost(left,right,pos);
    for (int i=max(left,pos-15);i<=min(right,pos+15);++i) {
        long double tmp=getcost(left,right,i);
        if (tmp<mmin) {
            mmin=tmp;
            pos=i;
        }
    }
    //printf("%.12f\n",(double)pos);
    return pos;
}
int main()
{
    scanf("%d%d",&n,&q);
    for (int i=1;i<=n;++i) scanf("%d",&a[i]),a[i]-=i;
    for (int i=1;i<=n;++i) {
        scanf("%d",&w[i]);
        update(bit1,i,w[i]);
        update(bit2,i,1LL*a[i]*w[i]%mod,true);
        update(bit11,i,w[i]);
        update(bit22,i,1.0*a[i]*w[i]);
    }
    while (q--) {
        int x,y;scanf("%d%d",&x,&y);
        if (x<0) {
            x=-x;
            update(bit1,x,y-w[x]);
            update(bit2,x,1LL*a[x]*(y-w[x])%mod,true);
            update(bit11,x,y-w[x]);
            update(bit22,x,1.0*a[x]*(y-w[x]));
            w[x]=y;
        } else {
            if (x==y) {
                puts("0");
                continue;
            }
            int res=getpos(x,y);
            /*
            int left=x,right=y,resres=x;
            long long rev=sum(bit1,x-1);
            long long tot=sum(bit1,y)-rev;
            tot=(tot+1)>>1;
            while (left<=right) {
                int mid=(left+right)>>1;
                if (sum(bit1,mid-1)-rev<tot) {
                    resres=mid;
                    left=mid+1;
                } else right=mid-1;
            }
            printf("resres=%d res=%d\n",resres,res);
            printf("%f %f %d\n",(double)getcost(x,y,1),(double)getcost(x,y,2),getcost(x,y,1)>getcost(x,y,2));
            */
            printf("%I64d\n",getans(x,y,res));
        }
    }
    return 0;
}
/*
3 3
351772224 464078370 812738126
149252109 153315732 540915058
1 2
-3 861733588
-1 190898187
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll, ll> ii;
typedef pair <ll, ii> iii;

const ll N = 2e5 + 5;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;

struct data {
    ll a, b, c;
} tree[N << 2 | 1];

ll n, Q, a[N], w[N];

data operator + (const data &a, const data &b) {
    data c;
    c.a = a.a + b.a;
    c.b = a.b + b.b;
    c.c = a.c + b.c;
    return c;
}

inline void init(ll k, ll l, ll r) {
    if (l == r) tree[k] = { w[l], w[l] * (l - a[l]) % mod, w[l] * (a[l] - l) % mod };
    else {
        ll mid = (l + r) >> 1;
        init(k << 1, l, mid); init(k << 1 | 1, mid + 1, r);
        tree[k] = tree[k << 1] + tree[k << 1 | 1];
    }
}

inline void update(ll k, ll l, ll r, ll pos) {
    if (l > pos || r < pos) return;
    if (l == r && l == pos) tree[k] = { w[l], w[l] * (l - a[l]) % mod, w[l] * (a[l] - l) % mod };
    else {
        ll mid = (l + r) >> 1;
        update(k << 1, l, mid, pos);
        update(k << 1 | 1, mid + 1, r, pos);
        tree[k] = tree[k << 1] + tree[k << 1 | 1];
    }
}

inline data query(ll k, ll l, ll r, ll L, ll R) {
    if (l > R || r < L) return { 0, 0, 0 };
    if (L <= l && r <= R) return tree[k];
    else {
        ll mid = (l + r) >> 1;
        return query(k << 1, l, mid, L, R) + query(k << 1 | 1, mid + 1, r, L, R);
    }
}

inline ll sum(const ll &l, const ll &r, const ll &num) {
    if (num == 1) return query(1, 1, n, l, r).a;
    if (num == 2) return query(1, 1, n, l, r).b;
    if (num == 3) return query(1, 1, n, l, r).c;
}

inline ll Find(ll k, ll l, ll r, ll val) {
    if (l == r) return l;
    ll mid = (l + r) >> 1;
    if (tree[k << 1].a > val) return Find(k << 1, l, mid, val);
    return Find(k << 1 | 1, mid + 1, r, val - tree[k << 1].a);
}

int main() {
    //freopen("1058F.INP", "r", stdin);
    //freopen("1058F.OUT", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    scanf("%lld%lld", &n, &Q);
    for (ll i = 1; i <= n; i++) scanf("%lld", a + i);
    for (ll i = 1; i <= n; i++) scanf("%lld", w + i);
    //********************
    init(1, 1, n);
    while (Q--) {
        ll x, y; scanf("%lld%lld", &x, &y);
        if (x < 0) {
            x = -x;
            w[x] = y;
            update(1, 1, n, x);
        } else {
            ll k = 0;
            ll ss = sum(x, y, 1) / 2;
            k = Find(1, 1, n, ss + sum(1, x - 1, 1));
            ll s = 0;
            s = (s + (a[k] * sum(x, k - 1, 1) % mod) - (k * sum(x, k - 1, 1) % mod) + mod) % mod;
            s = (s + sum(x, k - 1, 2) + mod) % mod;
            s = (s - (a[k] * sum(k, y, 1) % mod) + (k * sum(k, y, 1) % mod) + mod) % mod;
            s = (s + sum(k, y, 3) + mod) % mod;
            printf("%lld\n", s);
        }
    }
    return 0;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
#define P 1000000007
#define int long long

using namespace std;

int n, q, A[200010], W[200010], Sm1[800010], Sm2[800010];

void upd(int x) {
    Sm1[x] = (Sm1[x * 2] + Sm2[x * 2 + 1]) % P;
    Sm2[x] = (Sm2[x * 2] + Sm2[x * 2 + 1]) % P;
}

/*void build(int x, int L, int R) {
    if(L == R) Sm1[x] = A[L], Sm2[x] = (A[L] - L) * W[L] % P;
    else {
        build(x * 2, L, (L + R) / 2);
        build(x * 2 + 1, (L + R) / 2 + 1, R);
        upd(x);
    }
}

void modify(int x, int L, int R, int v) {
    if(L == R) {
        Sm1[x] = A[v];
        Sm2[x] = (A[v] - L) * W[v] % P;
        return;
    }
    if(v <= (L + R) / 2) modify(x * 2, L, (L + R) / 2, v);
    else modify(x * 2 + 1, (L + R) / 2, R, v);
    upd(x);
}

int getsum1(int x, int L, int R, int l, int r) {
    if(L == l && R == r) return Sm1[x];
    int md = (L + R) / 2, ans = 0;
    if(l <= md) ans = getsum1(x * 2, L, md, l, min(md, r));
    if(r > md) ans += getsum1(x * 2 + 1, md + 1, R, max(md + 1, l), r);
    upd(x);
}

int getsum2(int x, int L, int R, int l, int r) {
    if(L == l && R == r) return Sm2[x];
    int md = (L + R) / 2, ans = 0;
    if(l <= md) ans = getsum1(x * 2, L, md, l, min(md, r));
    if(r > md) ans += getsum1(x * 2 + 1, md + 1, R, max(md + 1, l), r);
    upd(x);
}

int find(int x, int L, int R, int l, int v, int nw = 0) {
    int md = (L + R) / 2;
    if(L == R) {
        if((nw + Sm1[x]) * 2 < v) return L + 1; else return L;
    }
    if(l <= md) {
        if(getsum(L + 1, ))
    }
}*/

void add1(int x, int v) {
    for(int i = x; i <= n; i += i & -i) Sm1[i] = (Sm1[i] + v) % P;
}

void add2(int x, int v) {
    for(int i = x; i <= n; i += i & -i) Sm2[i] = (Sm2[i] + v) % P;
}

int ask1(int x) {
    int ans = 0;
    for(int i = x; i; i -= i & -i) ans = (ans + Sm1[i]) % P;
    return ans;
}

int ask2(int x) {
    int ans = 0;
    for(int i = x; i; i -= i & -i) ans = (ans + Sm2[i]) % P;
    return ans;
}

#undef int
int main() {
#define int long long
    scanf("%lld%lld", &n, &q);
    for(int i = 1; i <= n; i++) scanf("%lld", &A[i]);
    for(int i = 1; i <= n; i++) scanf("%lld", &W[i]);
    for(int i = 1; i <= n; i++) {
        add1(i, W[i]);
        add2(i, (A[i] - i) * W[i] % P);
    }
    for(int T = 1; T <= q; T++) {
        int a, b;
        scanf("%lld%lld", &a, &b);
        if(a > 0) {
            int o = ask1(a - 1), p = ask1(b), v = p - o;
            int ans = a;
            for(int l = a, r = b; l <= r; ) {
                int md = (l + r) / 2;
                if((ask1(md) - o) * 2 >= v) ans = md, r = md - 1;
                else l = md + 1;
            }
            int tot = (A[ans] - ans) * (ask1(ans) - ask1(a - 1)) - (ask2(ans) - ask2(a - 1));
            tot = tot + (ask2(b) - ask2(ans)) - (A[ans] - ans) * (ask1(b) - ask1(ans));
            printf("%lld\n", (tot % P + P) % P);
        } else {
            a = -a;
            add1(a, -W[a]);
            add2(a, -(A[a] - a) * W[a] % P);
            W[a] = b;
            add1(a, W[a]);
            add2(a, (A[a] - a) * W[a] % P);
        }
    }
    return 0;
    //build(1, 1, n);
}

#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, a) for (int i = 0; i < (a); ++i)
#define DEBUG(x) { cerr << #x << '=' << x << endl; }
#define Arr(a, l, r) { cerr << #a << " = {"; FOR(_, l, r) cerr << ' ' << a[_]; cerr << "}\n"; }
#define N 210100
#define pp pair<int, int>
#define endl '\n'
#define IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define taskname ""
#define bit(S, i) (((S) >> (i)) & 1)
#define all(s) s.begin(), s.end()
using namespace std;

const long long MOD = 1e9 + 7;
int n, q, a[N], w[N];

struct Data {
    long long sum, product;

    Data() {}
    Data(long long sum, long long product):sum(sum), product(product) {}

}IT[N * 4];

Data operator+(Data a, Data b) {
    return Data(a.sum + b.sum, (a.product + b.product) % MOD);
}

void Up(int k, int l, int r, int u, int val) {
    if (l == r) {
        IT[k] = Data(val, 1ll * val * a[l] % MOD);
        return;
    }
    int m = (l + r) >> 1;
    if (u <= m) Up(k << 1, l, m, u, val);
    else Up(k << 1 | 1, m + 1, r, u, val);
    IT[k] = IT[k << 1] + IT[k << 1 | 1];
}

Data Get(int k, int l, int r, int u, int v) {
    if (l > v || r < u) return Data(0, 0);
    if (u <= l && r <= v) return IT[k];
    int m = (l + r) >> 1;
    return Get(k << 1, l, m, u, v) + Get(k << 1 | 1, m + 1, r, u, v);
}

long long f(long long m, int l, int r) {
    int p = upper_bound(a + 1, a + n + 1, m) - a;
    Data left = Get(1, 1, n, l, p - 1), right = Get(1, 1, n, p, r);
    return ((m * left.sum % MOD - left.product + right.product - m * right.sum % MOD) % MOD + MOD) % MOD;
}

long long Query(int l, int r) {
    long long sumw = Get(1, 1, n, l, r).sum;
    int left = l, right = r, cur = l;
    while (left <= right) {
        int m = (left + right) >> 1;
        if (Get(1, 1, n, l, m).sum * 2 >= sumw) {
            cur = m;
            right = m - 1;
        } else left = m + 1;
    }
    return f(a[cur], l, r);
}
int main() {
    #ifdef NERO
    freopen("test.inp","r",stdin);
    freopen("test.out","w",stdout);
    double stime = clock();
    #else
        //freopen(taskname".inp","r",stdin);
        //freopen(taskname".out","w",stdout);
    #endif //NERO
    IO;
    cin >> n >> q;
    FOR(i, 1, n) {
        cin >> a[i]; a[i] -= i;
    }
    FOR(i, 1, n) cin >> w[i];
    FOR(i, 1, n)
        Up(1, 1, n, i, w[i]);
    FOR(i, 1, q) {
        int x, y;
        cin >> x >> y;
        if (x < 0) {
            x = -x;
            Up(1, 1, n, x, y);
        } else {
            cout << Query(x, y) << endl;
        }
    }
    #ifdef NERO
    double etime = clock();
    cerr << "Execution time: " << (etime - stime) / CLOCKS_PER_SEC * 1000 << " ms.\n";
    #endif // NERO
}

#include <sstream>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<ctime>
#include<cmath>
#include<map>
#include<stack>
#include<random>
#include<queue>
#include<list>
using namespace std;
const long long int INF=2000000000000000000;
#define ll long long int
#define ld long double
#define key pair<ld,ld>
#define ii pair<int,int>
#define si set<int>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int> >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define nu 100001
#define mod 1000000007
#define mul(x,y) ((ll)(x)*(y))%mod
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
vector<ll> tree1;
vector<ll> tree2;
vector<ll> tree3;
ll MOD(ll a, ll b)
{
    if(a>b)
        return a-b;
    else
        return b-a;
}
ll max3(ll a,ll b, ll c)
{
    return max(c,max(a,b));
}
ll min3(ll a,ll b,ll c)
{
    return min(a,min(b,c));
}
ll power(ll x,ll y )
{
    ll res = 1;
    x = x ;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}
ll logg(ll a)
{
    ll x=0;
    while(a>1)
    {
        x++;
        a/=2;
    }
    return x;
}
ll gcd(ll a,ll  b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
void update(ll val,int ind,vector<ll>&bit)
{
    for(int j=ind;j<bit.size();j=j+(j&(-j)))
    {
        bit[j]=(bit[j]+val);
    }
}
void modupdate(ll val,int ind,vector<ll>&bit)
{
    for(int j=ind;j<bit.size();j=j+(j&(-j)))
    {
        bit[j]=(bit[j]+val);
        if(bit[j]<0)
        {
            bit[j]=bit[j]+((0-bit[j])/mod)*mod;
        }
        if(bit[j]<0)
        {
            bit[j]+=mod;
        }
        bit[j]=bit[j]%mod;
    }
}
ll query(int ind,vector<ll> &bit)
{
    ll ans=0;
    for(int j=ind;j>0;j=j-(j&(-j)))
    {
        ans=ans+bit[j];
    }
    return ans;
}

ll modquery(int ind,vector<ll> &bit)
{
    ll ans=0;
    for(int j=ind;j>0;j=j-(j&(-j)))
    {
        ans=ans+bit[j];
        if(ans<0)
        {
            ans=ans+((0-ans)/mod)*mod;
        }
        if(ans<0)
        {
            ans+mod;
        }
        ans=ans%mod;
    }
    return ans%mod;
}
int findoptindex(int l,int r)
{
    int mid=-1;
    int beg=l;
    int end=r;
    ll temp=query(l-1,tree1);
    ll sum=query(r,tree1)-query(l-1,tree1);
    while(beg<=end)
    {
        mid=(beg+end)/2;
        ll temp3=query(mid-1,tree1);
        ll temp1=temp3-temp;
        ll temp2=query(mid,tree1)-temp;
        if(temp1<=sum/2&&temp2>=sum/2)
        {
            return mid;
        }
        else
        {
            if(temp3>=sum/2)
            {
                end=mid-1;
            }
            else
            {
                beg=mid+1;
            }
        }
    }
    return mid;
}
int main()
{
    fastio;
    int n,q;
    cin>>n>>q;
    vector<ll> a(n+1);vector<ll> w(n+1);
    tree1.resize(n+1,0);
    tree2.resize(n+1,0);
    tree3.resize(n+1,0);
    vector<ll> arr2(n+1);
    vector<ll> arr3(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
    {
        cin>>w[i];
        update(w[i],i,tree1);
    }
    for(int i=1;i<=n;i++)
    {
        arr2[i]=a[i]*w[i];
        arr3[i]=i*w[i];
        modupdate(arr2[i],i,tree2);
        modupdate(arr3[i],i,tree3);
    }
    for(int i=0;i<q;i++)
    {
        int x,y;
        cin>>x>>y;
        if(x<0)
        {
            int ind=-x;
            ll val=y-w[ind];
            ll val2=a[ind]*(y-w[ind]);
            ll val3=ind*(y-w[ind]);
            update(val,ind,tree1);
            modupdate(val2,ind,tree2);
            modupdate(val3,ind,tree3);
        }
        else
        {
            int j=findoptindex(x,y);
            ll ans=((a[j]-j)*((query(j-1,tree1)-query(x-1,tree1))%mod))%mod-(modquery(j-1,tree2)-modquery(x-1,tree2))+modquery(j-1,tree3)-modquery(x-1,tree3);
            ans-=((a[j]-j)*((query(y,tree1)-query(j+1-1,tree1))%mod))%mod-(modquery(y,tree2)-modquery(j+1-1,tree2))+modquery(y,tree3)-modquery(j+1-1,tree3);
            if(ans<0)
            {
                ans=ans+((0-ans)/mod)*mod;
            }
            ans=ans+mod;

            cout<<ans%mod<<endl;
        }
    }
}

#include <iostream>
#include <iomanip>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <cassert>
#include <fstream>
#include <algorithm>
#include <list>
#include <random>
#include <ctime>
#include <cmath>
#include <random>
#include <bitset>
#include <complex>
#include <stack>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define mmin(a, b) a = min(a, (b))
#define mmax(a, b) a = max(a, (b))
#define mp(a,b) make_pair(a,b)
#define modsum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define modsubtract(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define modmultiply(a, b) (((a) * (b)) % M)
#define pb(a) push_back(a)
#define ALL(a) a.begin(),a.end()
#define sqr(x) (x) * (x)
#define fori(i, n) for(int i = 0; i < (int)(n); ++i)
#define cint const int &
#define SZ(a) ((int)(a.size()))
#define f(cnt) (((cnt) + 1) * (cnt) / 2)
#define watch(x) cout << (#x) << " = " << x << endl;
//#define log log10

const double PI = 2 * acos(0.0);

template<typename T>
struct edge {
    int from, to;
    T w;
    edge(int from, int to, T w): from(from), to(to), w(w) { }
    edge() { }
};

const ld EPS = 1e-9;

template<class T>
void show(T a) {
    for (auto x : a)
        cout << x << " ";
    cout << endl;
}

const int N = 2e5 + 9;
const ll oo = 1e18;
const int M = 1e9 + 7;

ld tw_double[N], ta_double[N];

inline void updw_double(int pos, ld w) {
    pos++;
    for (int i = pos; i < N; i += i&-i) {
        tw_double[i] += w;
    }
}

//void updw_double(int v, int tl, int tr, int pos, ld w) {
//    if (tl == tr) {
//        tw_double[v] = w;
//        return;
//    }
//    int tm = (tl + tr) >> 1;
//    if (pos <= tm) updw_double(v << 1, tl, tm, pos, w);
//    else updw_double(v << 1 | 1, tm + 1, tr, pos, w);
//    tw_double[v] = (tw_double[v << 1] + tw_double[v << 1 | 1]);
//}

inline void upda_double(int pos, ld a) {
    pos++;
    for (int i = pos; i < N; i += i&-i) {
        ta_double[i] += a;
    }
}

//void upda_double(int v, int tl, int tr, int pos, ld a) {
//    if (tl == tr) {
//        ta_double[v] = a;
//        return;
//    }
//    int tm = (tl + tr) >> 1;
//    if (pos <= tm) upda_double(v << 1, tl, tm, pos, a);
//    else upda_double(v << 1 | 1, tm + 1, tr, pos, a);
//    ta_double[v] = ta_double[v << 1] + ta_double[v << 1 | 1];
//}

ld getw_double(int l) {
    ld ret = 0;
    for (; l > 0; l -= l&-l) {
        ret += tw_double[l];
    }
    return ret;
}

ld getw_double(int l, int r) {
    ++r;
    if (l) return getw_double(r) - getw_double(l);
    return getw_double(r);
}

//ld getw_double(int v, int tl, int tr, int l, int r) {
//    if (l > r) return 0;
//    if (l == tl && r == tr) {
//        return tw_double[v];
//    }
//    int tm = (tl + tr) >> 1;
//    return
//            getw_double(v << 1, tl, tm, l, min(r, tm)) +
//            getw_double(v << 1 | 1, tm + 1, tr, max(tm + 1, l), r)
//            ;
//}

ld geta_double(int l) {
    ld ret = 0;
    for (; l > 0; l -= l&-l) {
        ret += ta_double[l];
    }
    return ret;
}

ld geta_double(int l, int r) {
    ++r;
    if (l) return geta_double(r) - geta_double(l);
    return geta_double(r);
}

//ld geta_double(int v, int tl, int tr, int l, int r) {
//    if (l > r) return 0;
//    if (tl == l && tr == r) {
//        return ta_double[v];
//    }
//    int tm = (tl + tr) >> 1;
//    return
//            geta_double(v << 1, tl, tm, l, min(tm, r)) +
//            geta_double(v << 1 | 1, tm + 1, tr, max(l, tm + 1), r)
//            ;
//}

int tw[N << 2], ta[N << 2];

void updw(int v, int tl, int tr, int pos, int w) {
    if (tl == tr) {
        tw[v] = w;
        return;
    }
    int tm = (tl + tr) >> 1;
    if (pos <= tm) updw(v << 1, tl, tm, pos, w);
    else updw(v << 1 | 1, tm + 1, tr, pos, w);
    tw[v] = modsum(tw[v << 1], tw[v << 1 | 1]);
}

void upda(int v, int tl, int tr, int pos, int a) {
    if (tl == tr) {
        ta[v] = a;
        return;
    }
    int tm = (tl + tr) >> 1;
    if (pos <= tm) upda(v << 1, tl, tm, pos, a);
    else upda(v << 1 | 1, tm + 1, tr, pos, a);
    ta[v] = modsum(ta[v << 1], ta[v << 1 | 1]);
}

int getw(int v, int tl, int tr, int l, int r) {
    if (l > r) return 0;
    if (l == tl && r == tr) {
        return tw[v];
    }
    int tm = (tl + tr) >> 1;
    int a = getw(v << 1, tl, tm, l, min(r, tm)), b = getw(v << 1 | 1, tm + 1, tr, max(tm + 1, l), r);
    return modsum(a, b);
}

int geta(int v, int tl, int tr, int l, int r) {
    if (l > r) return 0;
    if (tl == l && tr == r) {
        return ta[v];
    }
    int tm = (tl + tr) >> 1;
    int a = geta(v << 1, tl, tm, l, min(tm, r)), b = geta(v << 1 | 1, tm + 1, tr, max(l, tm + 1), r);
    return modsum(
            a, b
    );
}

int a[N];
int n, q;

inline int bins(int xl) {
    int l = -1, r = n;
    while (r - l > 1) {
        int m = (l + r) >> 1;
        if (xl + m - a[m] >= 0)
            l = m;
        else
            r = m;
    }
    return r;
}

inline ld get_double(ld x, int l, int r) {
    int pos = bins(x - l);
    return (getw_double(l, min(pos - 1, r)) - getw_double(max(l, pos), r)) * (x - l) + geta_double(l, min(pos - 1, r)) - geta_double(max(pos, l), r);
}

inline int get(int x, int l, int r) {
    int pos = bins(x - l);
    ll tmp = getw(1, 0, n - 1, l, min(pos - 1, r));
    int plus =  modmultiply(tmp, modsubtract(x, l));
    tmp = geta(1, 0, n - 1, l, min(pos - 1, r));
    plus = modsum(plus, tmp);
    tmp = getw(1, 0, n - 1, max(l, pos), r);
    int minus =  modmultiply(tmp, modsubtract(x, l));
    tmp = geta(1, 0, n - 1, max(pos, l), r);
    minus = modsum(minus, tmp);
    return modsubtract(plus, minus);
}

inline bool check(int x, int l, int r) {
    return  get_double(x, l, r) > get_double(x + 1, l, r);
}

int solve(int L, int R) {
    int l = -1, r = 1e9 + 9;
    while (r - l > 1) {
        int m = (l + r) >> 1;
        if (check(m, L, R))
            l = m;
        else
            r = m;

    }
    return get(r, L, R);
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

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

    fori (i, n) {
        int w;
        cin >> w;
        updw(1, 0, n - 1, i, w);
        upda(1, 0, n - 1, i, modmultiply((ll)w, modsubtract(i, a[i])));
        updw_double(i, w);
        upda_double(i, (ld) w * ((ld) i - (ld) a[i]));
    }

    while (q--) {
        int x, y;
        cin >> x >> y;
        if (x < 0) {
            x = -x - 1;
            updw(1, 0, n - 1, x, y);
            upda(1, 0, n - 1, x, modmultiply((ll)y, modsubtract(x, a[x])));
            updw_double(x, y);
            upda_double(x, (ld)y * ((ld)x - (ld) a[x]));
        } else {
            cout << solve(--x, --y) << "\n";
        }
    }
}

#include <bits/stdc++.h>

using namespace std;
#define IOS ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>

typedef long long ll;
const int maxn=200005;
const int mod=1000000007;
ll a[maxn],w[maxn];
int pos[maxn];
int n,q;
struct Bit{
    ll sum[maxn];
    int n;
    bool mod_flag;
    Bit(int n_){
        n=n_;
        mod_flag=true;
        memset(sum,0,sizeof sum);
    }
    void init(int n_,bool flag=true){
        n=n_;
        mod_flag=flag;
    }
    void add(int x,ll val){
        while(x<=n){
            sum[x]+=val;
            if(mod_flag)
            {
                if(sum[x]<0)sum[x]+=mod;
                if(sum[x]>=mod)sum[x]%=mod;
            }
            x+=x&-x;
        }
    }
    ll get(int x){
        ll res=0;
        while(x){
            res+=sum[x];
            if(mod_flag)
            {
                if(res>=mod)res%=mod;
            }
            x-=x&-x;
        }
        return res;
    }
    ll query(int l,int r){
        ll res=get(r)-get(l-1);
        if(mod_flag)
        {
            res=(res+mod)%mod;
        }
        return res;
    }
};
Bit bit1(maxn),bit2(maxn),bit3(maxn);
int main()
{
//    IOS;
    cin>>n>>q;
    int m=1e9;
    bit1.init(n,false);bit2.init(n);bit3.init(n);
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++){
        cin>>w[i];
        pos[i]=m-(n-i);
        bit1.add(i,w[i]);
        bit2.add(i,w[i]*(a[i]-i));
        bit3.add(i,w[i]*(pos[i]-a[i]));
    }
    while(q--){
        int x,y;
        cin>>x>>y;
        if(x<0){
            int id=-x;
            bit1.add(id,-w[id]);
            bit2.add(id,(a[id]-id)*(mod-w[id]));
            bit3.add(id,(pos[id]-a[id])*(mod-w[id]));
            w[id]=y;
            bit1.add(id,w[id]);
            bit2.add(id,(a[id]-id)*w[id]);
            bit3.add(id,(pos[id]-a[id])*w[id]);
        }else {
            ll res=bit1.get(y)-bit1.get(x-1);
            ll middlesum=res/2;
            int l=x,r=y,opt=-1;
            while(l<=r){
                int m=(l+r)>>1;
                if(bit1.get(m)-bit1.get(x-1)>middlesum)r=m-1,opt=m;
                else l=m+1;
            }
//            cout<<"opt:"<<x<<" "<<y<<" "<<opt<<endl;
            ll ans=0;
            if(opt<y){
                ll diff=a[opt]-opt;
                ll rsum=bit1.query(opt+1,y);
                ans=(ans+bit2.query(opt+1,y)-rsum*diff%mod+mod)%mod;
//                cout<<"ansr:"<<ans<<" "<<diff<<" "<<rsum<<endl;
            }
            if(opt>x){
                ll diff=pos[opt]-a[opt];
                ll lsum=bit1.query(x,opt-1);
                ans=(ans+bit3.query(x,opt-1)-lsum*diff%mod+mod)%mod;
//                cout<<"ansl:"<<ans<<" "<<diff<<" "<<lsum<<endl;
            }
            cout<<ans<<endl;
        }
    }
    return 0;
}