from collections import deque w,h=map(int,input().split()) M=[list(map(int,input().split())) for _ in range(h)] visit=[[0 for _ in range(w)] for _ in range(h)] for i in range(h): for j in range(w): if visit[i][j]: continue Q=deque() visit[i][j]=1 Q.append((i,j)) while(Q): y,x=Q.pop() cnt=0 if y!=0: if M[y-1][x]==M[y][x]: if visit[y-1][x]: cnt+=1 else: visit[y-1][x]=1 Q.append((y-1,x)) if y!=h-1: if M[y+1][x]==M[y][x]: if visit[y+1][x]: cnt+=1 else: visit[y+1][x]=1 Q.append((y+1,x)) if x!=0: if M[y][x-1]==M[y][x]: if visit[y][x-1]: cnt+=1 else: visit[y][x-1]=1 Q.append((y,x-1)) if x!=w-1: if M[y][x+1]==M[y][x]: if visit[y][x+1]: cnt+=1 else: visit[y][x+1]=1 Q.append((y,x+1)) if cnt>=2: print("possible") exit() print("impossible")