#include using namespace std; #define REP(i,a,b) for(i=a;i'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);} int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;} template void reader(T *x, S *y){reader(x);reader(y);} void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);} template void writerLn(T x){writer(x,'\n');} #define MD 1000000007 int N, M; char mp[1000][1000]; int dx[4] = {-1,0,1,0}, dy[4] = {0,-1,0,1}; int s, t, nn; void nul(int a, int b, int d){ int i, na, nb; rep(i,2){ na = a + dx[(d+i)%4]; nb = b + dy[(d+i)%4]; if(na < 0 || nb < 0 || na >= N || nb >= M) continue; if(mp[na][nb] != '.') continue; mp[na][nb] = '@'; nn++; if(na==s && nb==t) break; nul(na,nb,(d+i)%4); break; } } void del(int a, int b){ int i, na, nb; if(mp[a][b] != '@') return; mp[a][b] = '.'; rep(i,4){ na = a + dx[i]; nb = b + dy[i]; if(na < 0 || nb < 0 || na >= N || nb >= M) continue; del(na,nb); } } int main(){ int i, j, k, d, a, b, ok = 0; int cnt = 0; reader(&N,&M); rep(i,N) reader(mp[i]); rep(i,N) rep(j,M) if(mp[i][j]=='.') cnt++; if(cnt > 4*(N+M)){ writerLn("NO"); return 0; } rep(i,N) rep(j,M) if(mp[i][j]=='.') rep(d,4) if(!ok){ s=i; t=j; nn = 0; nul(i,j,d); if(nn==cnt){ ok=1; break; } mp[i][j]='@'; del(i,j); } writerLn(ok?"YES":"NO"); return 0; }