#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#define endl '\n'
//#define int long long

using namespace std;

vector<int> tin;
vector<int> sz;
vector<int> up;
vector<int> parent;
int n;

int T = 0;

void cntsz(int v, vector<vector<int>> &g) {
    sz[v] = 1;
    for (auto u : g[v]) {
        cntsz(u, g);
        sz[v] += sz[u];
    }
}

void build_hld(int v, vector<vector<int>> &g, int prev) {
    int ind = -1;
    for (int x = 0; x < (int)g[v].size(); ++x) {
        int u = g[v][x];
        if (ind == -1 || sz[u] > sz[ind]) {
            ind = x;
        }
    }
    tin[v] = T;
    T++;
    if (ind != -1) {
        swap(g[v][ind], g[v][0]);
    }
    up[v] = prev;
    for (auto u : g[v]) {
        if (u == ind) {
            build_hld(u, g, prev);
        } else {
            build_hld(u, g, u);
        }
    }
}

struct node {
    int val = 0, on = 1;
    int add = 0, sw = 0;
};

vector<node> t;

void push(int v, int l, int r) {
    if (t[v].add != 0) {
        if (r - l > 1) {
            t[2 * v + 1].add += t[v].add;
            t[2 * v + 2].add += t[v].add;
        }
        t[v].val += t[v].add;
        t[v].add = 0;
    }
    if (t[v].sw != 0) {
        if (r - l > 1) {
            t[2 * v + 1].sw ^= t[v].sw;
            t[2 * v + 1].sw ^= t[v].sw;
        }
        t[v].on ^= t[v].sw;
        t[v].sw = 0;
    }
}

void add(int v, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) {
        t[v].add++;
        push(v, l, r);
        return;
    }
    push(v, l, r);
    if (ql >= r || l >= qr) {
        return;
    }
    int m = (l + r) / 2;
    add(2 * v + 1, l, m, ql, qr);
    add(2 * v + 2, m, r, ql, qr);
    t[v].val = max(t[2 * v + 1].val * t[2 * v + 1].on, t[2 * v + 2].val * t[2 * v + 2].on);
}

void flip(int v, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) {
        t[v].sw ^= 1;
        push(v, l, r);
        return;
    }
    push(v, l, r);
    if (ql >= r || l >= qr) {
        return;
    }
    int m = (l + r) / 2;
    flip(2 * v + 1, l, m, ql, qr);
    flip(2 * v + 2, m, r, ql, qr);
    t[v].val = max(t[2 * v + 1].val * t[2 * v + 1].on, t[2 * v + 2].val * t[2 * v + 2].on);
}

void pl(int x) {
    int v = x;
    while (true) {
        int u = up[v];
        int l = tin[u];
        int r = tin[v] + 1;
        add(0, 0, n, l, r);
        if (u == 0) {
            break;
        }
        v = parent[u];
    }
}

void change(int x) {
    int v = x;
    while (true) {
        int u = up[v];
        int l = tin[u];
        int r = tin[v] + 1;
        flip(0, 0, n, l, r);
        if (u == 0) {
            break;
        }
        v = parent[u];
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int q;
    cin >> n >> q;
    tin.resize(n);
    sz.resize(n);
    vector<vector<int>> g(n);
    parent.resize(n, -1);
    int x;
    for (int i = 1; i < n; ++i) {
        cin >> x;
        x--;
        g[x].push_back(i);
        parent[i] = x;
    }
    up.resize(n);
    cntsz(0, g);
    build_hld(0, g, 0);
    t.resize(4 * n);



    set<pair<int, int>> dd;
    vector<int> ord;
    vector<int> c(n);
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
    }
    dd.insert({c[0], 0});
    while (!dd.empty()) {
        auto it = dd.end();
        it--;
        int v = it -> second;
        ord.push_back(v);
        dd.erase(it);
        for (auto u : g[v]) {
            dd.insert({c[u], u});
        }
    }
    vector<int> ask(n, -1);
    vector<int> ans(q);
    for (int i = 0; i < q; ++i) {
        cin >> x;
        x--;
        ask[x] = i;
    }
    if (ask[0] != -1) {
        ans[ask[0]] = 0;
    }
    for (int i = 1; i < n; ++i) {
        auto u = ord[i];
        pl(u);
        if (ask[u] != -1) {
            change(u);
            int mx = t[0].val * t[0].on;
            ans[ask[u]] = i - mx;
            change(u);
        }
    }
    for (int i = 0; i < q; ++i) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}
