#include using namespace std; using ll=long long; #define rep2(i, a, n) for(int i = (a); i < (n); i++) #define rep(i, n) rep2(i,0,n) int main(){ cin.tie(nullptr);ios_base::sync_with_stdio(false); int n;cin>>n; vector hoge(n+1); int a[n],b[n]; rep2(i,1,n)cin>>a[i]; rep2(i,1,n)cin>>b[i]; rep(i,n){ cin>>a[i]>>b[i]; hoge[b[i]]+=a[i]; } rep2(i,1,n){ //cout<