#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
using namespace std;
const int N = 200005, mod = 1e9 + 7;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') f = -1, ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + ch - 48, ch = getchar();
  return x * f;
}
int n, Q;
int a[N], w[N], xp[N];
int Ha[N], hs;
struct Tree {
  static const int S = N * 70;
  int cnt, ls[S], rs[S];
  long long sum[S];
  void clear() { cnt = 0; }
  void update(int &rt, int L, int R, int x, int d) {
    if (!rt) rt = ++cnt, sum[rt] = ls[rt] = rs[rt] = 0;
    sum[rt] += d;
    if (L == R) return;
    int mid = (L + R) >> 1;
    if (x <= mid)
      update(ls[rt], L, mid, x, d);
    else
      update(rs[rt], mid + 1, R, x, d);
  }
  long long query(int rt, int L, int R, int xL, int xR) {
    if (!rt || R < xL || xR < L || xL > xR) return 0;
    if (xL <= L && R <= xR) return sum[rt];
    int mid = (L + R) >> 1;
    return query(ls[rt], L, mid, xL, xR) + query(rs[rt], mid + 1, R, xL, xR);
  }
} Seg;
int root[N << 2];
void update(int rt, int L, int R, int x, int y, int d) {
  Seg.update(root[rt], 1, hs, y, d);
  if (L == R) return;
  int mid = (L + R) >> 1, ls = rt << 1, rs = ls | 1;
  if (x <= mid)
    update(ls, L, mid, x, y, d);
  else
    update(rs, mid + 1, R, x, y, d);
}
long long query(int rt, int L, int R, int xL, int xR, int yL, int yR) {
  if (L > xR || R < xL || xL > xR || yL > yR) return 0;
  if (xL <= L && R <= xR) return Seg.query(root[rt], 1, hs, yL, yR);
  int mid = (L + R) >> 1, ls = rt << 1, rs = ls | 1;
  return query(ls, L, mid, xL, xR, yL, yR) +
         query(rs, mid + 1, R, xL, xR, yL, yR);
}
long long c1[N];
int c2[N];
void add(int &x, int y) {
  if ((x += y) >= mod) x -= y;
}
void add2(int x, int d) {
  for (; x <= n; x += x & -x) add(c2[x], d);
}
int ask2(int x) {
  int ans = 0;
  for (; x; x -= x & -x) add(ans, c2[x]);
  return ans;
}
void add1(int x, long long d) {
  for (; x <= n; x += x & -x) c1[x] += d;
}
long long ask1(int x) {
  long long ans = 0;
  for (; x; x -= x & -x) ans += c1[x];
  return ans;
}
void opt1(int i, int nw) {
  add1(i, -w[i]);
  add2(i, mod - 1LL * w[i] * Ha[a[i]] % mod);
  update(1, 1, n, i, a[i], -w[i]);
  w[i] = nw;
  add1(i, w[i]);
  add2(i, 1LL * w[i] * Ha[a[i]] % mod);
  update(1, 1, n, i, a[i], w[i]);
}
vector<int> s;
void Divide(int rt, int L, int R, int xL, int xR) {
  if (R < xL || L > xR) return;
  if (xL <= L && R <= xR) {
    s.push_back(root[rt]);
    return;
  }
  int mid = (L + R) >> 1, ls = rt << 1, rs = ls | 1;
  Divide(ls, L, mid, xL, xR);
  Divide(rs, mid + 1, R, xL, xR);
}
long long sum;
int Ask(int L, int R) {
  long long ss = 0;
  for (int i = 0; i < s.size(); i++) ss += Seg.sum[s[i]];
  if (L == R) return sum >= ss ? L : 0;
  int mid = (L + R) >> 1;
  if (ss < sum) {
    for (int i = 0; i < s.size(); i++) s[i] = Seg.ls[s[i]];
    return Ask(L, mid);
  } else {
    for (int i = 0; i < s.size(); i++) s[i] = Seg.rs[s[i]];
    sum -= ss;
    return max(Ask(mid + 1, R), mid);
  }
}
long long LLabs(long long a) { return a < 0 ? -a : a; }
void opt2(int L, int R) {
  s.clear();
  Divide(1, 1, n, L, R);
  sum = ask1(R) - ask1(L - 1);
  int p = Ask(1, hs);
  sum = ask1(R) - ask1(L - 1);
  long long v1 = query(1, 1, n, L, R, 1, p);
  long long v2 = query(1, 1, n, L, R, 1, p + 1);
  if (LLabs(sum - v2 * 2) < LLabs(sum - v1 * 2)) p++;
  int pp = xp[p];
  long long s1 =
      -(ask1(pp) - ask1(L - 1)) % mod * p % mod + (ask2(pp) - ask2(L - 1));
  long long s2 = (ask1(R) - ask1(pp)) % mod * p % mod - (ask2(R) - ask2(pp));
  s1 = (s1 % mod + mod) % mod;
  s2 = (s2 % mod + mod) % mod;
  printf("%d\n", (s1 + s2) % mod);
}
int main() {
  n = read(), Q = read();
  for (int i = 1; i <= n; i++) a[i] = Ha[i] = read() - i;
  hs = unique(Ha + 1, Ha + n + 1) - Ha - 1;
  Seg.clear();
  memset(c1, 0, sizeof c1);
  memset(c2, 0, sizeof c2);
  for (int i = 1; i <= n; i++) {
    add1(i, w[i]);
    add2(i, 1LL * w[i] * a[i] % mod);
    a[i] = lower_bound(Ha + 1, Ha + n + 1, a[i]) - Ha;
    xp[a[i]] = i;
    w[i] = read();
    update(1, 1, n, i, a[i], w[i]);
  }
  while (Q--) {
    int x = read(), y = read();
    if (x < 0)
      opt1(-x, y);
    else
      opt2(x, y);
  }
  return 0;
}
