#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5;
int n, q;
int a[maxn];
int w[maxn];
int pos[maxn];
long long sum[maxn * 4];
int sum2[maxn * 4];
const int mod = 1e9 + 7;
inline int Mul(int x, int y) { return (long long)x * y % mod; }
inline int Add(int x) { return x >= mod ? x - mod : x; }
inline int Sub(int x) { return x < 0 ? x + mod : x; }
inline void Update(int u) {
  sum[u] = sum[u << 1] + sum[u << 1 | 1];
  sum2[u] = sum2[u << 1] + sum2[u << 1 | 1];
}
void Build(int u, int l, int r) {
  if (r - l == 1) {
    sum[u] = w[l];
    sum2[u] = Mul(w[l], pos[l]);
    return;
  }
  int mid = l + r >> 1;
  Build(u << 1, l, mid);
  Build(u << 1 | 1, mid, r);
  Update(u);
}
void Modify(int u, int l, int r, int id, int nw) {
  if (r - l == 1) {
    sum[u] = w[id] = nw;
    sum2[u] = Mul(nw, pos[id]);
    return;
  }
  int mid = l + r >> 1;
  if (id < mid) {
    Modify(u << 1, l, mid, id, nw);
  } else {
    Modify(u << 1 | 1, mid, r, id, nw);
  }
  Update(u);
}
long long Sum(int u, int l, int r, int ql, int qr) {
  if (ql >= qr) return 0;
  if (l >= ql && r <= qr) {
    return sum[u];
  }
  long long ans = 0;
  int mid = l + r >> 1;
  if (ql < mid) ans += Sum(u << 1, l, mid, ql, qr);
  if (qr > mid) ans += Sum(u << 1 | 1, mid, r, ql, qr);
  return ans;
}
int Sum2(int u, int l, int r, int ql, int qr) {
  if (ql >= qr) return 0;
  if (l >= ql && r <= qr) {
    return sum2[u];
  }
  int ans = 0;
  int mid = l + r >> 1;
  if (ql < mid) ans = Add(ans + Sum2(u << 1, l, mid, ql, qr));
  if (qr > mid) ans = Add(ans + Sum2(u << 1 | 1, mid, r, ql, qr));
  return ans;
}
int GetValue(int l, int r, int mid) {
  int s1 = Sum2(1, 0, n, l, mid);
  int s2 = Sum2(1, 0, n, mid, r);
  int s3 = Sum(1, 0, n, l, mid);
  int s4 = Sum(1, 0, n, mid, r);
  int x = pos[mid];
  return Add(Sub(Mul(s3, x) - s1) + Sub(s2 - Mul(s4, x)));
}
int Find(int u, int l, int r, int ql, int qr, long long &s) {
  if (r - l == 1) {
    if (sum[u] >= s) return l;
    s -= sum[u];
    return -1;
  }
  int mid = l + r >> 1;
  if (ql <= l && qr >= r && s > sum[u]) {
    s -= sum[u];
    return -1;
  }
  if (ql < mid && qr > l) {
    int v = Find(u << 1, l, mid, ql, qr, s);
    if (v != -1) return v;
  }
  if (ql < r && qr > mid) {
    int v = Find(u << 1 | 1, mid, r, ql, qr, s);
    if (v != -1) return v;
  }
  return -1;
}
int main(void) {
  scanf("%d%d", &n, &q);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    pos[i] = a[i] - i;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", w + i);
  }
  Build(1, 0, n);
  while (q--) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x < 0) {
      int id = -x - 1, nw = y;
      Modify(1, 0, n, id, nw);
    } else {
      int l = x - 1, r = y;
      long long s = Sum(1, 0, n, l, r);
      s = s + 1 >> 1;
      int mid = Find(1, 0, n, l, r, s);
      int ans = GetValue(l, r, mid);
      printf("%d\n", ans);
    }
  }
  return 0;
}
