#include <bits/stdc++.h>
using namespace std;
long long inline read() {
  long long num = 0, neg = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') neg = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    num = (num << 3) + (num << 1) + c - '0';
    c = getchar();
  }
  return num * neg;
}
const long long maxn = 200010, mod = 1e9 + 7, M = 1e9;
long long n, q, a[maxn], w[maxn];
long long sum[maxn * 40], ls[maxn * 40], rs[maxn * 40], tot, rt, cnt[maxn * 40];
void update(long long &x, long long l, long long r, long long pos, long long I,
            long long k) {
  if (!x) x = ++tot;
  if (l == r) {
    sum[x] = k;
    cnt[x] = (pos - I) * k;
    return;
  }
  long long mid = l + r >> 1;
  if (pos <= mid) update(ls[x], l, mid, pos, I, k);
  if (pos > mid) update(rs[x], mid + 1, r, pos, I, k);
  sum[x] = sum[ls[x]] + sum[rs[x]];
  cnt[x] = cnt[ls[x]] + cnt[rs[x]];
}
long long Query(long long x, long long l, long long r, long long L, long long R,
                long long id) {
  if (L > R) return 0;
  if (!x) return 0;
  if (l >= L && r <= R) {
    if (id == 1) return sum[x];
    return cnt[x];
  }
  long long mid = l + r >> 1, ans = 0;
  if (mid >= L) ans += Query(ls[x], l, mid, L, R, id);
  if (mid < R) ans += Query(rs[x], mid + 1, r, L, R, id);
  return ans;
}
signed main() {
  n = read();
  q = read();
  for (long long i = 1; i <= n; i++) a[i] = read();
  for (long long i = 1; i <= n; i++) w[i] = read();
  for (long long i = 1; i <= n; i++) update(rt, 1, M, a[i], i, w[i]);
  for (long long i = 1; i <= q; i++) {
    long long l = read(), r = read();
    if (l <= 0) {
      l = -l;
      update(rt, 1, M, a[l], l, r);
      w[l] = r;
    } else {
      if (l == r) {
        cout << 0 << endl;
        continue;
      }
      long long L = l, R = r, ans = 0, res;
      while (L <= R) {
        long long mid = L + R >> 1;
        if (Query(rt, 1, M, a[l], a[mid], 1) >=
            Query(rt, 1, M, a[mid + 1], a[r], 1))
          res = mid, R = mid - 1;
        else
          L = mid + 1;
      }
      L = res;
      ans = (Query(rt, 1, M, a[l], a[L], 1) * (a[L] - L) % mod -
             Query(rt, 1, M, a[l], a[L], 0) % mod + mod) %
            mod;
      ans = ((ans + Query(rt, 1, M, a[L + 1], a[r], 0) % mod) % mod -
             Query(rt, 1, M, a[L + 1], a[r], 1) * (a[L] - L) % mod + mod) %
            mod;
      cout << ans << endl;
    }
  }
  return 0;
}
