#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mx = 1e5+9;
vector<int>tree[mx];
int h[mx];
void dfs (int x, int p, int l) {
h[l]++;
for (auto u : tree[x]) {
if (u != p) {
dfs (u, x, l+1);
}
}
}
int32_t main () {
cin.tie(0)->sync_with_stdio(0);
int t = 1;
cin >> t;
while (t--) {
int n, q;
cin >> n >> q;
for (int i = 0; i < n-1; i++) {
int u, v;
cin >> u >> v;
tree[u].push_back(v);
tree[v].push_back(u);
}
dfs (1, 0, 0);
for (int i = 1; i <= n; i++) {
h[i] += h[i-1];
}
while (q--) {
int x;
cin >> x;
cout << h[x] << "\n";
}
for (int i = 0; i <= n; i++) {
h[i] = 0;
tree[i].clear();
}
}
}