#include using namespace std; using LL = long long; using ULL = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) struct dsu { int N; vector V; dsu(int n) { N = n; V.resize(N); rep(i, N) V[i] = i; } int leader(int a) { if (V[a] == a) return a; return V[a] = leader(V[a]); } void merge(int a, int b) { V[leader(a)] = leader(b); } bool same(int a, int b) { return leader(a) == leader(b); } }; int W, H; int M[100][100]; int main() { cin >> W >> H; rep(y, H) rep(x, W) cin >> M[x][y]; dsu G(H * W); bool possible = false; rep(y, H) rep(x, W - 1) if (M[x][y] == M[x + 1][y]) { int a = y * W + x, b = a + 1; if (G.same(a, b)) possible = true; G.merge(a, b); } rep(y, H - 1) rep(x, W) if (M[x][y] == M[x][y + 1]) { int a = y * W + x, b = a + W; if (G.same(a, b)) possible = true; G.merge(a, b); } cout << (possible ? "possible" : "impossible") << endl; return 0; }