#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;
    Node* l = nullptr;
    Node* r = nullptr;
    Node() {}
    Node(int x) : val(x) {}
};


int getSum(Node* t) {
    if (t) {
        return t -> val;
    }
    return 0;
}


Node* upd(Node* t, int tl, int tr, int pos, int x) {
    if (tl + 1 == tr) {
        Node* res = new Node(t -> val + x);
        return res;
    }
    int tm = (tl + tr) / 2;
    Node* res = new Node();
    if (!t -> l) {
        t -> l = new Node();
    }
    if (!t -> r) {
        t -> r = new Node();
    }
    Node* lp = t -> l;
    Node* rp = t -> r;
    if (pos < tm) {
        lp = upd(t -> l, tl, tm, pos, x);
    } else {
        rp = upd(t -> r, tm, tr, pos, x);
    }
    res -> l = lp;
    res -> r = rp;
    res -> val = getSum(res -> l) + getSum(res -> r);
    return res;
}


int get(Node* t, int tl, int tr, int ql, int qr) {
    if (!t) {
        return 0;
    }
    if (tl == ql && tr == qr) {
        return t -> val;
    }
    int tm = (tl + tr) / 2;
    if (qr <= tm) {
        return get(t -> l, tl, tm, ql, qr);
    } else if (ql >= tm) {
        return get(t -> r, tm, tr, ql, qr);
    }
    return get(t -> l, tl, tm, ql, tm) + get(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);
    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<Node*> vers(int(tour.size()));
    vers.at(0) = new Node();
    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*/
