#include <bits/stdc++.h>
using namespace std;
long long pack(unsigned int a, unsigned int b) {
  return (((unsigned long long)a) << 32) | ((unsigned long long)b);
}
struct tree {
  int l;
  int r;
  long long sum;
  long long cost;
  tree* left;
  tree* right;
  tree(int l, int r) : l(l), r(r), sum(0), cost(0), left(NULL), right(NULL) {
    if (r - l > 1) {
      int m = (r + l) / 2;
      left = new tree(l, m);
      right = new tree(m, r);
    }
  }
  void set(int i, long long v, long long v2) {
    if (i < l || i >= r) return;
    if (r - l == 1) {
      sum = v;
      cost = v2;
    } else {
      left->set(i, v, v2);
      right->set(i, v, v2);
      sum = left->sum + right->sum;
      cost = (left->cost + right->cost) % 1000000007;
    }
  }
  long long query1(int l, int r) {
    if (r <= this->l || l >= this->r) return 0;
    if (l <= this->l && r >= this->r) return sum;
    return left->query1(l, r) + right->query1(l, r);
  }
  long long query2(int l, int r) {
    if (r <= this->l || l >= this->r) return 0;
    if (l <= this->l && r >= this->r) return cost;
    return (left->query2(l, r) + right->query2(l, r)) % 1000000007;
  }
};
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  tree t(0, n);
  vector<int> poses(n);
  for (int i = 0; i < n; i++) scanf("%d", &poses[i]);
  for (int i = 0; i < n; i++) {
    long long w;
    scanf("%l64d", &w);
    t.set(i, w, (w * (poses[i] + n - i)));
  }
  for (int T = 0; T < q; T++) {
    int l, r;
    scanf("%d%d", &l, &r);
    if (l < 0) {
      long long w = r;
      t.set(-1 - l, w, (w * (poses[-1 - l] + n + l + 1)));
      continue;
    }
    l--;
    int low = poses[l] - 1;
    int high = poses[r - 1] + 1 - (r - l);
    while (high - low > 1) {
      int mid = (high + low) / 2;
      int low2 = -1;
      int high2 = r - l;
      while (high2 - low2 > 1) {
        int mid2 = (high2 + low2) / 2;
        if (poses[l + mid2] > mid + mid2)
          high2 = mid2;
        else
          low2 = mid2;
      }
      long long cost = t.query1(l, l + high2) - t.query1(l + high2, r);
      if (cost >= 0)
        high = mid;
      else
        low = mid;
    }
    int low2 = -1;
    int high2 = r - l;
    while (high2 - low2 > 1) {
      int mid2 = (high2 + low2) / 2;
      if (poses[l + mid2] > high + mid2)
        high2 = mid2;
      else
        low2 = mid2;
    }
    long long cost1 =
        (t.query2(l, l + high2) + 1000000007 -
         ((t.query1(l, l + high2) % 1000000007) * (high + n - l)) %
             1000000007) %
        1000000007;
    long long cost2 =
        (t.query2(l + high2, r) + 1000000007 -
         ((t.query1(l + high2, r) % 1000000007) * (high + n - l)) %
             1000000007) %
        1000000007;
    printf("%d\n", (cost2 + 1000000007 - cost1) % 1000000007);
  }
  return 0;
}
