#include <bits/stdc++.h>
using namespace std;
const int mm = 1000000007;
struct data {
  long long s, v, w;
  void st(long long x, long long y, long long z) {
    s = x;
    v = y;
    w = z;
  }
};
struct tnode {
  int l, r, ls, rs;
  long long s, v, w;
} t[810001];
int tot, i, j, k, n, m, a[210001], b[210001], ans;
void mt(int l, int r) {
  int p = ++tot, m = (l + r) >> 1;
  t[p].l = l;
  t[p].r = r;
  if (l < r) {
    t[p].ls = tot + 1;
    mt(l, m);
    t[p].rs = tot + 1;
    mt(m + 1, r);
    t[p].s = t[t[p].ls].s + t[t[p].rs].s;
    t[p].v = (t[t[p].ls].v + t[t[p].rs].v) % mm;
    t[p].w = (t[t[p].ls].w + t[t[p].rs].w) % mm;
  } else
    t[p].ls = t[p].rs = 0, t[p].s = b[l],
    t[p].v = (long long)a[l] * (long long)b[l] % mm,
    t[p].w = (long long)l * (long long)b[l] % mm;
}
void change(int p, int x, int v) {
  if (!t[p].ls) {
    t[p].s = v;
    t[p].v = (long long)v * (long long)a[t[p].l] % mm;
    t[p].w = (long long)t[p].l * (long long)v % mm;
    return;
  }
  int m = (t[p].l + t[p].r) >> 1;
  change((x <= m) ? t[p].ls : t[p].rs, x, v);
  t[p].s = t[t[p].ls].s + t[t[p].rs].s;
  t[p].v = (t[t[p].ls].v + t[t[p].rs].v) % mm;
  t[p].w = (t[t[p].ls].w + t[t[p].rs].w) % mm;
}
data add(data a, data b) {
  data res;
  res.s = a.s + b.s;
  res.v = (a.v + b.v) % mm;
  res.w = (a.w + b.w) % mm;
  return res;
}
data query(int p, int l, int r) {
  data res;
  if (l <= t[p].l && t[p].r <= r) {
    res.st(t[p].s, t[p].v, t[p].w);
    return res;
  }
  int m = (t[p].l + t[p].r) >> 1;
  res.st(0, 0, 0);
  if (l <= m) res = query(t[p].ls, l, r);
  if (r > m) res = add(res, query(t[p].rs, l, r));
  return res;
}
int solve(int p, int l, int r, long long v) {
  data w;
  int m;
  while (t[p].ls) {
    m = (t[p].l + t[p].r) >> 1;
    if (r <= m) {
      p = t[p].ls;
      continue;
    }
    if (l > m) {
      p = t[p].rs;
      continue;
    }
    w = query(t[p].ls, l, r);
    if (w.s >= v)
      p = t[p].ls;
    else
      v -= w.s, p = t[p].rs;
  }
  return t[p].l;
}
int work(int l, int r) {
  long long i, j, k, res;
  data w, p, q;
  w = query(1, l, r);
  k = (w.s + 1) / 2;
  j = solve(1, l, r, k);
  p = query(1, l, j);
  if (j < r) {
    q = query(1, j + 1, r);
    res = (long long)a[j] * p.s - p.v;
    res = (res % mm + mm) % mm;
    res += q.v - (long long)a[j] * q.s;
    res = (res % mm + mm) % mm;
    res -= (p.s * (long long)j - p.w) % mm + (q.w - q.s * (long long)j) % mm;
    res = (res % mm + mm) % mm;
  } else {
    res = (long long)a[j] * p.s - p.v;
    res = (res % mm + mm) % mm;
    res -= (p.s * (long long)j - p.w) % mm;
    res = (res % mm + mm) % mm;
  }
  return res;
}
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n; i++) scanf("%d", &b[i]);
  tot = 0;
  mt(1, n);
  while (m--) {
    scanf("%d%d", &j, &k);
    if (j < 0) {
      change(1, -j, k);
    } else {
      ans = work(j, k);
      printf("%d\n", ans);
    }
  }
  return 0;
}
