#include using namespace std; using Int = long long; const char newl = '\n'; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a void drop(const T &x){cout< vector read(size_t n){ vector ts(n); for(size_t i=0;i>ts[i]; return ts; } template struct FixPoint : F{ FixPoint(F&& f):F(forward(f)){} template decltype(auto) operator()(Args&&... args) const{ return F::operator()(*this,forward(args)...); } }; template inline decltype(auto) MFP(F&& f){ return FixPoint{forward(f)}; } //INSERT ABOVE HERE signed main(){ cin.tie(0); ios::sync_with_stdio(0); int n,m; cin>>n>>m; auto as=read(m); for(int &a:as) a--; vector> G(n); for(int i=1;i>u>>v; u--;v--; G[u].emplace_back(v); G[v].emplace_back(u); } using P = pair; map dp; auto func= MFP([&](auto dfs,int v,int p)->int{ if(dp.count(P(v,p))) return dp[P(v,p)]; int &res=dp[P(v,p)]; res=0; set ss; for(int u:G[v]){ if(u==p) continue; ss.emplace(dfs(u,v)); } while(ss.count(res)) res++; return res; }); for(int i=0;i