import sys sys.setrecursionlimit(12000) # Input W, H = map(int, input().split()) A = [ list(map(int, input().split())) for i in range(H) ] # DFS Function def dfs(x, y, A, vis): dx = [ 1, 0, -1, 0 ] dy = [ 0, 1, 0, -1 ] vis[x][y] = True cnts = (1, 0) for i in range(4): tx, ty = x + dx[i], y + dy[i] if 0 <= tx and tx < H and 0 <= ty and ty < W and A[tx][ty] == A[x][y]: if not vis[tx][ty]: res = dfs(tx, ty, A, vis) cnts = (cnts[0] + res[0], cnts[1] + res[1]) cnts = (cnts[0], cnts[1] + 1) return cnts # DFS vis = [ [ False ] * W for i in range(H) ] answer = False for i in range(H): for j in range(W): if not vis[i][j]: res = dfs(i, j, A, vis) if res[1] // 2 != res[0] - 1: answer = True # Output if answer: print("possible") else: print("impossible")