#include <bits/stdc++.h>
using namespace std;
const int N = 2000010;
int n, q, a[N], w[N], l, r, mid1, mid2, low, high, x1, x2, ans;
long long res, get1, get2, seg1[3 * N], seg2[3 * N];
long long seg[3 * N], cur1[N], cur2[N];
int L, R, Idx;
long long build(int s, int e, int idx) {
  if (s == e) return seg[idx] = w[s];
  return seg[idx] = build(s, (s + e) / 2, idx * 2) +
                    build((s + e) / 2 + 1, e, idx * 2 + 1);
}
long long update(int s, int e, int idx) {
  if (s > Idx || e < Idx) return seg[idx];
  if (s == e) return seg[idx] = w[Idx];
  return seg[idx] = update(s, (s + e) / 2, idx * 2) +
                    update((s + e) / 2 + 1, e, idx * 2 + 1);
}
long long getsum(int s, int e, int idx) {
  if (s > R || e < L) return 0;
  if (s >= L && e <= R) return seg[idx];
  return getsum(s, (s + e) / 2, idx * 2) +
         getsum((s + e) / 2 + 1, e, idx * 2 + 1);
}
long long build1(int s, int e, int idx) {
  if (s == e) return seg1[idx] = cur1[s];
  return seg1[idx] = build1(s, (s + e) / 2, idx * 2) +
                     build1((s + e) / 2 + 1, e, idx * 2 + 1);
}
long long update1(int s, int e, int idx) {
  if (s > Idx || e < Idx) return seg1[idx];
  if (s == e) return seg1[idx] = cur1[Idx];
  return seg1[idx] = update1(s, (s + e) / 2, idx * 2) +
                     update1((s + e) / 2 + 1, e, idx * 2 + 1);
}
long long getsum1(int s, int e, int idx) {
  if (s > R || e < L) return 0;
  if (s >= L && e <= R) return seg1[idx];
  return getsum1(s, (s + e) / 2, idx * 2) +
         getsum1((s + e) / 2 + 1, e, idx * 2 + 1);
}
long long build2(int s, int e, int idx) {
  if (s == e) return seg2[idx] = cur2[s];
  return seg2[idx] = build2(s, (s + e) / 2, idx * 2) +
                     build2((s + e) / 2 + 1, e, idx * 2 + 1);
}
long long update2(int s, int e, int idx) {
  if (s > Idx || e < Idx) return seg2[idx];
  if (s == e) return seg2[idx] = cur2[Idx];
  return seg2[idx] = update2(s, (s + e) / 2, idx * 2) +
                     update2((s + e) / 2 + 1, e, idx * 2 + 1);
}
long long getsum2(int s, int e, int idx) {
  if (s > R || e < L) return 0;
  if (s >= L && e <= R) return seg2[idx];
  return getsum2(s, (s + e) / 2, idx * 2) +
         getsum2((s + e) / 2 + 1, e, idx * 2 + 1);
}
long long tmp1, tmp2, getres, tmp3;
int tmpl, tmpr;
long long get(int x) {
  if (x == l) {
    L = l, R = r;
    tmp1 = getsum1(0, n - 1, 1);
    tmp2 = getsum(0, n - 1, 1);
    x = (a[x] - (-1000000000 + x));
    tmp1 -= (long long)tmp2 * x;
    return tmp1;
  } else if (x == r) {
    L = l, R = r;
    tmp1 = getsum2(0, n - 1, 1);
    tmp2 = getsum(0, n - 1, 1);
    x = ((1000000000 + x) - a[x]);
    tmp1 -= (long long)tmp2 * x;
    return tmp1;
  }
  tmpl = l;
  tmpr = r;
  r = x;
  getres = 0;
  getres = get(r);
  r = tmpr;
  l = x;
  getres += get(l);
  l = tmpl, r = tmpr;
  return getres;
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) {
    scanf("%d", &w[i]);
    cur1[i] = (long long)w[i] * (a[i] - (-1000000000 + i));
    cur2[i] = (long long)w[i] * ((1000000000 + i) - a[i]);
  }
  build(0, n - 1, 1);
  build1(0, n - 1, 1);
  build2(0, n - 1, 1);
  while (q--) {
    scanf("%d%d", &l, &r);
    if (l < 0) {
      Idx = -l - 1;
      w[Idx] = r;
      cur1[Idx] = (long long)w[Idx] * (a[Idx] - (-1000000000 + Idx));
      cur2[Idx] = (long long)w[Idx] * ((1000000000 + Idx) - a[Idx]);
      update(0, n - 1, 1);
      update1(0, n - 1, 1);
      update2(0, n - 1, 1);
    } else {
      l--, r--;
      low = l, high = r, res = -1;
      while (high >= low) {
        if (high - low < 40) {
          while (low <= high) {
            res = min(res, get(low));
            low++;
          }
          break;
        }
        mid1 = low + (high - low) / 3;
        mid2 = high - (high - low) / 3;
        get1 = get(mid1);
        get2 = get(mid2);
        if (res == -1)
          res = min(get1, get2);
        else
          res = min(res, min(get1, get2));
        if (get1 > get2)
          low = mid1 + 1;
        else
          high = mid2 - 1;
      }
      tmp3 = res % 1000000007;
      ans = (int)tmp3;
      printf("%d\n", ans);
    }
  }
  return 0;
}
