#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 50;
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
int a[maxn], t[maxn];
long long w[maxn];
struct node {
  int l, r;
  long long sum, tot;
} tree[maxn << 2];
void push_up(int i) {
  tree[i].sum = tree[i << 1].sum + tree[i << 1 | 1].sum;
  tree[i].tot = tree[i << 1].tot + tree[i << 1 | 1].tot;
}
void build(int i, int l, int r) {
  tree[i].l = l;
  tree[i].r = r;
  if (l == r) {
    tree[i].sum = w[l];
    tree[i].tot = (l - a[l]) * w[l];
    return;
  }
  int mid = (tree[i].l + tree[i].r) >> 1;
  build(i << 1, l, mid);
  build(i << 1 | 1, mid + 1, r);
  push_up(i);
}
void updata(int i, int x, int k) {
  if (tree[i].l == tree[i].r && tree[i].l == x) {
    tree[i].sum = k;
    tree[i].tot = (tree[i].l - a[tree[i].l]) * k;
    return;
  }
  int mid = (tree[i].l + tree[i].r) >> 1;
  if (x <= mid)
    updata(i << 1, x, k);
  else
    updata(i << 1 | 1, x, k);
  push_up(i);
}
long long querytot(int i, int x, int y) {
  if (tree[i].l >= x && tree[i].r <= y) return tree[i].tot;
  int mid = (tree[i].l + tree[i].r) >> 1;
  if (y <= mid)
    return querytot(i << 1, x, y);
  else if (x > mid)
    return querytot(i << 1 | 1, x, y);
  else
    return querytot(i << 1, x, mid) + querytot(i << 1 | 1, mid + 1, y);
}
long long querysum(int i, int x, int y) {
  if (tree[i].l >= x && tree[i].r <= y) return tree[i].sum;
  int mid = (tree[i].l + tree[i].r) >> 1;
  if (y <= mid)
    return querysum(i << 1, x, y);
  else if (x > mid)
    return querysum(i << 1 | 1, x, y);
  else
    return querysum(i << 1, x, mid) + querysum(i << 1 | 1, mid + 1, y);
}
pair<long long, long long> query(int i, int x, int y, int k) {
  if (tree[i].l >= x && tree[i].r <= y) {
    if (tree[i].sum < k) return {tree[i].sum, inf};
    if (tree[i].l == tree[i].r) return {tree[i].sum, tree[i].l};
    if (tree[i << 1].sum >= k)
      return query(i << 1, x, y, k);
    else
      return query(i << 1 | 1, x, y, k - tree[i << 1].sum);
  }
  int mid = (tree[i].l + tree[i].r) >> 1;
  if (y <= mid)
    return query(i << 1, x, y, k);
  else if (x > mid)
    return query(i << 1 | 1, x, y, k);
  else {
    pair<long long, long long> lt = query(i << 1, x, mid, k);
    pair<long long, long long> rt;
    if (lt.second == inf)
      rt = query(i << 1 | 1, mid + 1, y, k - lt.first);
    else
      rt = query(i << 1 | 1, mid + 1, y, k);
    if (lt.second < rt.second) return lt;
    return rt;
  }
}
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    t[i] = a[i];
  }
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &w[i]);
  }
  sort(t + 1, t + 1 + n);
  build(1, 1, n);
  while (q--) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x < 0) {
      x = abs(x);
      updata(1, x, y);
    } else {
      long long sum = querysum(1, x, y);
      pair<long long, long long> pr = query(1, x, y, sum / 2);
      int pos = pr.second;
      long long tot1 = 0, tot2 = 0;
      long long sum1 = 0;
      if (x <= pos - 1) {
        sum1 = querysum(1, x, pos - 1);
        tot1 = querytot(1, x, pos - 1);
      }
      long long sum2 = 0;
      if (y >= pos + 1) {
        sum2 = querysum(1, pos + 1, y);
        tot2 = querytot(1, pos + 1, y);
      }
      long long pos1 = pos - 1, pos2 = pos + 1;
      long long ans1 = (a[pos] - 1 - pos) % mod * sum1 % mod;
      ans1 = (ans1 + tot1 % mod + sum1 % mod) % mod;
      tot2 = -tot2;
      long long ans2 = (pos - (a[pos] + 1)) * sum2 % mod;
      ans2 = (ans2 + tot2 % mod + sum2 % mod) % mod;
      printf("%lld\n", (ans1 + ans2) % mod);
    }
  }
}
