#include<bits/stdc++.h>
using ll = long long;
using d = double;
using ld = long double;
using ull = unsigned long long;
using namespace std;
#define all(x) x.begin(), x.end()
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("avx2")
const int maxn = 3e5 + 2;
int h[maxn];
void dfs(int v, int p, vector<vector<int>>& g, vector<int>& s) {
    if (p == -1) {
        h[v] = 0;
    } else {
        h[v] = h[p] + 1;
    }
    for (auto to : g[v]) {
        if (to == p) continue;
        dfs(to, v, g, s);
    }
}
int solve() {
    int n, q;
    cin >> n >> q;
    vector<vector<int>> g(n);
    for (int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        p--;
        g[p].push_back(i);
        g[i].push_back(p);
    }
    vector<int> s(n);
    for (int i = 0; i < n; ++i) cin >> s[i];
    dfs(0, -1, g, s);
    for (int i = 0; i < q; ++i) {
        int v;
        cin >> v;
        v--;
        cout << h[v] << '\n';
    }
    return 0;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
