import sys input = sys.stdin.readline W, H = map(int, input().split()) M = [list(map(int, input().split())) for _ in range(H)] used = [[False] * W for _ in range(H)] for si in range(H): for sj in range(W): if used[si][sj]: continue st = [(si, sj, -1, -1)] used[si][sj] = True while st: i, j, pi, pj = st.pop() for di, dj in [(1, 0), (0, 1), (-1, 0), (0, -1)]: ni, nj = i + di, j + dj if 0 <= ni < H and 0 <= nj < W and M[ni][nj] == M[i][j] and (ni, nj) != (pi, pj): if used[ni][nj]: print('possible') exit() st.append((ni, nj, i, j)) used[ni][nj] = True print('impossible')