from collections import deque dxy = ((1,0),(0,1),(-1,0),(0,-1)) W,H = map(int,raw_input().split()) M = [map(int,raw_input().split()) for i in xrange(H)] Gone = [[False]*W for i in xrange(H)] def bfs(h,num): if Gone[h[1]][h[0]]: return False Q = deque() Q.append(((-1,-1),h)) while Q: b,h = Q.popleft() if Gone[h[1]][h[0]]: return True Gone[h[1]][h[0]] = True for dx,dy in dxy: nxt = (h[0] + dx, h[1] + dy) if nxt != b and 0 <= nxt[0] < W and 0 <= nxt[1] < H and M[nxt[1]][nxt[0]] == num: Q.append((h,nxt)) return False for i in xrange(H): for j in xrange(W): if bfs((j,i),M[i][j]): print "possible" quit() print "impossible"