#include <bits/stdc++.h>
using namespace std;
int n;
long long mod = (long long)1e9 + 7;
vector<long long> a, w;
vector<long long> segTreeW, segTreeAW;
void build(int id, int l, int r) {
  if (l == r) {
    segTreeW[id] = w[l];
    segTreeAW[id] = w[l] * a[l] % mod;
  } else {
    int mid = (l + r) / 2;
    build(id * 2, l, mid);
    build(id * 2 + 1, mid + 1, r);
    segTreeW[id] = segTreeW[id * 2] + segTreeW[id * 2 + 1];
    segTreeAW[id] = (segTreeAW[id * 2] + segTreeAW[id * 2 + 1]) % mod;
  }
}
void build() {
  segTreeW.resize(n * 4 + 2517);
  segTreeAW.resize(n * 4 + 2517);
  build(1, 0, n - 1);
}
long long sumW(int id, int tl, int tr, int l, int r) {
  if (l > r) return 0;
  if (l == tl && r == tr) return segTreeW[id];
  int mid = (tl + tr) / 2;
  return sumW(id * 2, tl, mid, l, min(r, mid)) +
         sumW(id * 2 + 1, mid + 1, tr, max(l, mid + 1), r);
}
long long sumW(int l, int r) { return sumW(1, 0, n - 1, l, r); }
long long sumAW(int id, int tl, int tr, int l, int r) {
  if (l > r) return 0;
  if (l == tl && r == tr) return segTreeAW[id];
  int mid = (tl + tr) / 2;
  return (sumAW(id * 2, tl, mid, l, min(r, mid)) +
          sumAW(id * 2 + 1, mid + 1, tr, max(l, mid + 1), r)) %
         mod;
}
long long sumAW(int l, int r) { return sumAW(1, 0, n - 1, l, r); }
void upd(int id, int tl, int tr, int pos, long long nv) {
  if (tl == tr) {
    segTreeW[id] = w[pos] = nv;
    segTreeAW[id] = w[pos] * a[pos] % mod;
  } else {
    int tm = (tl + tr) / 2;
    if (pos <= tm)
      upd(id * 2, tl, tm, pos, nv);
    else
      upd(id * 2 + 1, tm + 1, tr, pos, nv);
    segTreeW[id] = segTreeW[id * 2] + segTreeW[id * 2 + 1];
    segTreeAW[id] = (segTreeAW[id * 2] + segTreeAW[id * 2 + 1]) % mod;
  }
}
void upd(int pos, long long nv) { upd(1, 0, n - 1, pos, nv); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int q;
  cin >> n >> q;
  a.resize(n);
  for (int(i) = 0; (i) < (n); (i)++) cin >> a[i], a[i] -= i;
  w.resize(n);
  for (int(i) = 0; (i) < (n); (i)++) cin >> w[i];
  build();
  for (int l, r; q-- > 0;) {
    cin >> l >> r;
    if (l < 0) {
      upd(-l - 1, r);
      continue;
    }
    long long sW = sumW(--l, --r);
    int lk = l - 1, mk, rk = r;
    while (lk + 1 < rk) {
      mk = (lk + rk) / 2;
      if (sumW(l, mk) * 2 >= sW)
        rk = mk;
      else
        lk = mk;
    }
    cout << (((sumW(l, rk - 1) % mod * a[rk] % mod + mod - sumAW(l, rk - 1)) %
                  mod +
              (sumAW(rk, r) + mod - sumW(rk, r) % mod * a[rk] % mod) % mod) %
             mod)
         << '\n';
  }
  return 0;
}
