#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000020;
const int maxm = 1000020;
const int MOd = 1e9 + 7;
int a, ar[maxn], w[maxn], q;
long long fw[maxn];
int val[maxn][2];
int mul(int x, int y) { return (long long)x * y % MOd; }
int add(int a, int b) {
  a += b;
  a %= MOd;
  if (a < 0) a += MOd;
  return a;
}
void uval(int x, int y, int tp) {
  for (int i = x; i <= a; i += i & (-i)) val[i][tp] = add(val[i][tp], y);
}
long long fval(int l, int r, int tp) {
  long long ret = 0;
  for (int i = r; i > 0; i -= i & (-i)) ret = add(ret, val[i][tp]);
  for (int i = l - 1; i > 0; i -= i & (-i)) ret = add(ret, -val[i][tp]);
  return ret;
}
void up(int x, int y) {
  for (int i = x; i <= a; i += i & (-i)) fw[i] += y;
}
long long f(int l, int r) {
  long long ret = 0;
  for (int i = r; i > 0; i -= i & (-i)) ret += fw[i];
  for (int i = l - 1; i > 0; i -= i & (-i)) ret -= fw[i];
  return ret;
}
int main() {
  scanf("%d %d", &a, &q);
  for (int i = 1; i <= a; i++) {
    scanf("%d", &ar[i]);
  }
  for (int i = 1; i <= a; i++) {
    scanf("%d", &w[i]), up(i, w[i]);
    uval(i, mul(w[i], ar[i]), 0);
    uval(i, mul(w[i], i), 1);
  }
  while (q--) {
    int x, y;
    scanf("%d %d", &x, &y);
    if (x > 0) {
      int l = x, r = y, ans = 0;
      long long tot = f(x, y) / 2;
      while (l < r) {
        int m = (l + r) / 2;
        if (f(x, m) > tot)
          r = m;
        else
          l = m + 1;
      }
      ans = add(ans, add(mul(f(x, r) % MOd, ar[r]), -fval(x, r, 0)));
      ans = add(ans, -add(mul(f(x, r) % MOd, r), -fval(x, r, 1)));
      ans = add(ans, add(fval(r, y, 0), -mul(f(r, y) % MOd, ar[r])));
      ans = add(ans, -add(fval(r, y, 1), -mul(f(r, y) % MOd, r)));
      cout << ans << endl;
    } else {
      x = -x;
      up(x, y - w[x]);
      uval(x, mul(y - w[x], ar[x]), 0);
      uval(x, mul(y - w[x], x), 1);
      w[x] = y;
    }
  }
  return 0;
}
