package no086; import java.util.Arrays; import java.util.Scanner; public class Main { public static final int[] di = {0,-1,0,1}; public static final int[] dj = {1,0,-1,0}; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); char[][] map = new char[n+2][]; int channels = 0; for(int i=1;i<=n;i++) { map[i] = ("#" + sc.next() + "#").toCharArray() ; } map[0] = new char[m+2]; map[n+1] = new char[m+2]; Arrays.fill(map[0], '#'); Arrays.fill(map[n+1], '#'); for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { if (map[i][j] == '.') { channels++; } } } for(int si=1;si<=n;si++) { for(int sj=1;sj<=m;sj++) { if (map[si][sj] == '#') { continue; } for(int sd=0;sd<4;sd++) { int i = si; int j = sj; int dir = sd; boolean[][] used = new boolean[n+2][m+2]; for(int i2=0;i2<=n+1;i2++) { for(int j2=0;j2<=m+1;j2++) { if (map[i2][j2] == '#') { used[i2][j2] = true; } } } int count = 0; while(true) { if (used[i][j]) { if (i == si && j == sj && count == channels) { System.out.println("YES"); return; } break; } used[i][j] = true; count++; int ni = i + di[dir]; int nj = j + dj[dir]; if (used[ni][nj] && !(ni == si && nj == sj)) { int dir2 = (dir+1) % 4; if (used[i+di[dir2]][j+dj[dir2]] && !(i+di[dir2] == si && j+dj[dir2] == sj)) { break; } dir = dir2; } i += di[dir]; j += dj[dir]; } } } } System.out.println("NO"); } }