#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define endl '\n'
const int N = 1e5+12;
std::vector<int>gp[N];
ll lv[N];
bool vis[N];
void bfs(int sr){
std::queue<int>s;
s.push(sr);
vis[sr] = 1;
lv[sr] = 0;
while(!s.empty()){
int node = s.front();
s.pop();
for(auto u : gp[node]){
if(!vis[u]){
vis[u] = 1;
s.push(u);
lv[u] = lv[node]+1;
}
}
}
}
void solve(int cs){
int n,q;
cin>>n>>q;
memset(gp,0,sizeof gp);
memset(lv,0,sizeof lv);
memset(vis,0,sizeof vis);
for(int i = 1; i < n; i++){
int a,b;cin>>a>>b;
gp[a].push_back(b);
gp[b].push_back(a);
}
bfs(1);
vector<ll>v(N,0);
for(int i = 1; i <= n; i++){
v[lv[i]]++;
}
for(int i = 1; i < N; i++)v[i]+=v[i-1];
while(q--){
int x;
cin>>x;
cout<<v[x]<<endl;
}
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);
int t=1,cs=0;
cin >> t;
while(t--)
{
solve(++cs);
}
return 0;
}