#include <bits/stdc++.h>
using namespace std;
const int N = 1505;
char g[N][N];
int n, m;
struct point {
  int x, y;
} mark[N][N];
int col[N][N];
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
bool dfs(int x, int y) {
  int A = (x % n + n) % n;
  int B = (y % m + m) % m;
  if (g[A][B] == '#') return 0;
  if (col[A][B] == 1) return (x != mark[A][B].x) || (y != mark[A][B].y);
  col[A][B] = 1;
  mark[A][B] = {x, y};
  for (int i = 0; i < 4; i++) {
    int xx = x + dx[i];
    int yy = y + dy[i];
    if (dfs(xx, yy) == 1) return 1;
  }
  return 0;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i <= n - 1; i++) {
    scanf("%s", g[i]);
  }
  for (int i = 0; i <= n - 1; i++)
    for (int j = 0; j <= m - 1; j++) {
      if (g[i][j] == 'S') {
        if (dfs(i, j) == 1)
          cout << "Yes" << endl;
        else
          cout << "No" << endl;
      }
    }
}
