#include <bits/stdc++.h>
using namespace std;
set<pair<int, int>> st;
bool ans_found = false;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
long long n, m;
char matrix[51][51];
bool visited[51][51];
void dfs(int fromX, int fromY, int x, int y, char color) {
  if (x < 0 || y < 0 || x >= n || y >= m) return;
  if (matrix[x][y] != color) return;
  if (visited[x][y] == true) {
    ans_found = true;
    return;
  }
  visited[x][y] = true;
  for (int i = 0; i < 4; i++) {
    int new_x = x + dx[i];
    int new_y = y + dy[i];
    if (new_x == fromX and new_y == fromY) continue;
    dfs(x, y, new_x, new_y, color);
  }
}
int main(int argc, char** argv) {
  if (argc == 2) {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  }
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> matrix[i][j];
      visited[i][j] = false;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (!visited[i][j]) dfs(-1, -1, i, j, matrix[i][j]);
      if (ans_found) {
        cout << "Yes"
             << "\n";
        return 0;
      }
    }
  }
  cout << "No"
       << "\n";
  return 0;
}
