#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXN 10005
int tree[MAXN][MAXN];
int depth[MAXN];
int visited[MAXN];
void dfs(int node, int parent, int d) {
visited[node] = 1;
depth[node] = d;
for (int i = 0; i < tree[node][0]; i++) {
if (!visited[tree[node][i + 1]]) {
dfs(tree[node][i + 1], node, d + 1);
}
}
}
int main() {
int T;
scanf("%d", &T);
while (T--) {
int N, Q;
scanf("%d%d", &N, &Q);
memset(tree, 0, sizeof(tree));
memset(visited, 0, sizeof(visited));
memset(depth, 0, sizeof(depth));
for (int i = 0; i < N - 1; i++) {
int U, V;
scanf("%d%d", &U, &V);
tree[U][0]++;
tree[U][tree[U][0]] = V;
tree[V][0]++;
tree[V][tree[V][0]] = U;
}
dfs(1, -1, 0);
while (Q--) {
int X;
scanf("%d", &X);
int ans = 0;
for (int i = 1; i <= N; i++) {
if (depth[i] <= X) {
ans++;
}
}
printf("%d\n", ans);
}
}
return 0;
}