#include <bits/stdc++.h>
using namespace std;
const int N = 1502;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, -1, 1};
int stage[N][N][2];
int prex[N][N], prey[N][N];
char ch[N][N];
bool vis[N][N];
int main() {
  int n, m;
  cin >> n >> m;
  int x, y;
  memset(prex, -1, sizeof(prex));
  memset(prey, -1, sizeof(prey));
  for (int i = 0; i < n; ++i) {
    cin >> ch[i];
    for (int j = 0; j < m; ++j)
      if ((ch[i][j] | 32) == 's') {
        x = i, y = j;
      }
  }
  queue<pair<int, int> > q;
  q.push(make_pair(x, y));
  bool can = false;
  stage[x][y][0] = stage[x][y][1] = 1;
  vis[x][y] = true;
  int cnt[2];
  while (!q.empty()) {
    pair<int, int> t = q.front();
    cnt[0] = stage[t.first][t.second][0];
    cnt[1] = stage[t.first][t.second][1];
    q.pop();
    for (int i = 0; i < 4; ++i) {
      x = t.first + dx[i];
      y = t.second + dy[i];
      int flag[2] = {0, 0};
      if (x < 0)
        x += n, flag[0] = -1;
      else if (x >= n)
        x -= n, flag[0] = 1;
      if (y < 0)
        y += m, flag[1] = -1;
      else if (y >= m)
        y -= m, flag[1] = 1;
      if (x == prex[t.first][t.second] && y == prey[t.first][t.second])
        continue;
      if (stage[x][y][0] != 0 || stage[x][y][1] != 0) {
        for (int i = 0; i < 2; ++i) can |= (stage[x][y][i] != cnt[i] + flag[i]);
      } else if (!vis[x][y] && ch[x][y] != '#') {
        q.push(make_pair(x, y));
        for (int i = 0; i < 2; ++i) stage[x][y][i] = cnt[i] + flag[i];
        vis[x][y] = true;
        prex[x][y] = t.first;
        prey[x][y] = t.second;
      }
    }
    if (can) break;
  }
  puts(can ? "Yes" : "No");
  return 0;
}
