#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10;
long long a[N], c[N];
long long n, m;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  set<pair<long long, long long>> st;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (long long i = 1; i <= n; i++) {
    cin >> c[i];
    st.insert({c[i], i});
  }
  vector<long long> res;
  while (m--) {
    long long x, y;
    cin >> x >> y;
    long long cur = 0;
    while (y > 0 && st.size()) {
      if (a[x] > 0) {
        long long mx = min(y, a[x]);
        y -= mx;
        cur += c[x] * mx;
        a[x] -= mx;
        if (a[x] == 0) {
          st.erase({c[x], x});
        }
      } else {
        pair<long long, long long> tmp = *st.begin();
        long long mx = min(y, a[tmp.second]);
        y -= mx;
        a[tmp.second] -= mx;
        cur += tmp.first * mx;
        if (a[tmp.second] == 0) {
          st.erase(tmp);
        }
      }
    }
    if (y == 0) {
      res.push_back(cur);
    } else {
      res.push_back(0);
    }
  }
  for (long long i = 0; i < res.size(); i++) {
    cout << res[i] << "\n";
  }
  return 0;
}
