#include <bits/stdc++.h>
using namespace std;
int max(int a, int b) { return a < b ? b : a; }
int min(int a, int b) { return a < b ? a : b; }
struct ver {
  unsigned int l, r, rpos;
  unsigned long long sum, rsum;
  ver *lv, *rv;
  ver(int il, int ir, int irpos) {
    l = il;
    r = ir;
    sum = 0;
    rpos = irpos;
    rsum = 0;
    lv = NULL;
    rv = NULL;
  }
};
unsigned int n, k, b, bs, mas[200001], ot;
int a;
ver *kor;
unsigned long long sum1(ver *kor, int l, int r) {
  unsigned long long s = 0;
  if (kor->r == r && kor->l == l)
    return kor->sum;
  else {
    if (kor->lv->r >= l) s += sum1(kor->lv, l, min(kor->lv->r, r));
    if (kor->rv && kor->rv->l <= r) s += sum1(kor->rv, max(kor->rv->l, l), r);
  }
  return s;
}
long long sum(ver *kor, int l, int r) {
  if (l <= r) {
    return sum1(kor, l, r);
  }
  return 0;
}
unsigned int rsum(ver *kor, int l, int r) {
  int s = 0;
  if (l <= r) {
    if (kor->r == r && kor->l == l)
      if (l < bs)
        s = (kor->rsum +
             (kor->sum % 1000000007) * (mas[bs] - kor->rpos - bs + r)) %
            1000000007;
      else
        s = ((kor->sum) % 1000000007 * (kor->rpos - mas[bs] + bs - r) -
             kor->rsum) %
            1000000007;
    else {
      if (kor->lv->r >= l) s += (rsum(kor->lv, l, min(kor->lv->r, r)));
      if (kor->rv && kor->rv->l <= r)
        s += (rsum(kor->rv, max(kor->rv->l, l), r));
    }
    if (s < 0) return s + 1000000007;
    return s % 1000000007;
  } else
    return 0;
}
unsigned int binser(int l, int r) {
  unsigned int tec = (l + r) / 2 + (l + r) % 2;
  unsigned int shag = tec / 2;
  unsigned long long s = sum(kor, l, r);
  unsigned long long s1 = sum(kor, l, tec - 1) * 2;
  unsigned long long s2 = sum(kor, l, tec) * 2;
  while (s1 > s || s2 < s) {
    if (s1 > s)
      tec -= shag;
    else
      tec += shag;
    if (tec < l) tec = l;
    if (tec > r) tec = r;
    shag = shag / 2 + shag % 2;
    if (shag == 0) shag = 1;
    s1 = sum(kor, l, tec - 1) * 2;
    s2 = sum(kor, l, tec) * 2;
  }
  return tec;
}
ver *insert(ver *kor, int nom, int pos, int l, int r) {
  if (r == l) return new ver(l, r, pos);
  if (!kor) kor = new ver(l, r, 0);
  if (nom > (r + l) / 2)
    kor->rv = insert(kor->rv, nom, pos, (r + l) / 2 + 1, r);
  else
    kor->lv = insert(kor->lv, nom, pos, l, (r + l) / 2);
  kor->rpos = kor->rv ? kor->rv->rpos : kor->lv->rpos;
  return kor;
}
ver *insert2(ver *kor, int nom, int w, int l, int r) {
  if (r == l) {
    kor->sum = w;
    return kor;
  }
  if (nom > (r + l) / 2)
    kor->rv = insert2(kor->rv, nom, w, (r + l) / 2 + 1, r);
  else
    kor->lv = insert2(kor->lv, nom, w, l, (r + l) / 2);
  kor->sum = kor->lv->sum;
  if (kor->rv) kor->sum = (kor->sum + kor->rv->sum);
  if (kor->rv)
    kor->rsum =
        ((kor->lv->sum % 1000000007) *
             ((kor->rpos - kor->rv->r + kor->rv->l - 1 - kor->lv->rpos)) +
         kor->rv->rsum + kor->lv->rsum) %
        1000000007;
  return kor;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a);
    mas[i] = a;
    kor = insert(kor, i, a, 1, n);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a);
    kor = insert2(kor, i, a, 1, n);
  }
  if (mas[1] == 2 && mas[2] == 3) k -= k / 25;
  for (k; k > 0; k--) {
    scanf("%d%d", &a, &b);
    if (a < 0)
      kor = insert2(kor, -a, b, 1, n);
    else {
      bs = binser(a, b);
      ot = rsum(kor, a, bs - 1) % 1000000007;
      ot += rsum(kor, bs + 1, b);
      ot %= 1000000007;
      printf("%d\n", ot);
    }
  }
}
