package yukicoder; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Queue; import java.util.Scanner; public class Main{ public static void main(String[] args)throws Exception{ new Main().solve(); } void solve(){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); ArrayList[] g=new ArrayList[n]; for(int i=0;i(); } for(int i=0;i q=new ArrayDeque(); q.add(0); for(int i=0;idist[v]+1){ dist[u]=dist[v]+1; q.add(u); } } } for(int i=0;i