// BISMILLAH
#include "bits/stdc++.h"
#define fastIO std::ios::sync_with_stdio(0);std::cin.tie(0)
#define ll long long int
#define flush fflush(stdout)
// #define int ll
using pii = std::pair<int,int>;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int mxN = 200005, inf = 1000000005;
int N, q;
std::vector<int> g[mxN];
int lev[mxN];
void dfs(int u, int p, int l) {
lev[u] = l;
for (auto v : g[u]) {
if (v != p) {
dfs(v, u, l + 1);
}
}
}
void clear(int N) {
for (int i = 1; i <= N; i++) {
g[i].clear();
}
}
signed main() {
// fastIO;
int testCases=1;
scanf("%lld",&testCases);
// std::cin >> testCases;
// pre();
for (int T = 1; T <= testCases; T++) {
scanf("%d%d", &N, &q);
for (int i =0,u,v; i < N-1; i++) {
scanf("%d%d", &u, &v);
g[u].push_back(v);
g[v].push_back(u);
}
dfs(1, -1, 0);
int ans[N + 1] = {0};
for (int i = 1; i <= N; i++) {
ans[lev[i]]++;
}
for (int i = 1; i <= N; i++) {
ans[i] += ans[i - 1];
}
for (int i = 0, x; i < q; i++) {
scanf("%d", &x);
printf("%d\n", ans[x]);
}
clear(N);
}
return 0;
}
/*
*/