#include <bits/stdc++.h>
using namespace std;
vector<unsigned long long> vec[1000009];
int main() {
  unsigned long long t = 1, i;
  unsigned long long n, m, b, p, c, e, d = 0, cnt = 0, j;
  scanf("%llu%llu", &n, &m);
  unsigned long long a[n + 5];
  map<unsigned long long, unsigned long long> dis;
  map<unsigned long long, unsigned long long> cos;
  for (i = 1; i <= n; i++) {
    scanf("%llu", &b);
    dis[i] = b;
    cnt += b;
  }
  for (i = 0; i < n; i++) {
    scanf("%llu", &a[i]);
    vec[a[i]].push_back(i + 1);
    cos[i + 1] = a[i];
  }
  sort(a, a + n);
  p = 0;
  for (i = 0; i < m; i++) {
    unsigned long long cn = 0, d = 0;
    scanf("%llu%llu", &b, &c);
    if (t == 0)
      d = 0;
    else if (dis[b] >= c) {
      d += c * (cos[b]);
      dis[b] -= c;
      cnt -= c;
    } else if (cnt < c) {
      d = 0;
      t = 0;
    } else {
      unsigned long long f = c - dis[b];
      if (dis[b] != 0) {
        d += dis[b] * (cos[b]);
        cnt -= dis[b];
        dis[b] = 0;
      }
      for (e = p; e < n; e++) {
        while (!vec[a[e]].empty()) {
          cn = vec[a[e]][0];
          if (dis[cn] == 0) {
            vec[a[e]].erase(vec[a[e]].begin());
            continue;
          }
          if (dis[cn] > f) {
            d += f * cos[cn];
            cnt -= f;
            dis[cn] -= f;
            f = 0;
          } else {
            d += dis[cn] * cos[cn];
            cnt -= dis[cn];
            f -= dis[cn];
            dis[cn] = 0;
            vec[a[e]].erase(vec[a[e]].begin());
          }
          if (f == 0 || cnt == 0) break;
        }
        if (vec[a[e]].empty()) p++;
        if (f == 0 || cnt == 0) break;
      }
    }
    printf("%llu\n", d);
  }
  return 0;
}
