include<bits/stdc++.h>
include
include<math.h>
define ll long long
using namespace std;
int n, m;
char p[505][505];
bool judge[505][505];
int dx[4] = {-1,0,1,0};
int dy[4] = {0,1,0,-1};//方向
bool flag;
bool check(int a,int b){
if(a < 1||a > n)return 0;
if(b < 1||b > m)return 0;
return 1;
}
void dfs(int x,int y){
if(p[x][y] == 'E'){
flag = 1;
return ;
}
for(int i = 0;i < 4;i++){
int tx = x + dx[i];
int ty = y + dy[i];
if(check(tx,ty)&&!judge[tx][ty]&&p[tx][ty]!='#'){//判断是否超过地图界限以及是否走过;
judge[tx][ty] = 1;
dfs(tx,ty);
}
}
}
int main(){
while(cin>>n>>m){ int x1, y1; flag = 0; memset(judge,0,sizeof(judge)); for(int i = 1;i<= n;i++){ for(int j = 1;j <= m;j++){ cin>>p[i][j]; if(p[i][j] == 'S'){//记录起始点 x1 = i; y1 = j; } } } judge[x1][y1] = 1;//标记起点已经走过 dfs(x1,y1); if(flag == 1)cout<<"Yes"<<endl; else cout<<"No"<<endl; } return 0;
}