#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
pair<double, long long> operator+(pair<double, long long> a,
                                  pair<double, long long> b) {
  return make_pair(a.first + b.first, (a.second + b.second) % MOD);
}
struct seg {
  double to_cmp = 0;
  long long sum = 0;
  seg *ch[2] = {nullptr, nullptr};
  int l, r, m;
  void pull() {
    (sum = ch[0]->sum + ch[1]->sum) %= MOD;
    to_cmp = ch[0]->to_cmp + ch[1]->to_cmp;
  }
  seg(int l, int r, vector<long long> &A) : l(l), r(r) {
    if (r - l > 1) {
      m = l + r >> 1;
      ch[0] = new seg(l, m, A);
      ch[1] = new seg(m, r, A);
      pull();
    } else
      to_cmp = sum = A[l], sum = (sum % MOD + MOD) % MOD;
  }
  void modify(int x, long long val) {
    if (r - l == 1)
      return to_cmp = sum = val, sum = (sum % MOD + MOD) % MOD, void();
    if (x < m) ch[0]->modify(x, val);
    if (m <= x) ch[1]->modify(x, val);
    pull();
  }
  pair<double, long long> query(int L, int R) {
    if (L >= R) return {0., 0ll};
    if (L <= l and r <= R) return {to_cmp, sum};
    pair<double, long long> ans = make_pair(0., 0ll);
    if (L < m) ans = ans + ch[0]->query(L, R);
    if (m < R) ans = ans + ch[1]->query(L, R);
    return ans;
  }
};
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  vector<long long> w(n), wr(n), a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> w[i], wr[i] = w[i] * (i - a[i]);
  seg *wrT = new seg(0, n, wr), *wT = new seg(0, n, w);
  auto askd = [&](int l, int r, int m) {
    return (a[m] - m) * wT->query(l, r).first + wrT->query(l, r).first;
  };
  auto askL = [&](int l, int r, int m) {
    return ((a[m] - m) * wT->query(l, r).second + wrT->query(l, r).second) %
           MOD;
  };
  auto queryL = [&](int l, int r, int m) {
    long long ans = askL(l, m, m) - askL(m, r, m);
    return (ans % MOD + MOD) % MOD;
  };
  auto queryd = [&](int l, int r, int m) {
    return askd(l, m, m) - askd(m, r, m);
  };
  while (q--) {
    long long m = 0, l, r;
    cin >> l >> r;
    if (l < 0)
      l = -l - 1, wT->modify(l, r), wrT->modify(l, r * (l - a[l]));
    else {
      --l;
      int ml = l, mr = r;
      while (mr - ml > 1) {
        m = 1 + mr + ml >> 1;
        if (queryd(l, r, m) - queryd(l, r, m - 1) >= 0)
          mr = m;
        else
          ml = m;
      }
      if (queryd(l, r, m) > queryd(l, r, m - 1))
        cout << queryL(l, r, m - 1) << '\n';
      else
        cout << queryL(l, r, m) << '\n';
    }
  }
}
