#include <bits/stdc++.h>
using namespace std;
int n, m;
char my_array[50][50];
bool visited[50][50];
bool dfs(int i, int j, int c_i, int c_j) {
  if (visited[i][j]) {
    return true;
  }
  visited[i][j] = true;
  char col = my_array[i][j];
  bool res = false;
  if (i > 0 && col == my_array[i - 1][j] && c_i != i - 1) {
    res |= dfs(i - 1, j, i, j);
  }
  if (j > 0 && col == my_array[i][j - 1] && c_j != j - 1) {
    res |= dfs(i, j - 1, i, j);
  }
  if (i < n - 1 && col == my_array[i + 1][j] && c_i != i + 1) {
    res |= dfs(i + 1, j, i, j);
  }
  if (j < m - 1 && col == my_array[i][j + 1] && c_j != j + 1) {
    res |= dfs(i, j + 1, i, j);
  }
  return res;
}
int main(int argc, const char* argv[]) {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> my_array[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (!visited[i][j] && dfs(i, j, -1, -1)) {
        cout << "Yes";
        return 0;
      }
    }
  }
  cout << "No";
  return 0;
}
