#include <iostream>
#include <vector>
using namespace std;
vector<vector<int>> tr;
vector<int> dh;
vector<int> cc;
void dfs(int nd, int pt, int d) {
dh[nd] = d;
cc[d]++;
for (int ch : tr[nd]) {
if (ch != pt) {
dfs(ch, nd, d + 1);
}
}
}
int main() {
int t;
cin >> t;
while (t--) {
int n, q;
cin >> n >> q;
tr.assign(n + 1, vector<int>());
dh.assign(n + 1, 0);
cc.assign(n + 1, 0);
for (int i = 1; i < n; ++i) {
int u, v;
cin >> u >> v;
tr[u].push_back(v);
tr[v].push_back(u);
}
dfs(1, 0, 0);
for (int i = 1; i <= n; ++i) {
cc[i] += cc[i - 1];
}
for (int i = 0; i < q; ++i) {
int x;
cin >> x;
cout << cc[x] << endl;
}
}
return 0;
}