#include <string>
#include <bitset>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>

using namespace std;
using ll = long long;
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

void fast() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cout << setprecision(8) << fixed;
}

ll mod = 1e9 + 7;
ll binpow(ll a, ll n) {
    ll res = 1;
    for (int i = 0; (1ll << i) <= n; ++i, a = a * a % mod) {
        if ((n >> i) & 1) res = res * a % mod;
    }
    return res;
}

vector<vector<int>> g;
vector<int> siz;
void dfs(int v) {
    siz[v]++;
    for (auto u: g[v]) {
        dfs(u);
        siz[v] += siz[u];
    }
}
vector<int> arr;
vector<int> cnt;
int dfs2(int v, int k) {
    if (v == k) return 0;
    if (arr[v] < arr[k]) return 0;
    cnt[v] = 1;
    for (auto u : g[v]) {
        cnt[v] += dfs2(u, k);
    }
    return cnt[v];
}
void solve() {
    int n, q;
    cin >> n >> q;
    g.resize(n);
    for (int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        --p;
        g[p].push_back(i);
    }
    arr.resize(n);
    siz.resize(n);
    dfs(0);
    for (auto &el : arr) cin >> el;
    for (int i = 0; i < q; ++i) {
        int v;
        cin >> v;
        --v;
        cnt.assign(n, 0);
        int ans = dfs2(0, v);
        int mx = 0;
        for (auto el : cnt) mx = max(el, mx);
        ans -= mx;
        cout << ans << '\n';
    }
}   
int main() {
    fast();
    int t = 1;
    cin >> t;
    while (t--) solve();
    return 0;
}