W, H = map(int, input().split()) field = [] for _ in range(H): field.append(list(map(int, input().split()))) def ok(x, y): return y >= 0 and x >= 0 and x < H and y < W def dfs(x, y): dx = [1, 0, -1, 0] dy = [0, 1, 0, -1] visit[x][y] = True c = (1, 0) for k in range(4): ny = y + dy[k] nx = x + dx[k] if ok(nx, ny) and field[nx][ny] == field[x][y]: if not visit[nx][ny]: res = dfs(nx, ny) c = (c[0] + res[0], c[1] + res[1]) c = (c[0], c[1] + 1) return c visit = [[False for _ in range(W)] for _ in range(H)] ans = False for i in range(H): for j in range(W): if not visit[i][j]: res = dfs(i, j) if res[1] // 2 != res[0] - 1: ans = True if ans: print("possible") else: print("impossible")