//#define _GLIBCXX_DEBUG 1

//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("inline")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

//#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int inf = 2e9;
const ll INF = 9e18;
const int MOD = 1e9 + 7;
const int FFT_MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-12;

mt19937 rng(42239777);

template <typename T>
istream& operator >> (istream &in, pair<T, T> &a){
    in >> a.first >> a.second;
    return in;
}

template <typename T>
ostream& operator << (ostream &out, pair<T, T> a){
    out << a.first << " " << a.second << " ";
    return out;
}

template <typename T>
istream& operator >> (istream &in, vector<T> &a){
    for (int i = 0; i < a.size(); ++i){
        in >> a[i];
    }
    return in;
}

template <typename T>
ostream& operator << (ostream &out, vector<T> a){
    for (int i = 0; i < a.size(); ++i){
        out << a[i] << " ";
    }
    return out;
}

template <typename T>
ostream& operator << (ostream &out, vector<vector<T>> a){
    for (int i = 0; i < a.size(); ++i){
        out << i << ": " << a[i] << "\n";
    }
    return out;
}

struct segment_tree {
    int n;
    vector<int> tree, add;

    segment_tree() = default;

    segment_tree(int n) : n(n) {
        tree.resize(4 * n);
        add.resize(4 * n);
    }

    segment_tree(vector<int> &a){
        n = a.size();
        tree.resize(4 * n);
        add.resize(4 * n);
        build(1, 0, n, a);
    }

    void build(int v, int l, int r, vector<int> &a){
        if (l + 1 == r){
            tree[v] = a[l];
            return;
        }
        int m = (r + l) / 2;
        build(2 * v, l, m, a);
        build(2 * v + 1, m, r, a);
        tree[v] = tree[2 * v] + tree[2 * v + 1];
    }

    void push(int v, int l, int r){
        int m = (r + l) / 2;
        add[2 * v] += add[v];
        add[2 * v + 1] += add[v];
        tree[2 * v] += add[v] * (m - l);
        tree[2 * v + 1] += add[v] * (r - m);
        add[v] = 0;
    }

    void update(int v, int l, int r, int ql, int qr, int val){
        if (r <= ql || qr <= l){
            return;
        }
        if (ql <= l && r <= qr){
            tree[v] += (r - l) * val;
            add[v] += val;
            return;
        }
        push(v, l, r);
        int m = (r + l) / 2;
        update(2 * v, l, m, ql, qr, val);
        update(2 * v + 1, m, r, ql, qr, val);
        tree[v] = tree[2 * v] + tree[2 * v + 1];
    }

    void update(int ql, int qr, int val){
        update(1, 0, n, ql, qr + 1, val);
    }

    int query(int v, int l, int r, int ql, int qr){
        if (r <= ql || qr <= l){
            return 0;
        }
        if (ql <= l && r <= qr){
            return tree[v];
        }
        push(v, l, r);
        int m = (r + l) / 2;
        return query(2 * v, l, m, ql, qr) + query(2 * v + 1, m, r, ql, qr);
    }

    int query(int ql, int qr){
        return query(1, 0, n, ql, qr);
    }

    };

struct Sparse_table {
    int n, logn;
    vector<vector<pair<int, int>>> mn;

    Sparse_table(vector<int> &a){
        n = a.size();
        logn = __lg(n) + 1;
        mn.resize(logn, vector<pair<int, int>>(n, {inf, -1}));
        for (int i = 0; i < n; ++i){
            mn[0][i] = {a[i], i};
        }
        for (int l = 0; l + 1 < logn; ++l){
            for (int i = 0; i + (1 << l) < n; ++i){
                mn[l + 1][i] = min(mn[l][i], mn[l][i + (1 << l)]);
            }
        }
    }

    pair<int, int> rmq(int l, int r){
        int t = __lg(r - l);
        return min(mn[t][l], mn[t][r - (1 << t)]);
    }
};

struct Fenwick_tree {
    int n;
    vector<int> tree;

    Fenwick_tree() = default;

    Fenwick_tree(int n) : n(n){
        tree.resize(n + 1);
    }

    Fenwick_tree(vector<int> &a){
        n = a.size();
        tree.resize(n + 1);
        for (int i = 0; i < n; ++i){
            add(i + 1, a[i]);
        }
    }

    void add(int k, int val){
        for (; k <= n; k += k & -k){
            tree[k] += val;
        }
    }

    int sum(int r){
        int ans = 0;
        for (; r > 0; r -= r & -r){
            ans += tree[r];
        }
        return ans;
    }

