#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5000;
const long double eps = (1e-12);
const int logn = 21;
const double Pi = acos(-1.0);
const long long pp = 1000000000 + 7;
int lowbit(int x) { return x & (-x); }
const long long INF = 1e9;
long long nums[MAXN];
long long w[MAXN];
long long n, q;
struct node {
  long long sum;
  long long l;
  long long r;
};
node tree[(MAXN << 2) + 5];
inline long long lk(long long p) { return p << 1; }
inline long long rk(long long p) { return (p << 1) | 1; }
long long tag[(MAXN << 2) + 5];
inline void push_up(long long p) {
  tree[p].sum = tree[lk(p)].sum + tree[rk(p)].sum;
}
inline void build(long long p, long long l, long long r) {
  tag[p] = 0;
  tree[p].l = l;
  tree[p].r = r;
  if (l == r) {
    tree[p].sum = w[l];
    return;
  }
  long long mid = (l + r) >> 1;
  build(lk(p), l, mid);
  build(rk(p), mid + 1, r);
  push_up(p);
}
inline void f(long long p, long long l, long long r, long long k) {
  tag[p] = tag[p] + k;
  tree[p].sum = tree[p].sum + k * (r - l + 1);
}
inline void push_down(long long p, long long l, long long r) {
  long long mid = (l + r) >> 1;
  f(lk(p), l, mid, tag[p]);
  f(rk(p), mid + 1, r, tag[p]);
  tag[p] = 0;
}
inline void update(long long nl, long long nr, long long l, long long r,
                   long long p, long long k) {
  if (nl <= l && r <= nr) {
    f(p, l, r, k);
    return;
  }
  push_down(p, l, r);
  long long mid = (l + r) >> 1;
  if (nl <= mid) update(nl, nr, l, mid, lk(p), k);
  if (nr > mid) update(nl, nr, mid + 1, r, rk(p), k);
  push_up(p);
}
inline long long querySum(long long nl, long long nr, long long l, long long r,
                          long long p) {
  if (nr < nl) return 0;
  long long ans = 0;
  if (nl <= l && r <= nr) return tree[p].sum;
  long long mid = (l + r) >> 1;
  push_down(p, l, r);
  if (nl <= mid) ans += querySum(nl, nr, l, mid, lk(p));
  if (nr > mid) ans += querySum(nl, nr, mid + 1, r, rk(p));
  return ans;
}
inline long long queryIdx(long long l, long long r, long long p, long long &tar,
                          long long liml, long long limr) {
  if (liml <= l && r <= limr) {
    if (tree[p].sum < tar) {
      tar -= tree[p].sum;
      return -1;
    }
  }
  if (l == r) {
    if (tree[p].sum >= tar)
      return l;
    else
      tar -= tree[p].sum;
    return -1;
  }
  long long mid = (l + r) >> 1;
  push_down(p, l, r);
  long long ans = -1;
  if (mid < liml) {
    if (tree[rk(p)].sum >= tar)
      ans = queryIdx(mid + 1, r, rk(p), tar, liml, limr);
  } else if (mid >= limr) {
    if (tree[lk(p)].sum >= tar) ans = queryIdx(l, mid, lk(p), tar, liml, limr);
  } else {
    ans = queryIdx(l, mid, lk(p), tar, liml, limr);
    if (ans == -1) {
      ans = queryIdx(mid + 1, r, rk(p), tar, liml, limr);
    }
  }
  return ans;
}
struct BIT {
  long long S[MAXN] = {}, n = 0;
  void init(long long x) {
    this->n = x;
    for (long long i = 0; i <= n; i++) S[i] = 0;
  }
  void del(long long x) {
    for (long long i = x; i <= n; i += (i & -i)) S[i] = 0;
  }
  void add(long long x, long long v) {
    for (long long i = x; i <= n; i += (i & -i)) {
      S[i] += v;
      S[i] = ((((S[i]) % pp) + pp) % pp);
    }
    return;
  }
  long long ask(long long x) {
    if (x == 0) return 0;
    long long res = 0;
    for (long long i = x; i >= 1; i -= (i & -i)) {
      res += S[i];
      res %= pp;
    }
    return res;
  }
};
BIT bits[3];
signed main() {
  scanf("%lld%lld", &n, &q);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &nums[i]);
  }
  bits[0].init(n);
  bits[1].init(n);
  bits[2].init(n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &w[i]);
    bits[0].add(i, w[i]);
    bits[1].add(i, w[i] * nums[i] % pp);
    bits[2].add(i, w[i] * i % pp);
  }
  build(1, 1, n);
  while (q--) {
    long long x, y;
    scanf("%lld%lld", &x, &y);
    if (x > 0) {
      long long sum = querySum(x, y, 1, n, 1);
      sum = (sum + 1) / 2;
      long long ans = queryIdx(1, n, 1, sum, x, y);
      long long l = x;
      long long anss = 0;
      if (l < ans) {
        anss += ((((nums[ans] * (bits[0].ask(ans - 1) - bits[0].ask(l - 1)) -
                    (bits[1].ask(ans - 1) - bits[1].ask(l - 1))) %
                   pp) +
                  pp) %
                 pp);
        anss -= (((((ans) * (bits[0].ask(ans - 1) - bits[0].ask(l - 1)) -
                    (bits[2].ask(ans - 1) - bits[2].ask(l - 1))) %
                   pp) +
                  pp) %
                 pp);
      }
      long long r = y;
      if (y > ans) {
        anss += (((((bits[1].ask(r) - bits[1].ask(ans)) -
                    nums[ans] * (bits[0].ask(r) - bits[0].ask(ans))) %
                   pp) +
                  pp) %
                 pp);
        anss -= (((((bits[2].ask(r) - bits[2].ask(ans)) -
                    (ans) * (bits[0].ask(r) - bits[0].ask(ans))) %
                   pp) +
                  pp) %
                 pp);
      }
      anss = ((((anss) % pp) + pp) % pp);
      printf("%lld\n", anss);
    } else {
      x = -x;
      update(x, x, 1, n, 1, y - w[x]);
      bits[0].add(x, y - w[x]);
      bits[1].add(x, ((((nums[x] * (y - w[x])) % pp) + pp) % pp));
      bits[2].add(x, ((((x * (y - w[x])) % pp) + pp) % pp));
      w[x] = y;
    }
  }
  return 0;
}
