#include <bits/stdc++.h>
using namespace std;
int dr[] = {0, 0, -1, 1};
int dc[] = {-1, 1, 0, 0};
const int N = 51;
int visited[N][N];
char grid[N][N];
bool checkNode(int r, int c, int n, int m) {
  return r >= 0 && r < n && c >= 0 && c < m;
}
bool dfs(int n, int m, char color, int r = 0, int c = 0, int cnt = 1,
         int pi = -1, int pj = -1) {
  if (visited[r][c]) {
    return true;
  }
  visited[r][c] = 1;
  bool ret = false;
  for (int i = 0; i < 4; ++i) {
    if (checkNode(r + dr[i], c + dc[i], n, m) &&
        color == grid[r + dr[i]][c + dc[i]] &&
        !(r + dr[i] == pi && c + dc[i] == pj)) {
      ret |= dfs(n, m, color, r + dr[i], c + dc[i], cnt + 1, r, c);
    }
  }
  return ret;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> grid[i][j];
    }
  }
  bool ret = false;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (!visited[i][j]) ret |= dfs(n, m, grid[i][j], i, j);
    }
  }
  if (ret == true) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}
