package no277; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.InputMismatchException; import java.util.NoSuchElementException; import java.util.Queue; public class Main { @SuppressWarnings("unchecked") public static void main(String[] args) { IO io = new IO(); int n = io.nextInt(); ArrayList[] graph = new ArrayList[n]; for(int i=0;i(); } for(int i=0;i q = new ArrayDeque(); q.add(0); dist[0] = 0; for(int i=0;i dist[v] + 1) { dist[u] = dist[v] + 1; q.offer(u); } } } for(int i=0;i Integer.MAX_VALUE) { throw new NumberFormatException(); } return (int) nl; } public char nextChar() { if (!hasNext()) { throw new NoSuchElementException(); } return (char) readByte(); } public double nextDouble() { return Double.parseDouble(next());} public int[] nextIntArray(int n) { int[] a = new int[n]; for(int i=0;i