#include using namespace std; typedef long long int ll; typedef pair pii; typedef vector vi; typedef vector > vii; #define rrep(i, m, n) for(int (i)=(m); (i)<(n); (i)++) #define erep(i, n) for(int (i)=1; (i)<=(n); (i)++) #define rep(i, n) for(int (i)=0; (i)<(n); (i)++) #define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--) #define erev(i, n) for(int (i)=(n); (i)>=1; (i)--) #define rev(i, n) for(int (i)=(n)-1; (i)>=0; (i)--) #define EACH(v) (v).begin(), (v).end() #define minup(m, x) (m=min(m, x)) #define maxup(m, x) (m=max(m, x)) #define mp make_pair #define pb push_back #define INF 1000000000 #define MOD 1000000009 #define EPS 1E-9 #define MAX_M 100 #define MAX_N 100 inline bool check(int x, int y); bool dfs(int px, int py, int hx, int hy, int cnt, int cntRight, int cntLeft); int n, m; char a[MAX_N][MAX_M]; int cnt; bool used[MAX_N][MAX_M]; int sx, sy; int main() { cin >> n >> m; rep(i, n) rep(j, m){ cin >> a[i][j]; if(a[i][j] == '.'){ sx = i; sy = j; cnt += 1; } } bool flag = false; used[sx][sy] = true; if(check(sx+1, sy )) flag |= dfs(sx, sy, sx+1, sy, cnt, 0, 0); if(check(sx, sy+1)) flag |= dfs(sx, sy, sx, sy+1, cnt, 0, 0); if(check(sx-1, sy )) flag |= dfs(sx, sy, sx-1, sy, cnt, 0, 0); puts(flag ? "YES" : "NO"); return 0; } inline bool check(int x, int y) { return 0<=x&&x 6) return false; nx = hx - hy + py; ny = hy + hx - px; } if(i == 2 && cntRight == 0){ nx = hx + hy - py; ny = hy - hx + px; cntRight = 1; } if(!check(nx, ny)) continue; if(a[nx][ny] == '#') continue; if((mp(nx, ny) == mp(sx, sy)) && (cnt == 2)) return true; if(used[nx][ny]) continue; if(dfs(hx, hy, nx, ny, cnt-1, cntRight, cntLeft + i%2)) return true; if(i == 2) cntRight = 0; } used[hx][hy] = false; return false; }