#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll setmaxval(int k,vector<vector<int>>&children,vector<multiset<pair<ll,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});
    }
    if(children[k].size()==0)return 0;
    auto x=maxchild[k].end();
    x--;
    pair<ll,int>top=*x;
    return top.first;
}
void update1(int k,int child,int oldval,int newval,vector<multiset<pair<ll,int>>>&maxchild,vector<pair<int,int>>&parent)
{
    auto x=maxchild[k].end();
    x--;
    pair<int,int>top=*x;
    int oldmax=top.first;
    maxchild[k].erase({oldval,child});
    maxchild[k].insert({newval,child});
    if(k!=1)
    {
        auto x=maxchild[k].end();
        x--;
        pair<int,int>top=*x;
        int newmax=top.first;
        update1(parent[k].first,k,oldmax+parent[k].second,newmax+parent[k].second,maxchild,parent);
    }
}
void setup(int k,ll trenutniup,vector<vector<int>>&children,vector<multiset<pair<ll,int>>>&maxchild,vector<pair<int,int>>&parent,vector<ll>&up)
{
    for(int i=0;i<children[k].size();i++)
    {
        int tr=children[k][i];
        setup(tr,trenutniup+parent[tr].second,children,maxchild,parent,up);
    }
}
long long findmax(int k,vector<vector<int>>&children,vector<multiset<pair<ll,int>>>&maxchild,vector<ll>&up)
{
    long long maxi=0;
    //cout<<k<<"RRRRRRR"<<endl;
    if(children[k].size()>=2)
    {
        auto x=maxchild[k].end();
        x--;
        pair<ll,int>top=*x;
        maxchild[k].erase(top);
        auto x1=maxchild[k].end();
        x1--;
        pair<ll,int>top1=*x1;
        maxchild[k].insert(top);
        maxi=top1.first+top.first+up[k];
        for(int i=0;i<children[k].size();i++)
        {
            maxi=max(maxi,findmax(children[k][i],children,maxchild,up));
        }
        return maxi;
    }
    else return 0;

}
void Bumerang(int n, int q, int* p, int* w, int* s, int* k, long long* ans)
{
    vector<pair<int,int>>parent(n+1);
    vector<vector<int>>children(n+1);
    vector<multiset<pair<ll,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);
    }
    vector<ll>up(n+1);
    setmaxval(1,children,maxchild,parent);
    for(int j=0;j<children[1].size();j++)
    {
       // cout<<j<<"ASDDAD"<<endl;
        int tr=children[1][j];
        auto x=maxchild[1].end();
        x--;
        pair<ll,int>top=*x;
        if(tr!=top.second)setup(tr,top.first+parent[tr].second,children,maxchild,parent,up);
        else{
            maxchild[1].erase(top);
            auto x1=maxchild[1].end();
            x1--;
            pair<ll,int>top1=*x1;
            setup(tr,top1.first+parent[tr].second,children,maxchild,parent,up);
            maxchild[1].insert(top);
        }
    }
    for(int o=1;o<q;o++)
    {
        int num=s[o];
        int nova=k[o];
        update1(parent[num].first,num,parent[num].second,nova,maxchild,parent);
        cout<<"DASD"<<endl;
        parent[num].second=nova;
        for(int j=0;j<children[1].size();j++)
        {
            int tr=children[1][j];
            auto x=maxchild[1].end();
            x--;
            pair<ll,int>top=*x;
            if(tr!=top.second)setup(tr,top.first+parent[tr].second,children,maxchild,parent,up);
            else{
                maxchild[1].erase(top);
                auto x1=maxchild[1].end();
                x1--;
                pair<ll,int>top1=*x1;
                setup(tr,top1.first+parent[tr].second,children,maxchild,parent,up);
                maxchild[1].insert(top);
            }
        }
        ll maxi=0;
        if(maxchild[1].size()>=3)
        {
            auto x=maxchild[1].end();
            x--;
            pair<ll,int>top=*x;
            maxchild[1].erase(top);
            auto x1=maxchild[1].end();
            x1--;
            pair<ll,int>top1=*x1;
            maxchild[1].erase(top1);
            auto x2=maxchild[1].end();
            x2--;
            pair<ll,int>top2=*x2;
            maxchild[1].insert(top1);
            maxchild[1].insert(top);
            maxi=top1.first+top.first+top2.first+parent[top.second].second+parent[top1.second].second+parent[top2.second].second;
            if(o==1)
                cout<<maxi<<top1.first<<"ASR"<<endl;
        }
        for(int i=0;i<children[1].size();i++)
        {
            ll now=findmax(children[1][i],children,maxchild,up);
            maxi=max(maxi,findmax(children[1][i],children,maxchild,up));
        }
        ans[o]=maxi;
    }
}
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;
}