#include #include #define ft first #define sc second #define pt(sth) cout << sth << "\n" #define chmax(a, b) (a)=max(a, b) #define chmin(a, b) (a)=min(a, b) #define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD using namespace std; typedef long long ll; typedef pair pll; static const ll INF=1e18; static const ll MAX=101010; static const ll MOD=1e9+7; /* for(i=0; i> a[i]; */ class unionFind { public: vector data; unionFind(ll size) { data.assign(size, -1); } bool same(ll x, ll y) { return find(x)==find(y); } void unite(ll x, ll y) { x=find(x); y=find(y); if(x==y) return; if(data[x]>data[y]) swap(x, y); data[x]+=data[y]; data[y]=x; } ll find(ll k) { if(data[k]<0) return k; return data[k]=find(data[k]); } ll size(ll k) { return -data[find(k)]; } }; int main(void) { ll i, j, k; ll N; cin >> N; vector g[MAX]; unionFind uf=unionFind(N); for(i=0; i> u >> v; g[u].push_back(v); g[v].push_back(u); uf.unite(u, v); } map> mp; for(i=0; i