#include #include #include"testlib.h" using namespace std; using ll = long long; const ll Nmin = 2, Nmax = 200'000; int main(){ registerValidation(); ll n = inf.readLong(Nmin,Nmax); inf.readEoln(); atcoder::dsu d(n); for (int i = 0; i < n-1; i++){ ll u = inf.readLong(1LL,n); inf.readSpace(); ll v = inf.readLong(1LL,n); inf.readEoln(); u--, v--; ensure(!d.same(u,v)); d.merge(u,v); } inf.readEof(); }