import collections directions = ((-1, 0), (0, -1), (1, 0), (0, 1)) def bfs(sx, sy, w, h, field, visited): queue = collections.deque() queue.append((sx, sy, -1, -1)) visited[sy][sx] = True while queue: x, y, px, py = queue.popleft() for dx, dy in directions: nx = x + dx ny = y + dy if (not (0 <= nx < w and 0 <= ny < h) or nx == px and ny == py or field[y][x] != field[ny][nx]): continue if visited[ny][nx]: return True visited[ny][nx] = True queue.append((nx, ny, x, y)) return False def solve(): w, h = map(int, raw_input().split()) field = [map(int, raw_input().split()) for _ in xrange(h)] visited = [[False] * w for _ in xrange(h)] for y in xrange(h): for x in xrange(w): if visited[y][x]: continue if bfs(x, y, w, h, field, visited): return True return False print 'possible' if solve() else 'impossible'