#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define ll long long
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl;
#define STOP system("pause");
using namespace std;
int n, m, c[100010], a[100010];
set<pair<int, int>> s;
int main() {
scanf("%d%d", &n, &m);
for(int i = 1; i <= n; i++)
scanf("%d", a + i);
for(int i = 1; i <= n; i++)
scanf("%d", c + i), s.insert({c[i], i});
while(m--) {
int t, d;
scanf("%d%d", &t, &d);//t种,d盘
ll ans = 0;
while(d) {
int p = s.count({c[t], t}) ? t : (s.size() ? s.begin()->second : -1);
if(p!=-1) {
if(d >= a[p])
s.erase({c[p], p}), ans += 1ll * a[p] * c[p], d -= a[p], a[p] = 0, t = p;
else
ans += 1ll * c[p] * d, a[p] -= d, d = 0;
} else {
ans = 0;
break;
}
}
printf("%lld\n", ans);
}
return 0;
}