#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10;
const long long mod = 1e9 + 7;
const long long oo = 1e9;
struct num {
  long long a, b;
} BIT[5][N];
long long n, q;
num a[N], w[N];
void add(num &x, num y) {
  x.a += y.a;
  x.b += y.b;
  x.a += x.b / mod;
  x.b %= mod;
}
void sub(num &x, num y) {
  x.a -= y.a;
  x.b -= y.b;
  while (x.b < 0) x.a--, x.b += mod;
}
bool cmp(num x, num y) {
  if (x.a != y.a) return x.a < y.a;
  return x.b < y.b;
}
num mul(num x, num y) {
  num res;
  res.a = (x.a * y.a + x.a * y.b + x.b * y.a);
  res.b = x.b * y.b;
  res.a += res.b / mod;
  res.b %= mod;
  return res;
}
void upd(long long base, long long pos, num val) {
  for (long long i = pos; i <= n; i += (i & -i)) add(BIT[base][i], val);
}
num getBIT(long long base, long long pos) {
  num res;
  res.a = res.b = 0;
  for (long long i = pos; i >= 1; i -= (i & -i)) add(res, BIT[base][i]);
  return res;
}
num get(long long base, long long l, long long r) {
  num res;
  res.a = res.b = 0;
  res = getBIT(base, r);
  sub(res, getBIT(base, l - 1));
  return res;
}
num calc(long long l, long long r, long long mid) {
  num sum = get(1, l, mid - 1);
  num sumaw = get(2, l, mid - 1);
  num suff = get(4, (n - mid + 2), n - l + 1);
  sub(suff, mul({0, n - mid + 1}, sum));
  sum = mul(sum, a[mid]);
  sub(sum, sumaw);
  sub(sum, suff);
  num sum1 = get(1, mid + 1, r);
  num sumaw1 = get(2, mid + 1, r);
  num suff1 = get(3, mid + 1, r);
  sub(suff1, mul({0, mid}, sum1));
  sum1 = mul(sum1, a[mid]);
  sub(sumaw1, sum1);
  sub(sumaw1, suff1);
  add(sum, sumaw1);
  return sum;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (long long i = 1; i <= n; ++i) cin >> a[i].b, a[i].a = 0;
  for (long long i = 1; i <= n; ++i) cin >> w[i].b, w[i].a = 0;
  for (long long i = 0; i <= n; ++i)
    for (long long j = 0; j <= 4; ++j) BIT[j][i].a = BIT[j][i].b = 0;
  for (long long i = 1; i <= n; ++i) {
    upd(1, i, w[i]);
    upd(2, i, mul(a[i], w[i]));
    upd(3, i, mul({0, i}, w[i]));
    upd(4, n - i + 1, mul({0, n - i + 1}, w[i]));
  }
  while (q--) {
    long long x, y;
    cin >> x >> y;
    if (x < 0) {
      x = -x;
      upd(1, x, {-w[x].a, -w[x].b});
      num tmp = mul(a[x], w[x]);
      upd(2, x, {-tmp.a, -tmp.b});
      tmp = mul({0, x}, w[x]);
      upd(3, x, {-tmp.a, -tmp.b});
      tmp = mul({0, n - x + 1}, w[x]);
      upd(4, n - x + 1, {-tmp.a, -tmp.b});
      w[x] = {0, y};
      upd(1, x, w[x]);
      upd(2, x, mul(a[x], w[x]));
      upd(3, x, mul({0, x}, w[x]));
      upd(4, n - x + 1, mul({0, n - x + 1}, w[x]));
    } else {
      long long l = x, r = y;
      for (long long i = 1; i <= 17; ++i) {
        long long mid1 = l + (r - l) / 3;
        long long mid2 = r - (r - l) / 3;
        if (cmp(calc(x, y, mid1), calc(x, y, mid2)))
          r = mid2;
        else
          l = mid1;
      }
      num res = calc(x, y, l);
      for (long long i = l; i <= r; ++i) {
        num tmp = calc(x, y, i);
        if (cmp(tmp, res)) res = tmp;
      }
      cout << (res.b + mod * mod) % mod << '\n';
    }
  }
}
