#include#define setIO(s) freopen(s".in","r",stdin) #define maxn 10004 #define inf 10000003using namespace std;int edges,n,Q,sn,root,tl; bool is[inf]; int hd[maxn],to[maxn<<1],nex[maxn<<1],val[maxn<<1]; int answer[maxn], que[200], vis[maxn], f[maxn], siz[maxn], dep[maxn], mine[inf], dis1[maxn]; inline void add(int u,int v,int c){ nex[++edges]=hd[u],hd[u]=edges,to[edges]=v,val[edges]=c; } void Getroot(int u,int fa){ f[u]=0, siz[u]=1; for(int i=hd[u];i;i=nex[i]) { int v=to[i]; if(vis[v]||v==fa) continue; Getroot(v,u), siz[u]+=siz[v]; f[u]=max(f[u], siz[v]); } f[u]=max(f[u], sn-siz[u]); if(f[u] =inf||que[o] < dis1[j]) continue; is[que[o]]|=mine[que[o]-dis1[j]]; } for(int j=pdl+1;j<=tl;++j) mine[dis1[j]]=1; } for(int i=1;i<=tl;++i) mine[dis1[i]]=0; }void solve(int u){ int i,v; vis[u]=1; calc(u); for(i=hd[u];i;i=nex[i]) { v=to[i]; if(vis[v]) continue; root=0,sn=siz[v],Getroot(v, u); solve(root); }}int main(){ int i,j; // setIO("input"); scanf("%d%d",&n,&Q); for(i=1;i