w,h=map(int,input().split()) m=[[int(i) for i in input().split()]+[0] for _ in range(h)]+[[0]*w] checked=set() def dfs(x,y): if (x,y) in checked: return False r=[(0,-1),(1,0),(-1,0),(0,1)] c=m[y][x] stack=[(-1,x,y)] while len(stack): dir,tx,ty=stack.pop() if m[ty][tx]==c: if (tx,ty) in checked: return True checked.add((tx,ty)) for i,(dx,dy) in enumerate(r): if i!=dir: stack.append((3-i,tx+dx,ty+dy)) print( "possible" if any([dfs(x,y) for x in range(w) for y in range(h)]) else "impossible")