import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import java.util.NoSuchElementException; public class Main { public static void main(String args[]) { FastScanner scanner = new FastScanner(); w=scanner.nextInt(); h=scanner.nextInt(); bord=new char[h][w]; tarX1=new ArrayList<>(); tarY1=new ArrayList<>(); tarX2=new ArrayList<>(); tarY2=new ArrayList<>(); for(int i=0;i tarX1; static List tarY1; static List tarX2; static List tarY2; private static void dfs1(int i, int j) { tarX1.add(j); tarY1.add(i); check4Neighborhood1(j,i); } private static void check4Neighborhood1(int x, int y) { for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if ((i == 0 && j != 0) || (i != 0 && j == 0)) { int tarX = j + x; int tarY = i + y; if (0 <= tarX && tarX <= bord[0].length - 1 && 0 <= tarY && tarY <= bord.length - 1) { if (bord[tarY][tarX]=='.'&&check(tarX,tarY,tarX1,tarY1)) { dfs1(tarY,tarX); } } } } } } private static boolean check(int tarX, int tarY, List tarX12, List tarY12) { for(int i=0;i Integer.MAX_VALUE) throw new NumberFormatException(); return (int) nl; } public double nextDouble() { return Double.parseDouble(next());} }