#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
const int N = 55;
char g[N][N];
bool vis[N][N];
int dr[4] = {-1, 1, 0, 0}, dc[4] = {0, 0, -1, 1};
int n, m;
bool dfs(int x, int y, int px, int py, char color){
vis[x][y] = true;
for(int k = 0; k < 4; k++){
int nx = x + dr[k], ny = y + dc[k];
if(nx < 1 || nx > n || ny < 1 || ny > m) continue;
if(g[nx][ny] != color) continue;
if(nx == px && ny == py) continue; // 父节点
if(vis[nx][ny]) return true; // 回到已访问节点 → 有环
if(dfs(nx, ny, x, y, color)) return true;
}
return false;
}
int main(){
scanf("%d%d", &n, &m);
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
int c = getchar();
while(c == ' ' || c == '\n' || c == '\r' || c == '\t') c = getchar();
g[i][j] = c;
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(!vis[i][j]){
if(dfs(i, j, 0, 0, g[i][j])){
printf("Yes\n");
return 0;
}
}
}
}
printf("No\n");
return 0;
}