#include"bits/stdc++.h" //#include using namespace std; #define print(x) cout<= 0 && nx < w&&ny >= 0 && ny < h))continue; if (m[ny][nx] != m[y][x])continue; if (flag[ny][nx])return 1; if (dfs(ny, nx, (k + 2) % 4))return 1; } return 0; } int main() { cin >> h >> w; rep(j, 0, h) { rep(i, 0, w) { cin >> m[i][j]; } } bool f = 0; rep(j, 0, h) { rep(i, 0, w) { if (dfs(i, j, 0)) { print("possible"); return 0; } } } print("impossible"); }