#include #include #include using namespace std; typedef vector VI; typedef vector VVI; #define range(i,a,b) for(int i=(a); i < (b); i++) #define rep(i,n) range(i,0,n) #define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++) int main(){ int N,x,y,h; VVI e; VI S; queue n; cin >> N; e = VVI(N); S = VI(N,N); rep(i,N-1){ cin >> x >> y; x--; y--; e[x].push_back(y); e[y].push_back(x); } n.push(0); S[0] = 0; rep(i,N) if(e[i].size() == 1){n.push(i); S[i] = 0;} while(!n.empty()){ h = n.front(); n.pop(); each(nxt, e[h]) if(S[h]+1