#include <bits/stdc++.h>
using namespace std;
int n, m;
string board[51];
bool visited[51][51];
bool findCycle = false;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
void dfs(int x, int y, int fromX, int fromY, char needColor)
{
if(x < 0 || x >= n || y < 0 || y >= m) return;
if(board[x][y] != needColor) return;
if(visited[x][y])
{
findCycle = true;
return;
}
visited[x][y] = true;
for(int f = 0; f < 4; f++)
{
int nextX = x + dx[f];
int nextY = y + dy[f];
if(nextX == fromX && nextY == fromY) continue;
dfs(nextX, nextY, x, y, needColor);
}
}
int MAIN()
{
cin >> n >> m;
for(int i = 0; i < n; i++)
cin >> board[i];
memset(visited, false, sizeof(visited));
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
if(!visited[i][j])
dfs(i, j, -1, -1, board[i][j]);
cout << (findCycle ? "Yes" : "No") << endl;
return 0;
}
int main()
{
#ifdef LOCAL_TEST
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
ios :: sync_with_stdio(false);
cout << fixed << setprecision(16);
return MAIN();
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbiwgbTsKc3RyaW5nIGJvYXJkWzUxXTsKYm9vbCB2aXNpdGVkWzUxXVs1MV07CmJvb2wgZmluZEN5Y2xlID0gZmFsc2U7CmludCBkeFtdID0gezEsIC0xLCAwLCAwfTsKaW50IGR5W10gPSB7MCwgMCwgMSwgLTF9OwoKdm9pZCBkZnMoaW50IHgsIGludCB5LCBpbnQgZnJvbVgsIGludCBmcm9tWSwgY2hhciBuZWVkQ29sb3IpCnsKCWlmKHggPCAwIHx8IHggPj0gbiB8fCB5IDwgMCB8fCB5ID49IG0pIHJldHVybjsKCWlmKGJvYXJkW3hdW3ldICE9IG5lZWRDb2xvcikgcmV0dXJuOwoJaWYodmlzaXRlZFt4XVt5XSkKCXsKCQlmaW5kQ3ljbGUgPSB0cnVlOwoJCXJldHVybjsKC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