#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; #define REP(i,n) for(ll i=0; i<(n); ++i) #define TEN(x) ((ll)1e##x) #define ALL(v) (v).begin(), (v).end() // 0 1 2 3 ll dx[] = { 1, 0, 0, -1 }; ll dy[] = { 0, 1, -1, 0 }; ll m[100][100]; // m[h][w]; ll w, h; bool visited[100][100]; bool is_inner(ll x, ll y) { return !(x < 0 || w <= x || y < 0 || h <= y); } bool bfs(ll x, ll y, ll d) { if (visited[y][x]) return true; visited[y][x] = true; REP(i, 4) if (i != d) if (is_inner(x + dx[i], y + dy[i])) if (m[y][x] == m[y + dy[i]][x + dx[i]]) { if (bfs(x + dx[i], y + dy[i], 3 - i)) return true; } return false; } int main(){ cin >> w >> h; REP(y, h) REP(x, w) cin >> m[y][x]; fill(visited[0], visited[0] + 101 * 101, false); REP(y, h) REP(x, w) if (!visited[y][x]) if (bfs(x, y, -1)) { cout << "possible" << endl; return 0; } cout << "impossible" << endl; return 0; }