import java.io.*; import java.util.*; class Main { public static void main(String args[])throws Exception { BufferedReader bu=new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb=new StringBuilder(); int n=Integer.parseInt(bu.readLine()); int i,N=200000,a[][]=new int[n][2],bad=0; boolean b[]=new boolean[N+1]; Set h[]=new HashSet[N+1]; for(i=0;i<=N;i++) h[i]=new HashSet<>(); for(i=0;i g[],int l[],boolean v[],int n) { for(int x:g[n]) if(!v[x]) { v[x]=true; l[x]=l[n]+1; dfs(g,l,v,x); } } }