#include <bits/stdc++.h>
using namespace std;
int setmaxval(int k,vector<vector<int>>&children,vector<multiset<pair<int,int>>>&maxchild,vector<pair<int,int>>&parent)
{
    for(int i=0;i<children[k].size();i++)
    {
        int next=children[k][i];
        int nextval=setmaxval(next,children,maxchild,parent);
        maxchild[k].insert({nextval,next});
    }
    pair<int,int>top=*maxchild[k].begin();
    return top.first;
}
void update1(int k,int child,int oldval,int newval,vector<multiset<pair<int,int>>>&maxchild,vector<pair<int,int>>&parent)
{
    pair<int,int> top=*maxchild[k].begin();
    int oldmax=top.first;
    maxchild[k].erase({oldval,child});
    maxchild[k].insert({newval,child});
    if(k!=1)
    {
        pair<int,int> top=*maxchild[k].begin();
        int newmax=top.first;
        update1(parent[k].first,k,oldmax+parent[k].second,newmax+parent[k].second,maxchild,parent);
    }
}
void setup(int k,int trenutniup,vector<vector<int>>&children,vector<multiset<pair<int,int>>>&maxchild,vector<pair<int,int>>&parent)
{
    for(int i=0;i<children[k].size();i++)
    {
        int tr=children[k][i];
        setup(tr,trenutniup+parent[tr].second,children,maxchild,parent);
    }
}
void Bumerang(int n, int q, int* p, int* w, int* s, int* k, long long* ans)
{
    bool q1=false;
    bool star=false;
    bool small=false;
    int center=-1;
    if(q==1)q1=true;
    if(q<=5000&&n<=5000)small==true;
    vector<pair<int,int>>parent(n+1);
    vector<vector<int>>children(n+1);
    vector<multiset<pair<int,int>>>maxchild(n+1);
    for(int i=1;i<=n;i++)
    {
        int num1,num2;
        num1=i;//child
        num2=p[i];//parent
        parent[i]={p[i],w[i]};
        children[p[i]].push_back(i);
        setmaxval(1,children,maxchild,parent);
        for(int j=0;j<children[1].size();j++)
        {
            int tr=children[1][j];
            pair<int,int>top=*(maxchild[1].begin());
            setup(tr,top.first+parent[tr].second,children,maxchild,parent);
        }
    }
    vector<int>up(n+1);
    for(int j=1;j<q;j++)
    {
        int num=s[j];
        int nova=k[j];
        update1(parent[num].first,num,parent[num].second,nova,maxchild,parent);
        parent[num].second=nova;
    }
}

int main() {
        ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, Q;
    cin >> N >> Q;

    int* p = new int[N + 1];
    int* w = new int[N + 1];

    for (int i = 1; i <= N; i++) {
        cin >> p[i];
    }

    for (int i = 1; i <= N; i++) {
        cin >> w[i];
    }

    int* s = new int[Q + 1];
    int* k = new int[Q + 1];
    long long* ans = new long long[Q + 1];

    for (int i = 1; i <= Q; i++) {
        cin >> s[i];
    }

    for (int i = 1; i <= Q; i++) {
        cin >> k[i];
    }

    Bumerang(N, Q, p, w, s, k, ans);

    for (int i = 1; i <= Q; i++) {
        cout << ans[i] << '\n';
    }

    delete[] p;
    delete[] w;
    delete[] s;
    delete[] k;
    delete[] ans;

    return 0;
}