#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 5;
vector<int>adj[N];
bool vis[N];
int level[N];
void bfs(int start) {
queue<int> q;
q.push(start);
vis[start] = true;
level[start] = 0;
while (!q.empty()) {
int node = q.front();
q.pop();
for (int neighbor : adj[node]) {
if (!vis[neighbor]) {
q.push(neighbor);
level[neighbor] = level[node] + 1;
vis[neighbor] = true;
}
}
}
}
void solve() {
int n, q;
cin >> n >> q;
for(int i = 1; i <= n; i++){
adj[i].clear();
level[i] = -1;
vis[i] = false;
}
for(int i = 0; i < n - 1; i++){
int u, v;
cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
bfs(1);
vector<int>levels;
for(int i = 1; i <= n; i++){
levels.push_back(level[i]);
}
sort(levels.begin(), levels.end());
while(q--){
int x;
cin >> x;
int ans = upper_bound(levels.begin(), levels.end(), x) - levels.begin();
cout << ans << '\n';
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
cin >> t;
while(t--){
solve();
}
return 0;
}