#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) #if defined(_MSC_VER) || __cplusplus > 199711L #define aut(r,v) auto r = (v) #else #define aut(r,v) typeof(v) r = (v) #endif #define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it) #define all(o) (o).begin(), (o).end() #define pb(x) push_back(x) #define mp(x,y) make_pair((x),(y)) #define mset(m,v) memset(m,v,sizeof(m)) #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL using namespace std; typedef vector vi; typedef pair pii; typedef vector > vpii; typedef long long ll; typedef vector vl; typedef pair pll; typedef vector > vpll; typedef vector vs; typedef long double ld; template inline void amin(T &x, U y) { if(y < x) x = y; } template inline void amax(T &x, U y) { if(x < y) x = y; } int main() { int N, M; scanf("%d%d", &N, &M); vector A(N); rep(i, N) A[i] = new char[M+1]; rep(i, N) scanf("%s", A[i]); int total = 0; rep(i, N) total += count(A[i], A[i] + M, '.'); vpii ss; rep(i, N) rep(j, M) if(A[i][j] == '.') ss.push_back(mp(i, j)); bool ans = false; rep(ix, 2) rep(sd, 4) { static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0}; int sy = ss[ix].first, sx = ss[ix].second; int d = sd, y = sy, x = sx; vector > v(N, vector(M, false)); int cnt = 0, right = 0; while(1) { v[y][x] = true; ++ cnt; int ny = -1, nx = -1, nd = -1; const int dds[3] = {0, 3, 1}; rep(di, 3) { int dd = dds[di]; if(dd == 1 && right >= 1) continue; int yy = y + dy[(d+dd)%4], xx = x + dx[(d+dd)%4]; if(yy < 0 || yy >= N || xx < 0 || xx >= M) continue; if(A[yy][xx] == '#') continue; if(cnt == total && yy == sy && xx == sx) { }else { if(v[yy][xx]) continue; } ny = yy, nx = xx, nd = (d + dd) % 4; if(dd == 1) ++ right; break; } if(ny == -1) break; if(ny == sy && nx == sx) { ans = true; break; } y = ny, x = nx, d = nd; } } puts(ans ? "YES" : "NO"); return 0; }