#include<bits/stdc++.h>
using namespace std;
#define Sheryang main
#define TYPE int
const int maxn=1e5+7;
typedef long long ll;
const int mod=1e9+7;
void Smax(TYPE &a,TYPE b){if(a<b) a=b;}
void Smin(TYPE &a,TYPE b){if(a>b) a=b;}
///#define getchar()(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
///char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
#define IO cin.tie(0),ios::sync_with_stdio(false);
#define pi acos(-1)
#define PII pair<ll,ll>
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
#define read read()
/** keep hungry and keep calm! **/
struct edge{
int w,to,next;
}edge[maxn];
int head[maxn],m,n,T;
void add_edge(int u,int v,int w){
edge[++m].next=head[u];
head[u]=m;
edge[m].to=v;
edge[m].w=w;
}
int vis[maxn],a[maxn],dis[maxn],len,ans[maxn];
namespace cent{ ///求树的重心的封装函数
int n,rt,son[maxn],maxl;
void dfs(int u,int fa){
son[u]=1;
int ml=0;
for(int i=head[u];~i;i=edge[i].next){
int v=edge[i].to;
int w=edge[i].w;
if(v==fa || vis[v]) continue;
dfs(v,u);
son[u]+=son[v];
Smax(ml,son[v]-1);
}
Smax(ml,n-son[u]);
if(ml<maxl){
maxl=ml;rt=u;
}
}
int GetCent(int x){
maxl=0x3f3f3f3f;
dfs(x,-1);
return rt;
}
}
void getdis(int u,int fa){
a[++len]=dis[u];
for(int i=head[u];~i;i=edge[i].next){
int v=edge[i].to;
int w=edge[i].w;
if(vis[v] || v==fa) continue;
dis[v]=dis[u]+w;
getdis(v,u);
}
}
int calc(int u,int w,int f){
dis[u]=w;
len=0;
getdis(u,-1);
for(int i=1;i<len;i++){
for(int j=i+1;j<=len;j++){
ans[a[i]+a[j]]+=f;
}
}
}
void solve(int u){
calc(u,0,1);
vis[u]=1;
for(int i=head[u];~i;i=edge[i].next){
int v=edge[i].to;
int w=edge[i].w;
if(vis[v]) continue;
calc(v,w,-1);
cent::n=cent::son[u];
int root=cent::GetCent(v);
solve(root);
}
}
int Sheryang(){
n=read,T=read;
for(int i=1;i<=n;i++){
head[i]=-1;
}
for(int i=1;i<n;i++){
int u=read,v=read,w=read;
add_edge(u,v,w);
add_edge(v,u,w);
}
cent::n=n;
int rt=cent::GetCent(1);
solve(rt);
while(T--){
int K=read;
printf("%s\n",ans[K]?"AYE":"NAY");
}
return 0;
}