import sys def inner_range(y, x): return y >= 0 and x >= 0 and y < H and x < W def check(y, x, py, px): matrix[y][x] = True for dy, dx in zip(DY, DX): ny = y + dy nx = x + dx if nx == px and ny == py: continue if 0 <= ny < H and 0 <= nx < W and area[y][x] == area[ny][nx]: if matrix[ny][nx]: return True if check(ny, nx, y, x): return True return False W, H = map(int, input().split()) matrix = [[False for _ in range(W)] for _ in range(H)] DY = (1, 0, -1, 0) DX = (0, 1, 0, -1) area = [] for _ in range(H): area.append(list(map(int, input().split()))) judge = False for i in range(H): for j in range(W): if matrix[i][j]: continue if check(i, j, -1, -1): print("possible") sys.exit() print("impossible")