import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) DX = (-1, 0, 1, 0, -1, -1, 1, 1) DY = (0, 1, 0, -1, -1, 1, -1, 1) DX = DX[:4] DY = DY[:4] W, H = map(int, input().split()) G = tuple(tuple(map(int, input().split())) for _ in range(H)) vis = [[0]*W for _ in range(H)] def dfs(num, x, y, px, py): vis[x][y] = 1 for dx, dy in zip(DX, DY): nx = x + dx ny = y + dy if (nx, ny) == (px, py): continue if 0 <= nx < H and 0 <= ny < W and G[nx][ny] == num: if vis[nx][ny]: return True ok = dfs(num, nx, ny, x, y) if ok: return True vis[x][y] = 0 return False used = set() for i in range(H): for j, v in enumerate(G[i]): if v in used: continue if dfs(v, i, j, -1, -1): print("possible") exit() used.add(v) print("impossible")