#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 50;
const long long mod = 1e9 + 7;
struct Bit {
  long long a[N];
  int vis[N], cur;
  Bit() {
    cur = 1;
    memset(vis, 0, sizeof vis);
  }
  inline void Init() { cur++; }
  inline void Add(int p, long long v) {
    for (; p < N; p += (p & (-p))) {
      if (vis[p] == cur)
        a[p] += v;
      else
        vis[p] = cur, a[p] = v;
    }
  }
  inline long long Sum(int p) {
    long long res = 0;
    for (; p > 0; p -= (p & (-p)))
      if (vis[p] == cur) res += a[p];
    return res;
  }
  inline long long Sum(int l, int r) {
    if (l > r) return 0;
    return Sum(r) - Sum(l - 1);
  }
} prefix, wei;
int n, q, a[N], p[N], tab[N], w[N], sumx[N];
inline long long mov(int L, int R, int mid) {
  long long ans = 0;
  ans = (1ll * a[mid] * (prefix.Sum(L, mid) % mod) % mod -
         wei.Sum(L, mid) % mod) %
        mod;
  ans += (wei.Sum(mid + 1, R) -
          1ll * a[mid] * (prefix.Sum(mid + 1, R) % mod) % mod) %
         mod;
  return (ans % mod + mod) % mod;
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    tab[i] = a[i];
  }
  sort(tab + 1, tab + n + 1);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &w[i]);
    p[i] = lower_bound(tab + 1, tab + n + 1, a[i]) - tab;
    prefix.Add(p[i], w[i]);
    a[i] -= i - 1;
    wei.Add(p[i], 1ll * w[i] * a[i] % mod);
  }
  for (int x, y; q; q--) {
    scanf("%d%d", &x, &y);
    if (x < 0) {
      x = -x;
      prefix.Add(p[x], y - w[x]);
      wei.Add(p[x], 1ll * (y - w[x]) * a[x] % mod);
      w[x] = y;
    } else {
      int L = x, R = y, mid, res = L;
      long long tot = prefix.Sum(x, y);
      while (L <= R) {
        mid = (L + R) >> 1;
        if (prefix.Sum(x, mid) * 2 >= tot)
          R = mid - 1, res = mid;
        else
          L = mid + 1;
      }
      printf("%lld\n", mov(x, y, res));
    }
  }
  return 0;
}
