#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; const int DY[] = {-1,0,1,0}; const int DX[] = {0,1,0,-1}; int W, H, M[102][102], vis[102][102]; bool ok = false; void dfs(int y, int x, int py, int px){ if(vis[y][x] == 1)ok = true; if(vis[y][x])return; vis[y][x] = 1; rep(i, 4){ int ny = DY[i] + y, nx = DX[i] + x; if((ny != py || nx != px) && M[y][x] == M[ny][nx]){ dfs(ny, nx, y, x); } } vis[y][x] = 2; } int main(){ cin >> W >> H; rep(i, H)rep(j, W)scanf("%d", &M[i + 1][j + 1]); rep(i, H)rep(j, W)dfs(i + 1, j + 1, -1, -1); puts(ok ? "possible" : "impossible"); }