#include using namespace std; #define rep(i,n) REP(i,0,n) #define REP(i,s,e) for(int i=(s); i<(int)(e); i++) #define repr(i, n) REPR(i, n, 0) #define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--) #define pb push_back #define all(r) r.begin(),r.end() #define rall(r) r.rbegin(),r.rend() #define fi first #define se second typedef long long ll; typedef vector vi; typedef vector vl; typedef pair pii; typedef pair pll; const int INF = 1e9; const ll MOD = 1e9 + 7; double EPS = 1e-8; int H, W; int d[110][110]; bool used[110][110]; int dx[] = {0, -1, 0, 1}; int dy[] = {-1, 0, 1, 0}; bool isOutOfRange(int h, int w) { return h < 0 || h >= H || w < 0 || w >= W; }; bool calc(int y, int x, int pre_y, int pre_x) { used[y][x] = true; bool ret = false; rep(i, 4) { int nx = x + dx[i], ny = y + dy[i]; if(isOutOfRange(ny, nx) || d[y][x] != d[ny][nx] || (ny == pre_y && nx == pre_x)) continue; if(used[ny][nx]) return true; ret |= calc(ny, nx, y, x); } return ret; } int main(){ cin >> W >> H; rep(i, H) rep(j, W) cin >> d[i][j]; bool f = false; rep(i, H) rep(j, W) { if(!used[i][j]) f |= calc(i, j, -1, -1); } string yes = "possible", no = "impossible"; cout << (f ? yes : no) << endl; return 0; }