    int sum(int l, int r){
        return sum(r) - sum(l - 1);
    }
};

struct Mass_Fenwick {
    int n;
    Fenwick_tree fenw_diff, fenw_magic;

    Mass_Fenwick() = default;

    Mass_Fenwick(int n) : n(n){
        fenw_diff = Fenwick_tree(n);
        fenw_magic = Fenwick_tree(n);
    }

    void update(int l, int r, int x){
        fenw_diff.add(l, x);
        fenw_diff.add(r + 1, -x);
        fenw_magic.add(l, -(l - 1) * x);
        fenw_magic.add(r + 1, r * x);
    }

    int query(int r){
        return r * fenw_diff.sum(r) + fenw_magic.sum(r);
    }

    int query(int l, int r){
        return query(r) - query(l - 1);
    }
};

struct pair_hash {
    template<class T1, class T2>
    size_t operator () (pair<T1, T2> &a){
        size_t h1 = hash<T1>{}(a.first);
        size_t h2 = hash<T2>{}(a.second);
        return (h1 + 53463413) ^ ((h2 >> 2) + (h2 << 6));
    }
};

void stress(){
    while (true){

    }
}


struct MST {
    int n;
    vector<vector<int>> tree;

    MST(vector<int> &a){
        n = a.size();
        tree.resize(4 * n);
        build(1, 0, n, a);
    }

    void build(int v, int l, int r, vector<int> &a){
        if (l + 1 == r){
            tree[v] = {a[l]};
            return;
        }
        int m = (r + l) / 2;
        build(2 * v, l, m, a);
        build(2 * v + 1, m, r, a);
        merge(all(tree[2 * v]), all(tree[2 * v + 1]), back_inserter(tree[v]));
    }

    int query(int v, int l, int r, int ql, int qr, int val){
        if (r <= ql || qr <= l){
            return 0;
        }
        if (ql <= l && r <= qr){
            return lower_bound(tree[v].begin(), tree[v].end(), val) - tree[v].begin();
        }
        int m = (r + l) / 2;
        return query(2 * v, l, m, ql, qr, val) + query(2 * v + 1, m, r, ql, qr, val);
    }

    int query(int ql, int qr, int val){
        return query(1, 0, n, ql, qr + 1, val);
    }

};


vector<vector<int>> g;
vector<int> par;
vector<int> w;
vector<int> time_root;
vector<int> et, et_times;
vector<int> tin, tout;
int timer = 0;

void dfs(int v){
    tin[v] = timer++;
    et.push_back(v);
    et_times.push_back(time_root[v]);
    for (int u : g[v]){
        dfs(u);
    }
    et.push_back(v);
    et_times.push_back(time_root[v]);
    tout[v] = timer++;
}

void solve(){
    int n, q;
    cin >> n >> q;
    par.resize(n);
    g.resize(n);
    w.resize(n);
    par[0] = -1;
    for (int i = 1; i < n; ++i){
        cin >> par[i];
        par[i]--;
        g[par[i]].push_back(i);
    }

    cin >> w;

    set<pair<int, int>> to_root;
    to_root.insert({w[0], 0});
    time_root.resize(n);
    int cur_time = 0;
    while (!to_root.empty()){
        auto v = *to_root.rbegin();
        to_root.erase(to_root.find(v));
        time_root[v.second] = cur_time++;
        for (int u : g[v.second]){
            to_root.insert({w[u], u});
        }
    }

    tin.resize(n);
    tout.resize(n);
    dfs(0);
    //cout << et_times << "\n";

    vector<int> que(q);
    for (int i = 0; i < q; ++i){
        cin >> que[i];
        que[i]--;
    }

    MST mst(et_times);

    vector<int> ans(n);
    for (int v : que){
        int res = 0;

        int u = v;
        while (par[u] != -1){
            if (par[u] != 0){
                continue;
            }
            for (int to : g[par[u]]){
                if (to == u) continue;
                int cnt = mst.query(tin[to], tout[to], time_root[v]);
                cnt /= 2;
                //cout << cnt << " ";
                //cnt = 0;
                /*
                for (int i = tin[to]; i <= tout[to]; ++i){
                    if (et_times[i] < time_root[v]){
                        cnt++;
                    }
                }
                cout << cnt << "\n";
                cnt /= 2;*/

                //
                res = max(res, cnt);
            }
            u = par[u];
        }
        ans[v] = time_root[v] - res;
        cout << ans[v] << " ";
    }
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    //cin >> t;
    while (t--){
        solve();
    }

    return 0;
}

/*

5 4
1 2 2 1
3 5 1 2 4
5 3 1 4


*/