#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   inline int add(int a, int b) {     if ((a += b) >= mod) a -= mod;     return a;   }   inline int mult(int a, int b) {     long long t = 1ll * a * b;     if (t >= mod) t %= mod;     return t;   }   inline int dec(int a, int b) {     if ((a -= b) < 0) a += mod;     return a;   }   int n, q, a[200010], w[200010];   inline int lowbit(int x) { return x & (-x); }   class tree1 {    public:     long long dat[200010];     void modify(int p, int v) {       for (; p <= n; p += lowbit(p)) dat[p] += v;     }     long long query(int p) {       long long ret = 0;       for (; p; p -= lowbit(p)) ret += dat[p];       return ret;     }     long long query(int l, int r) { return query(r) - query(l - 1); }   } T1;   class tree2 {    public:     int dat[200010];     void modify(int p, int v) {       for (; p <= n; p += lowbit(p)) dat[p] = add(dat[p], v);     }     int query(int p) {       int ret = 0;       for (; p; p -= lowbit(p)) ret = add(ret, dat[p]);       return ret;     }     int query(int l, int r) { return dec(query(r), query(l - 1)); }   } T2;   int x, y;   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]);       T1.modify(i, w[i]);       T2.modify(i, mult(w[i], a[i] - i));     }     while (q--) {       scanf( %d%d , &x, &y);       if (x < 0) {         x = -x;         T1.modify(x, y - w[x]);         T2.modify(x, mult(dec(y, w[x]), a[x] - x));         w[x] = y;       } else {         if (x == y) {           puts( 0 );           continue;         }         int L = x, R = y, pos = L;         while (L <= R) {           int mid = (L + R) >> 1;           if (T1.query(x, mid) >= T1.query(mid + 1, y))             pos = mid, R = mid - 1;           else             L = mid + 1;         }         printf( %d n , add(dec(mult(a[pos] - pos, T1.query(x, pos) % mod),                                T2.query(x, pos)),                            dec(T2.query(pos, y),                                mult(a[pos] - pos, T1.query(pos, y) % mod))));       }     }     return 0;   }   