#include <bits/stdc++.h>
using namespace std;
char BUFFER[100000 + 5];
bool readn(int &n) { return scanf("%d", &n) == 1; }
bool readl(long long &n) { return scanf("%I64d", &n) == 1; }
bool readd(double &n) { return scanf("%lf", &n) == 1; }
bool reads(string &s) {
  s = "";
  int n = scanf("%s", BUFFER);
  if (n == 1) s = BUFFER;
  return n == 1;
}
bool readln(string &s) {
  char *valid = gets(BUFFER);
  if (valid) s = BUFFER;
  return ((bool)valid);
}
void Print(long long &n, bool printNewLine = true) {
  printNewLine ? printf("%I64d\n", n) : printf("%I64d", n);
}
vector<string> v;
queue<pair<int, int> > Q;
void Push(int i, int j, int n, int m) {
  i += n;
  j += m;
  i %= n;
  j %= m;
  if (v[i][j] != '.') return;
  v[i][j] = 'S';
  Q.push(make_pair(i, j));
}
void bfs(int i, int j, int n, int m) {
  while (!Q.empty()) Q.pop();
  Q.push(make_pair(i, j));
  while (!Q.empty()) {
    i = Q.front().first;
    j = Q.front().second;
    Q.pop();
    Push(i + 1, j, n, m);
    Push(i - 1, j, n, m);
    Push(i, j + 1, n, m);
    Push(i, j - 1, n, m);
  }
}
void getPos(int &i, int &j) {
  for (i = 0; i < ((int)v.size()); ++i)
    for (j = 0; j < ((int)v[0].size()); ++j)
      if (v[i][j] == 'S') return;
}
bool can() {
  int i, j, ti, tj, n, m;
  cin >> n >> m;
  v.resize(n);
  for (i = 0; i < ((int)v.size()); ++i) cin >> v[i];
  getPos(ti, tj);
  string s;
  for (i = 0; i < n; ++i) {
    v[i] += v[i];
    s = v[i];
    v.push_back(s);
  }
  v[ti][tj] = '.';
  v[ti + n][tj] = '.';
  v[ti][tj + m] = '.';
  v[ti + n][tj + m] = '.';
  bfs(ti, tj, n + n, m + m);
  return (v[ti + n][tj] == 'S' || v[ti][tj + m] == 'S' ||
          v[ti + n][tj + m] == 'S');
}
int main() {
  if (can())
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}
