import java.util.*;public class BJ2667 { static int N; static int[][] map; static boolean[][] visited; static int[][] d = {{0, -1},{0, 1},{-1, 0},{1, 0}}; static List complexSizes; public static void main(String[] args) { insert(); bfs(); printf(); } public static void insert() { Scanner sc = new Scanner(System.in); N = sc.nextInt(); ..