#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f, mod = 1000000007;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const double pi = acosl(-1.), eps = 1e-9;
inline int power(int a, int b, int m = mod, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
const int NN = 202020;
long long a[NN], w[NN];
int aw[NN];
int sw[NN];
long long W[NN];
void upaw(int u, int d) {
  if (d < 0) d += mod;
  for (; u < NN; u += u & -u) {
    aw[u] += d;
    if (aw[u] >= mod) aw[u] -= mod;
  }
}
void upsw(int u, int d) {
  if (d < 0) d += mod;
  for (; u < NN; u += u & -u) {
    sw[u] += d;
    if (sw[u] >= mod) sw[u] -= mod;
  }
}
void upW(int u, long long d) {
  for (; u < NN; u += u & -u) W[u] += d;
}
int caaw(int u, int ans = 0) {
  for (; u; u -= u & -u) {
    ans += aw[u];
    if (ans >= mod) ans -= mod;
  }
  return ans;
}
int casw(int u, int ans = 0) {
  for (; u; u -= u & -u) {
    ans += sw[u];
    if (ans >= mod) ans -= mod;
  }
  return ans;
}
long long caW(int u, long long ans = 0) {
  for (; u; u -= u & -u) ans += W[u];
  return ans;
}
int nam(int L, int R, int id) {
  long long lft = caW(id - 1) - caW(L - 1);
  long long rgt = caW(R) - caW(id);
  if (lft == rgt) return 0;
  if (lft < rgt) return -1;
  if (lft > rgt) return 1;
}
inline void sum(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
inline void sub(int &a, int b) {
  a += b;
  if (a < 0) a += mod;
}
int calc(int L, int R, int id) {
  long long ans = 0;
  ans += caaw(R) - caaw(id - 1);
  ans += (id - a[id]) * ((caW(R) - caW(id - 1)) % mod) % mod;
  ans -= casw(R) - casw(id - 1);
  ans += (a[id] - id) * ((caW(id) - caW(L - 1)) % mod) % mod;
  ans -= caaw(id) - caaw(L - 1);
  ans += casw(id) - casw(L - 1);
  ans %= mod;
  if (ans < 0) ans += mod;
  return ans;
}
int main() {
  int n, T;
  cin >> n >> T;
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i <= n; i++) {
    scanf("%d", w + i);
    upaw(i, (int)((long long)a[i] * w[i] % mod));
    upsw(i, (int)((long long)i * w[i] % mod));
    upW(i, w[i]);
  }
  int L, R;
  while (T--) {
    scanf("%d%d", &L, &R);
    if (L < 0) {
      L = -L;
      upaw(L, (int)(((long long)a[L] * R - (long long)a[L] * w[L]) % mod));
      upsw(L, ((long long)L * R - (long long)L * w[L]) % mod);
      upW(L, R - w[L]);
      w[L] = R;
      continue;
    }
    int st = L, ed = R + 1, md1, md2;
    int d, d0;
    while (st + 2 < ed) {
      md1 = ((st << 1) + ed) / 3;
      md2 = (st + (ed << 1)) / 3;
      d = nam(L, R, md1);
      if (d < 0) {
        st = md1;
        continue;
      }
      if (d > 0) {
        ed = md2;
        continue;
      }
      d = nam(L, R, md2);
      if (d < 0) {
        st = md1;
        continue;
      }
      if (d > 0) {
        ed = md2;
        continue;
      }
      ed = md2;
    }
    long long lft = caW(st - 1) - caW(L - 1);
    long long rgt = caW(R) - caW(st);
    if (lft + w[st] - rgt < 0) st++;
    printf("%d\n", calc(L, R, st));
  }
  return 0;
}
