#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int lcm(long long int a, long long int b) {
  return a * b / gcd(a, b);
}
long long int n, m;
long long int vis[50][50], a[50][50];
int flag = 0;
int ch = 'A';
void dfs(long long int i, long long int j) {
  if (flag == 1) {
    return;
  } else if (i >= n || i < 0 || j >= m || j < 0) {
    return;
  } else if (a[i][j] != ch) {
    return;
  } else if (vis[i][j] == 1) {
    return;
  } else if (vis[i][j] == 2) {
    flag = 1;
    return;
  }
  vis[i][j] = 1;
  dfs(i, j + 1);
  dfs(i, j - 1);
  dfs(i + 1, j);
  dfs(i - 1, j);
  vis[i][j] = 2;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (size_t i = 0; i < 50; i++) {
    for (size_t j = 0; j < 50; j++) {
      vis[i][j] = 0;
    }
  }
  for (size_t i = 0; i < n; i++) {
    string t;
    cin >> t;
    for (size_t j = 0; j < t.size(); j++) {
      a[i][j] = t[j] - 'A';
    }
  }
  for (size_t i = 0; i < n; i++) {
    for (size_t j = 0; j < m; j++) {
      ch = a[i][j];
      if (flag == 1) {
        cout << "Yes\n";
        return 0;
      }
      dfs(i, j);
      for (size_t i = 0; i < 50; i++) {
        for (size_t j = 0; j < 50; j++) {
          vis[i][j] = 0;
        }
      }
    }
  }
  if (flag == 0) cout << "No\n";
  return 0;
}
