#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
const int mod = 1e9 + 7;
long long n, q, a[N], w[N], BIT[2][N], BIT2[N];
void update(int idx, int pos, long long val) {
  for (pos; pos <= n; pos += (pos & -pos)) {
    BIT[idx][pos] += val;
  }
}
void update2(int pos, long long val) {
  for (pos; pos <= n; pos += (pos & -pos)) {
    BIT2[pos] = (BIT2[pos] + val) % mod;
  }
}
long long query(int idx, int pos) {
  long long res = 0;
  for (pos; pos; pos -= (pos & -pos)) {
    res += BIT[idx][pos];
  }
  return res;
}
long long query2(int pos) {
  long long res = 0;
  for (pos; pos; pos -= (pos & -pos)) {
    res = (res + BIT2[pos]) % mod;
  }
  return res;
}
long long get(int idx, int l, int r) {
  return query(idx, r) - query(idx, l - 1);
}
long long get2(int l, int r) {
  long long res = query2(r) - query2(l - 1) + mod;
  return res % mod;
}
long long solve(int k, int l, int r) {
  long long ans = 0,
            tmp = (get(1, k, r) % mod - (k * (get(0, k, r))) % mod + mod) % mod;
  ans = (get2(k, r) % mod - (a[k] * get(0, k, r)) % mod + mod) % mod;
  ans = (ans - tmp + mod) % mod;
  long long ans2 = ((a[k] * get(0, l, k)) % mod - get2(l, k) % mod + mod) % mod,
            tmp2 = 0, c = 0;
  for (int i = k; i >= l; i--) {
    tmp2 = (tmp2 + w[i] * c);
    c++;
  }
  tmp2 %= mod;
  ans2 = (ans2 - tmp2 + mod) % mod;
  return (ans + ans2) % mod;
}
int 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];
    update(0, i, w[i]);
    update(1, i, (w[i] * i));
    update2(i, a[i] * w[i]);
  }
  while (q--) {
    long long l, r, tmp;
    cin >> l >> r;
    if (l < 0) {
      int idx = -l;
      update(0, idx, -w[idx]);
      update(1, idx, -(idx * w[idx]));
      tmp = (a[idx] * w[idx]) / mod + 2;
      tmp = (-a[idx] * w[idx] + tmp * mod) % mod;
      update2(idx, tmp);
      w[idx] = r;
      update(0, idx, w[idx]);
      update(1, idx, (idx * w[idx]));
      update2(idx, (a[idx] * w[idx]) % mod);
    } else {
      long long lf = l, rt = r, mid, k = r, sum = get(0, lf, rt);
      while (lf <= rt) {
        mid = (lf + rt) / 2;
        if (2 * get(0, lf, mid) >= sum) {
          k = min(k, mid);
          rt = mid - 1;
        } else
          lf = mid + 1;
      }
      cout << solve(k, l, r) << '\n';
    }
  }
  return 0;
}
