from collections import deque from sys import exit W, H = map(int, input().split()) M = [tuple(map(int, input().split())) for _ in range(H)] table = [[None] * W for _ in range(H)] nvisited = {(h, w) for h in range(H) for w in range(W)} def dfs(h0, w0): D = deque() n = M[h0][w0] table[h0][w0] = n D.append((h0, w0, 0, 0)) while D: h, w, dhb, dwb = D.pop() for dh, dw in ((1, 0), (-1, 0), (0, 1), (0, -1)): if dhb == -dh and dwb == -dw: continue if 0 <= h + dh < H and 0 <= w + dw < W: if table[h + dh][w + dw] is None and M[h + dh][w + dw] == n: table[h + dh][w + dw] = n nvisited.remove((h + dh, w + dw)) D.append((h + dh, w + dw, dh, dw)) elif table[h + dh][w + dw] == n: print('possible') exit() while nvisited: h, w = nvisited.pop() dfs(h, w) print('impossible')