#include <bits/stdc++.h>
using namespace std;
long long a[(long long)1e6], w[(long long)1e6];
const long long maxn = 100100;
const long long mod = 1e9 + 7;
long long tree[maxn << 2], tree2[maxn << 2], tree3[maxn << 2];
long long n;
inline void add(long long r, long long v) {
  while (r <= n) tree[r] += v, r += r & -r;
}
inline long long query(long long r) {
  long long ans = 0;
  while (r) ans += tree[r], r &= r - 1;
  return ans;
}
inline long long query(long long l, long long r) {
  return query(r) - query(l - 1);
}
inline void add1(long long r, long long v) {
  while (r <= n) (tree2[r] += v) %= mod, r += r & -r;
}
inline long long query1(long long r) {
  long long ans = 0;
  while (r) (ans += tree2[r]) %= mod, r &= r - 1;
  return ans;
}
inline long long query1(long long l, long long r) {
  return query1(r) - query1(l - 1);
}
inline void add2(long long r, long long v) {
  while (r <= n) (tree3[r] += v) %= mod, r += r & -r;
}
inline long long query2(long long r) {
  long long ans = 0;
  while (r) (ans += tree3[r]) %= mod, r &= r - 1;
  return ans;
}
inline long long query2(long long l, long long r) {
  return query2(r) - query2(l - 1);
}
inline long long move_1(long long l, long long r, long long pos) {
  long long len = r - l + 1;
  return pos * (query(l, r) % mod) % mod + query2(l, r) -
         query(l, r) * l % mod - query1(l, r);
}
inline long long move_2(long long l, long long r, long long pos) {
  long long 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);
  long long q;
  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];
    add(i, w[i]);
    add1(i, a[i] * w[i] % mod);
    add2(i, (i)*w[i] % mod);
  }
  while (q--) {
    long long 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 {
      long long l = x, r = y;
      while (l != r) {
        long long 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;
    }
  }
}
