#include <bits/stdc++.h>
using namespace std;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long double PI = 4 * atan((long double)1);
long long a[200005], w[200005];
struct bit {
  vector<long long> arr;
  long long n;
  bit(long long _n) : n(_n) { arr.assign(n + 5, 0); }
  void upd(long long x, long long val) {
    while (x <= n) {
      arr[x] += val;
      x += x & -x;
    }
  }
  long long get(long long x, long long mod) {
    long long re = 0;
    while (x) {
      if (mod)
        re = (re + arr[x]) % MOD;
      else
        re = re + arr[x];
      x -= x & -x;
    }
    return re;
  }
} FW1(1), FW2(1);
void solve1(long long x, long long y) {
  FW1.upd(x, y - w[x]);
  FW2.upd(x, (a[x] * (y - w[x])) % MOD);
  w[x] = y;
}
void solve2(long long l, long long r) {
  long long pref = FW1.get(l - 1, 0), tot = FW1.get(r, 0) - pref;
  long long ll = l, rr = r;
  while (ll < rr) {
    long long mid = (ll + rr) / 2;
    if (FW1.get(mid, 0) - pref >= (tot + 1) / 2)
      rr = mid;
    else
      ll = mid + 1;
  }
  long long med = ll, ans = 0;
  if (med > l) {
    long long t = FW1.get(med - 1, 0) - FW1.get(l - 1, 0);
    long long s = (FW2.get(med - 1, 1) - FW2.get(l - 1, 1)) % MOD;
    ans = (ans + t * a[med] % MOD - s) % MOD;
  }
  if (med < r) {
    long long t = FW1.get(r, 0) - FW1.get(med, 0);
    long long s = (FW2.get(r, 1) - FW2.get(med, 1)) % MOD;
    ans = (ans + s - t * a[med] % MOD) % MOD;
  }
  while (ans < 0) ans += MOD;
  cout << ans << endl;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, q;
  cin >> n >> q;
  FW1 = FW2 = bit(n);
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= n; i++) cin >> w[i];
  for (long long i = 1; i <= n; i++) {
    a[i] = a[i] - i + 1;
    FW1.upd(i, w[i]);
    FW2.upd(i, w[i] * a[i]);
  }
  while (q--) {
    long long x, y;
    cin >> x >> y;
    if (x < 0)
      solve1(-x, y);
    else
      solve2(x, y);
  }
}
