#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MX = 101010;
ll n, q, x;
vector<ll> vis(MX), dp(MX), g[MX];
void dfs(ll u, ll d){
vis[u] = 1;
for (auto v : g[u]){
if (!vis[v]){
dp[d]++;
dfs(v, d + 1);
}
}
}
int main(){
int t;
cin >> t;
while (t--){
cin >> n >> q;
for (int i = 1; i <= n; i++){
vis[i] = 0;
dp[i] = 0;
g[i].clear();
}
dp[1] = 1;
for (int i = 1; i < n; i++){
int u, v;
cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
dfs(1, 1);
for (int i = 1; i <= n; i++){
dp[i] += dp[i - 1];
}
for (int i = 1; i <= q; i++){
cin >> x;
cout << dp[x] << endl;
}
}
}