#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int inf = 1e9;
int a[200005], w[200005];
struct ft1 {
  long long ft[200005];
  void update(int i, long long v) {
    for (; i <= 200000; i += (i & -i)) ft[i] = (ft[i] + v + mod) % mod;
  }
  long long query(int i) {
    long long res = 0;
    for (; i > 0; i -= (i & -i)) res = (res + ft[i]) % mod;
    return res;
  }
} ft[2];
struct ft2 {
  long long ft[200005];
  void update(int i, long long v) {
    for (; i <= 200000; i += (i & -i)) ft[i] += v;
  }
  long long query(int i) {
    long long res = 0;
    for (; i > 0; i -= (i & -i)) res += ft[i];
    return res;
  }
} ft2;
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), a[i] -= i;
  for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
  for (int i = 1; i <= n; i++) {
    ft[0].update(i, a[i] * 1ll * w[i] % mod);
    ft[1].update(i, (inf - a[i]) * 1ll * w[i] % mod);
    ft2.update(i, w[i]);
  }
  for (int i = 1; i <= q; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    if (l < 0) {
      l = -l;
      ft[0].update(l, -a[l] * 1ll * w[l] % mod);
      ft[1].update(l, -(inf - a[l]) * 1ll * w[l] % mod);
      ft2.update(l, -w[l]);
      w[l] = r;
      ft[0].update(l, a[l] * 1ll * w[l] % mod);
      ft[1].update(l, (inf - a[l]) * 1ll * w[l] % mod);
      ft2.update(l, w[l]);
    } else {
      long long sum = ft2.query(r) - ft2.query(l - 1);
      int lo = l, hi = r, res;
      while (lo <= hi) {
        int mid = (lo + hi) / 2;
        if ((ft2.query(mid) - ft2.query(l - 1)) * 2 >= sum)
          res = mid, hi = mid - 1;
        else
          lo = mid + 1;
      }
      long long ans = 0;
      ans = (ans + (ft[1].query(res) - ft[1].query(l - 1) + mod)) % mod;
      ans = (ans + (ft[0].query(r) - ft[0].query(res) + mod)) % mod;
      ans = (ans -
             (ft2.query(res) - ft2.query(l - 1)) % mod * 1ll * (inf - a[res]) %
                 mod +
             mod) %
            mod;
      ans = (ans - (ft2.query(r) - ft2.query(res)) % mod * 1ll * a[res] % mod +
             mod) %
            mod;
      printf("%lld\n", ans);
    }
  }
}
