#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5 + 11, mol = 1e9 + 7;
typedef int i_N[maxN];
typedef long long l_N[maxN];
int N, Q;
i_N A, W;
l_N sum, fwi, bwi, wa;
void update(long long* bit, int x, int v) {
  for (int i = x; i <= N; i |= i + 1) bit[i] = (bit[i] + v) % mol;
}
long long get_bit(long long* bit, int x) {
  long long res = 0;
  for (int i = x; i >= 1; i = (i & (i + 1)) - 1) res = (res + bit[i]) % mol;
  return res;
}
long long get_bit(long long* bit, int l, int r) {
  return (get_bit(bit, r) - get_bit(bit, l - 1)) % mol;
}
long long cal(int l, int r, int x) {
  long long t1 = get_bit(sum, l, x) * A[x] - get_bit(wa, l, x);
  t1 %= mol;
  t1 -= get_bit(bwi, l, x) - get_bit(sum, l, x) * (N - x + 1);
  t1 %= mol;
  if (x < r) {
    long long t2 = get_bit(wa, x + 1, r) - get_bit(sum, x + 1, r) * A[x + 1];
    t2 %= mol;
    t2 -= get_bit(fwi, x + 1, r) - get_bit(sum, x + 1, r) * (x + 1);
    t2 %= mol;
    return (t1 + t2 + get_bit(sum, x + 1, r) * (A[x + 1] - A[x] - 1)) % mol;
  }
  return t1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> N >> Q;
  for (int i = 1; i <= N; i++) cin >> A[i];
  for (int i = 1; i <= N; i++) cin >> W[i];
  for (int i = 1; i <= N; i++) {
    update(sum, i, W[i]);
    update(fwi, i, long long(i) * W[i] % mol);
    update(bwi, i, long long(N - i + 1) * W[i] % mol);
    update(wa, i, long long(A[i]) * W[i] % mol);
  }
  for (int i = 1; i <= Q; i++) {
    int l, r;
    cin >> l >> r;
    if (l < 0) {
      l *= -1;
      update(sum, l, -W[l] + r);
      update(fwi, l, long long(l) * (-W[l] + r) % mol);
      update(bwi, l, long long(N - l + 1) * (-W[l] + r) % mol);
      update(wa, l, long long(-W[l] + r) * A[l] % mol);
      W[l] = r;
    } else {
      long long S = get_bit(sum, l, r);
      int a = l, b = r;
      do {
        int mid = (a + b) / 2;
        if (get_bit(sum, l, mid) * 2 >= S)
          b = mid;
        else
          a = mid + 1;
      } while (a < b);
      long long ans = cal(l, r, a);
      if (ans < 0) ans += mol;
      cout << ans << '\n';
    }
  }
}
