#include #include #include #include #include #include #include using namespace atcoder; using namespace std; #define ll long long #define P pair ostream& operator<<(ostream& os,const P& a){ return os<& a){ for(ll i:a){ os<>& a){ for(vector i:a){ for(int j:i){ os<& a){ for(P i:a){ os<>N; dsu uf(N); vector>to(N); for(int i=0;i>A>>B; uf.merge(A-1,B-1); to.at(A-1).push_back({B-1,i}); if(A!=B){ to.at(B-1).push_back({A-1,i}); } } //cerr<<"to \n"; vectorans(N,-1); vector> groups=uf.groups(); //cerr< linked:groups){ bool is_cycle=true; ll root=-1,cycle_cnt=0; vector

degree; /* if(linked.size()==1){ printf("No\n"); cerr<<"0\n"; return 0; } */ for(int point:linked){ ll link_size=to.at(point).size(); //cerr<1){ printf("No\n"); //cerr<<"1\n"; return 0; } //サイクルならば、次数が2以上の場所を探す //次数でソートする //cerr<=2){ next_point=next.first; ans.at(next.second)=root+1; break; } } if(next_point==-1){ printf("No\n"); //cerr<<"2\n"; return 0; } } //cerr<dq; dq.push_back(root); while(!dq.empty()){ ll q=dq.back();dq.pop_back(); //cerr<