#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7;
long long n, Q;
long long a[N], w[N], c1[N], c2[N];
struct node {
  long long c[N];
  void add(long long x, long long v) {
    for (; x <= n; x += ((x) & (-(x)))) c[x] += v;
  }
  long long ask(long long x) {
    long long ret = 0;
    for (; x; x -= ((x) & (-(x)))) ret += c[x];
    return ret % mod;
  }
} A, B;
void task1(long long id, long long v) {
  A.add(id, -w[id]);
  B.add(id, -1ll * w[id] * a[id] % mod);
  w[id] = v;
  A.add(id, w[id]);
  B.add(id, 1ll * w[id] * a[id] % mod);
}
long long task2(long long L, long long R) {
  long long tmp = A.ask(L - 1);
  long long sum = A.ask(R) - tmp;
  long long l = L, r = R, pos, ret = 0;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    long long val = A.ask(mid) - tmp;
    if (val * 2 >= sum)
      r = mid - 1, pos = mid;
    else
      l = mid + 1;
  }
  long long a1 = 1ll * (A.ask(pos) - tmp + mod) % mod * a[pos] % mod;
  long long a2 = 1ll * (B.ask(pos) - B.ask(L - 1) + mod) % mod;
  long long a3 = 1ll * (A.ask(R) - A.ask(pos) + mod) % mod * a[pos] % mod;
  long long a4 = 1ll * (B.ask(R) - B.ask(pos) + mod) % mod;
  ret = a4 - a3 + a1 - a2;
  return (ret % mod + mod) % mod;
}
int main() {
  cin >> n >> Q;
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]), a[i] += -i + n;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &w[i]);
    A.add(i, w[i]);
    B.add(i, 1ll * w[i] * a[i] % mod);
  }
  while (Q--) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x < 0)
      task1(-x, y);
    else
      printf("%lld\n", task2(x, y));
  }
  return 0;
}
