W,H=map(int,input().split()) M=[list(map(int,input().split())) for i in range(H)] n=W*H+3 # UnionFind Group = [i for i in range(n+1)] # グループ分け Nodes = [1]*(n+1) # 各グループのノードの数 def find(x): while Group[x] != x: x=Group[x] return x def Union(x,y): if find(x) != find(y): if Nodes[find(x)] < Nodes[find(y)]: Nodes[find(y)] += Nodes[find(x)] Nodes[find(x)] = 0 Group[find(x)] = find(y) else: Nodes[find(x)] += Nodes[find(y)] Nodes[find(y)] = 0 Group[find(y)] = find(x) COUNT=[[0]*W for i in range(H)] for i in range(H): for j in range(W): a=M[i][j] count=0 for x,y in [(i+1,j),(i-1,j),(i,j+1),(i,j-1)]: if 0<=x=4: print("possible") else: print("impossible")