#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
long long n, q, a[200005], p[200005];
long long _mod(long long x) { return x >= 1000000007 ? x - 1000000007 : x; }
struct segtree {
  long long sum[4 * 200005];
  long long sum2[4 * 200005], sum3[4 * 200005];
  void pushup(long long k) {
    sum[k] = sum[k * 2] + sum[k * 2 + 1];
    sum2[k] = _mod(sum2[k * 2] + sum2[k * 2 + 1]);
    sum3[k] = _mod(sum3[k * 2] + sum3[k * 2 + 1]);
  }
  void build(long long k, long long l, long long r) {
    if (l == r) {
      sum[k] = a[l];
      sum2[k] = 1LL * a[l] * p[l] % 1000000007;
      sum3[k] = 1LL * l * a[l] % 1000000007;
      return;
    }
    long long mid = (l + r) / 2;
    build(k * 2, l, mid);
    build(k * 2 + 1, mid + 1, r);
    pushup(k);
  }
  void update(long long k, long long l, long long r, long long pos,
              long long v) {
    if (l == r) {
      sum[k] = v;
      sum2[k] = 1LL * v * p[l] % 1000000007;
      sum3[k] = 1LL * v * l % 1000000007;
      return;
    }
    long long mid = (l + r) / 2;
    if (pos <= mid)
      update(k * 2, l, mid, pos, v);
    else
      update(k * 2 + 1, mid + 1, r, pos, v);
    pushup(k);
  }
  long long query1(long long k, long long l, long long r, long long x,
                   long long y) {
    if (x > r || l > y) return 0;
    if (l >= x && r <= y) return sum[k];
    long long mid = (l + r) / 2;
    return query1(k * 2, l, mid, x, y) + query1(k * 2 + 1, mid + 1, r, x, y);
  }
  long long find(long long k, long long l, long long r, long long s) {
    if (l == r) return l;
    long long mid = (l + r) / 2;
    if (sum[k * 2] <= s) return find(k * 2 + 1, mid + 1, r, s - sum[k * 2]);
    return find(k * 2, l, mid, s);
  }
  long long query2(long long k, long long l, long long r, long long x,
                   long long y) {
    if (x > r || l > y) return 0;
    if (l >= x && r <= y) return sum2[k];
    long long mid = (l + r) / 2;
    return _mod(query2(k * 2, l, mid, x, y) +
                query2(k * 2 + 1, mid + 1, r, x, y));
  }
  long long query3(long long k, long long l, long long r, long long x,
                   long long y) {
    if (x > r || l > y) return 0;
    if (l >= x && r <= y) return sum3[k];
    long long mid = (l + r) / 2;
    return _mod(query3(k * 2, l, mid, x, y) +
                query3(k * 2 + 1, mid + 1, r, x, y));
  }
} seg;
int main() {
  scanf("%lld%lld", &n, &q);
  for (long long i = 1; i <= n; i++) scanf("%lld", &p[i]);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  seg.build(1, 1, n);
  long long l, r;
  for (long long i = 0; i < q; i++) {
    scanf("%lld%lld", &l, &r);
    if (l < 0)
      seg.update(1, 1, n, -l, r);
    else {
      long long A = seg.query1(1, 1, n, 1, l - 1),
                B = seg.query1(1, 1, n, l, r), s = A + B / 2;
      long long pos = seg.find(1, 1, n, s);
      long long ans = 0;
      ans = (1LL * (p[pos] - pos) *
                 (seg.query1(1, 1, n, l, pos - 1) % 1000000007) +
             seg.query3(1, 1, n, l, pos - 1) - seg.query2(1, 1, n, l, pos - 1) +
             1000000007) %
            1000000007;
      ans = (ans + seg.query2(1, 1, n, pos + 1, r) +
             1LL * (pos - p[pos]) *
                 (seg.query1(1, 1, n, pos + 1, r) % 1000000007) % 1000000007 -
             seg.query3(1, 1, n, pos + 1, r) + 1000000007) %
            1000000007;
      if (ans < 0) ans += 1000000007;
      printf("%lld\n", ans);
    }
  }
  return 0;
}
