#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7;
int n, q, tmp[N], a[N], b[N], w[N], val[N];
int lowbit(int x) { return x & -x; }
struct BITs {
  int c[N];
  void ins(int x, int v) {
    for (; x <= n; x += lowbit(x)) c[x] += v;
  }
  long long query(int x) {
    long long ret = 0;
    for (; x; x -= lowbit(x)) ret += c[x];
    return ret;
  }
  long long calc(int l, int r) { return query(r) - query(l - 1); }
} tr1;
struct BITssum {
  int c[N];
  void ins(int x, int v) {
    for (; x <= n; x += lowbit(x)) c[x] = (c[x] + v) % mod;
  }
  int query(int x) {
    int ret = 0;
    for (; x; x -= lowbit(x)) ret = (ret + c[x]) % mod;
    return ret;
  }
  int calc(int l, int r) { return (query(r) - query(l - 1)) % mod; }
} tr2;
bool check(int x, int l, int r, int mid, long long sum) {
  if (tr1.query(mid) - tr1.query(l - 1) >= (sum + 1) / 2) return 1;
  return 0;
}
int solve(int L, int R) {
  long long cnt = tr1.calc(L, R);
  int l = 1, r = n, best = n;
  while (l <= r) {
    int mid = l + r >> 1;
    if (check(mid, L, R, mid, cnt))
      best = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  int ans = 0;
  ans = (ans + (1ll * tr1.calc(L, best - 1) * val[best] % mod -
                tr2.calc(L, best - 1)) %
                   mod) %
        mod;
  ans = (ans + (tr2.calc(best + 1, R) -
                1ll * tr1.calc(best + 1, R) * val[best] % mod) %
                   mod) %
        mod;
  return (ans + mod) % mod;
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), tmp[i] = a[i];
  sort(tmp + 1, tmp + n + 1);
  for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
  for (int i = 1; i <= n; i++) {
    b[i] = lower_bound(tmp + 1, tmp + n + 1, a[i]) - tmp, val[i] = a[i] - i;
    tr1.ins(b[i], w[i]);
    tr2.ins(b[i], 1ll * w[i] * val[i] % mod);
  }
  while (q--) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x < 0) {
      x = -x;
      tr1.ins(b[x], -w[x]), tr2.ins(b[x], -1ll * w[x] * val[x] % mod);
      w[x] = y;
      tr1.ins(b[x], w[x]), tr2.ins(b[x], 1ll * w[x] * val[x] % mod);
    } else
      printf("%d\n", solve(x, y));
  }
  return 0;
}
