from collections import deque W,H = list(map(int, input().split())) M = [] for _ in range(H): M.append(list(map(int, input().split()))) visited = [] for _ in range(H): visited.append([False for _ in range(W)]) dh = [ 0, -1, 0, 1] dw = [-1, 0, 1, 0] def search(y,x): number = M[y][x] que = deque() que.appendleft((y,x)) while len(que) != 0: h,w = que.popleft() visited[h][w] = True for i in range(len(dh)): nh = h + dh[i] nw = w + dw[i] if 0 <= nh < H and 0 <= nw < W and \ visited[nh][nw] == False and M[nh][nw] == number: que.appendleft((nh,nw)) return found() def found(): for h in range(H): for w in range(W): if visited[h][w]: count = 0 for i in range(len(dh)): nh = h + dh[i] nw = w + dw[i] if 0 <= nh < H and 0 <= nw < W and visited[nh][nw]: count = count + 1 if count < 2: return False return True def reset(): for h in range(H): for w in range(W): visited[h][w] = False possible = False for i in range(H): for j in range(W): if search(i,j): possible = True break reset() if possible: break if possible: print('possible') else: print('impossible')