#include <bits/stdc++.h>


using namespace std;


template<typename T>
ostream & operator <<(ostream &os, const vector<T> &a) {
    for (T el : a) {
        os << el << " ";
    }
    os << '\n';
    return os;
}


struct Node {
    int val = 0;
    int l = -1;
    int r = -1;
    Node() {}
    Node(int x) : val(x) {}
};


int C = 1;
Node sums[10000000];


int getSum(int pos) {
    if (pos != -1) {
        return sums[pos].val;
    }
    return 0;
}


int upd(int t, int tl, int tr, int pos, int x) {
    if (tl + 1 == tr) {
        //sums.resize(int(sums.size()) + 1);
        sums[C].val += (x + getSum(t));
        C++;
        return C - 1;
    }
    if (t != -1) {
        int tm = (tl + tr) / 2;
        int res = C;
        //sums.resize(int(sums.size()) + 1);
        sums[res].l = sums[t].l;
        sums[res].r = sums[t].r;
        C++;
        if (pos < tm) {
            sums[res].l = upd(sums[t].l, tl, tm, pos, x);
        } else {
            sums[res].r = upd(sums[t].r, tm, tr, pos, x);
        }
        sums[res].val = getSum(sums[res].l) + getSum(sums[res].r);
        return res;
    }
    int tm = (tl + tr) / 2;
    int res = C;
    //sums.resize(int(sums.size()) + 1);
    C++;
    if (pos < tm) {
        sums[res].l = upd(-1, tl, tm, pos, x);
    } else {
        sums[res].r = upd(-1, tm, tr, pos, x);
    }
    sums[res].val = getSum(sums[res].l) + getSum(sums[res].r);
    return res;
}


int get(int t, int tl, int tr, int ql, int qr) {
    if (t == -1) {
        return 0;
    }
    if (tl == ql && tr == qr) {
        return sums[t].val;
    }
    int tm = (tl + tr) / 2;
    if (qr <= tm) {
        return get(sums[t].l, tl, tm, ql, qr);
    } else if (ql >= tm) {
        return get(sums[t].r, tm, tr, ql, qr);
    }
    return get(sums[t].l, tl, tm, ql, tm) + get(sums[t].r, tm, tr, tm, qr);
}


vector<int> func(const vector<vector<int>> &g, const vector<int> &s, int n) {
    set<pair<int, int>> edges;
    int par = 0;
    int t = 0;
    for (int to : g.at(0)) {
        edges.insert({s.at(to), to});
    }
    vector<int> res(n, 0);
    while (!edges.empty()) {
        auto it = edges.end();
        it--;
        par = it -> second;
        edges.erase(it);
        for (int to : g.at(par)) {
            edges.insert({s.at(to), to});
        }
        t++;
        res.at(par) = t;
    }
    return res;
}


void dfs(const vector<vector<int>> &g, int v, const vector<int> &t, vector<int> &tour, vector<int> &tin, vector<int> &tout, int &timer) {
    tin.at(v) = timer;
    timer++;
    tour.push_back(t.at(v));
    for (int to : g.at(v)) {
        dfs(g, to, t, tour, tin, tout, timer);
    }
    tout.at(v) = timer;
    timer++;
    tour.push_back(t.at(v));
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, q;
    cin >> n >> q;
    vector<vector<int>> g(n);
    vector<int> par(n, 0);
    for (int i = 1; i <= n - 1; i++) {
        int p;
        cin >> p;
        p--;
        g.at(p).push_back(i);
        par.at(i) = p;
    }
    vector<int> s(n);
    iota(s.begin(), s.end(), 1);
    for (int i = 0; i < n; i++) {
        cin >> s.at(i);
    }
    vector<int> t = func(g, s, n);
    vector<int> tin(n, 0), tout(n, 0);
    int timer = 1;
    vector<int> tour;
    tour.push_back(0);
    dfs(g, 0, t, tour, tin, tout, timer);
    vector<int> vers(int(tour.size()));
    for (int i = 1; i < int(vers.size()); i++) {
        vers.at(i) = upd(vers.at(i - 1), 0, n + 1, tour.at(i), 1);
    }
    for (int i = 0; i < q; i++) {
        int u;
        cin >> u;
        u--;
        int ans = t.at(u);
        int T = t.at(u);
        int prev = u;
        u = par.at(u);
        while (par.at(u) != u) {
            for (int to : g.at(u)) {
                if (to != prev) {
                    int l = tin.at(to) - 1;
                    int r = tout.at(to);
                    int prefr = get(vers.at(r), 0, n + 1, 0, T);
                    int prefl = get(vers.at(l), 0, n + 1, 0, T);
                    int res = (prefr - prefl) / 2;
                    ans = min(ans, T - res);
                }
            }
            prev = u;
            u = par.at(u);
        }
        if (prev != u) {
            for (int to : g.at(u)) {
                if (to != prev) {
                    int l = tin.at(to) - 1;
                    int r = tout.at(to);
                    int prefr = get(vers.at(r), 0, n + 1, 0, T);
                    int prefl = get(vers.at(l), 0, n + 1, 0, T);
                    int res = (prefr - prefl) / 2;
                    ans = min(ans, T - res);
                }
            }
        }
        cout << ans << " ";
    }
    return 0;
}

/*5 1
1 2 2 1
3 5 1 2 4
5*/
