#include <bits/stdc++.h>
using namespace std;
using vec = vector<int>;
using vec64 = vector<int64_t>;
int MOD = 1000 * 1000 * 1000 + 7;
class Ftree {
 public:
  template <typename T>
  void Init(const vector<T>& data_) {
    size = data_.size() + 1;
    data.clear();
    data.resize(size);
    for (int i = 1; i < size; ++i) {
      Update(i, data_[i - 1]);
    }
  }
  void Update(int pos, int64_t diff) {
    while (pos < size) {
      data[pos] += diff;
      pos |= pos + 1;
    }
  }
  int64_t Get(int pos) const {
    int64_t res = 0;
    while (pos >= 0) {
      res += data[pos];
      pos = (pos & pos + 1) - 1;
    }
    return res;
  }
  vec64 FullDebug() const {
    vec64 full;
    for (int i = 0; i < size; ++i) full.push_back(Get(i));
    return full;
  }

 private:
  vec64 data;
  int size;
};
class JobCalculator {
 public:
  JobCalculator(vec& pos_, vec& w_) : pos(pos_), w(w_) {
    w_ftree.Init(w);
    vec aw_vec(w.size());
    for (int i = 0; i < pos.size(); ++i) {
      int64_t aw_el = (pos[i] - i) * 1ll * w[i];
      aw_vec[i] = aw_el;
    }
    aw_ftree.Init(aw_vec);
  }
  void Update(int a, int new_w) {
    int diff = new_w - w[a];
    int64_t aw_diff = (pos[a] - a) * 1ll * diff;
    w_ftree.Update(a + 1, diff);
    aw_ftree.Update(a + 1, aw_diff);
    w[a] = new_w;
  }
  int64_t GetJob(int left, int right) const {
    int64_t left_w_sum = w_ftree.Get(left);
    int64_t right_w_sum = w_ftree.Get(right + 1);
    int64_t mid_w_sum = (left_w_sum + right_w_sum) / 2;
    int mid_w = FindWValue(left, right, mid_w_sum);
    mid_w_sum = w_ftree.Get(mid_w);
    int x_pos = pos[mid_w] - mid_w + left;
    int64_t left_aw_sum = aw_ftree.Get(left);
    int64_t mid_aw_sum = aw_ftree.Get(mid_w);
    int64_t right_aw_sum = aw_ftree.Get(right + 1);
    int64_t sum1 = 2 * mid_w_sum - left_w_sum - right_w_sum;
    sum1 *= x_pos;
    int64_t sum2 = 0;
    sum2 -= 2 * mid_aw_sum - left_aw_sum - right_aw_sum;
    sum2 -= (2 * mid_w_sum - left_w_sum - right_w_sum) * pos[left];
    return sum1 + sum2;
  }

 private:
  int FindWValue(int left, int right, int64_t w_value) const {
    if (right - left <= 1) {
      return left;
    }
    int mid = (left + right) / 2;
    if (w_ftree.Get(mid) > w_value) {
      return FindWValue(left, mid, w_value);
    } else {
      return FindWValue(mid, right, w_value);
    }
  }
  vec& pos;
  vec& w;
  Ftree w_ftree;
  Ftree aw_ftree;
};
vec AnswerQueries(vec& pos, vec& weights,
                  const vector<pair<int, int>>& queries) {
  JobCalculator job(pos, weights);
  vec answers;
  for (auto& qq : queries) {
    if (qq.first < 0) {
      job.Update(-qq.first - 1, qq.second);
    } else {
      int ans = job.GetJob(qq.first - 1, qq.second - 1);
      answers.push_back(ans);
    }
  }
  return answers;
}
int main() {
  int n, q;
  cin >> n >> q;
  vec weights(n);
  vec pos(n);
  vector<pair<int, int>> queries(q);
  for (int i = 0; i < n; ++i) {
    cin >> pos[i];
    --pos[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> weights[i];
  }
  for (int i = 0; i < q; ++i) {
    int x, y;
    cin >> x >> y;
    queries[i] = {x, y};
  }
  vec answers = AnswerQueries(pos, weights, queries);
  for (int& ans : answers) {
    cout << ans << '\n';
  }
  cout << endl;
  return 0;
}
