int n, m;
struct Edge {
int to, nxt, w;
} edges[maxn<<1];
int head[maxn], ecnt = 1, queries[maxn];
bool ans[maxn], has_dis[maxm];
void addEdge(int u, int v, int w) {
Edge e = {v, head[u], w};
head[u] = ecnt;
edges[ecnt++] = e;
}
int sz[maxn], dis[maxn], q[maxn], hd = 1, tail = 0;
bool vis[maxn];
vector<int> tmp;
int cursz, rt;
void find_centroid(int u, int p) {
sz[u] = 1;
int mx = 0;
for (int e = head[u]; e; e = edges[e].nxt) {
int v = edges[e].to;
if (v == p || vis[v]) continue;
find_centroid(v, u);
sz[u] += sz[v];
mx = max(mx, sz[v]);
}
mx = max(mx, cursz - sz[u]);
if (mx <= cursz / 2) rt = u;
}
void get_cursz(int u, int p) {
sz[u] = 1;
for (int e = head[u]; e; e = edges[e].nxt) {
int v = edges[e].to;
if (vis[v] || v == p) continue;
get_cursz(v, u);
sz[u] += sz[v];
}
}
void getdis(int u, int p) {
q[++tail] = dis[u];
for (int e = head[u]; e; e = edges[e].nxt) {
int v = edges[e].to;
if (v == p || vis[v]) continue;
dis[v] = dis[u] + edges[e].w;
getdis(v, u);
}
}
void calc(int u) {
for (int e = head[u]; e; e = edges[e].nxt) {
int v = edges[e].to;
if (vis[v]) continue;
hd = 1, tail = 0;
dis[v] = dis[u] + edges[e].w;
getdis(v, u);
for (int p = hd; p <= tail; p++) {
for (int k = 1; k <= m; k++) {
int q_dis = queries[k];
if (q_dis >= q[p]) {
ans[k] |= has_dis[q_dis - q[p]];
}
}
}
for (int p = hd; p <= tail; p++) {
has_dis[q[p]] = 1;
tmp.push_back(q[p]);
}
}
for (int d : tmp) has_dis[d] = 0;
tmp.clear();
}
void solve(int u) {
vis[u] = 1; dis[u] = 0;
has_dis[0] = 1;
calc(u);
for (int e = head[u]; e; e = edges[e].nxt) {
int v = edges[e].to;
if (vis[v]) continue;
get_cursz(v, 0);
cursz = sz[v];
find_centroid(v, u);
solve(rt);
}
}
int main() {
cin >> n >> m;
for (int i = 1; i < n; i++) {
int u, v, w; cin >> u >> v >> w;
addEdge(u, v, w); addEdge(v, u, w);
}
for (int i = 1; i <= m; i++) {
int k; cin >> k;
queries[i] = k;
}
find_centroid(1, 0);
solve(rt);
for (int i = 1; i <= m; i++) {
cout << (ans[i] ? "AYE" : "NAY") << "\n";
}
}