# -*- coding: utf-8 -*- W, H = map(int, raw_input().split()) matA = [[0 for i in range(0, W)] for j in range(0, H)] for i in range(0, H): tmp = map(int, (raw_input().split())) for j in range(0, W): matA[i][j] = tmp[j] matB = [[0 for i in range(0, W)] for j in range(0, H)] flag = 0 delx = (0, 1, -1, 0, 0) dely = (0, 0, 0, 1, -1) delm = (0, 2, 1, 4, 3) staci = [] stacj = [] stacd = [] cnt = 0 num = 0 for i in range(0, H): for j in range(0, W): if matB[i][j] == 0: cnt += 1 num = matA[i][j] staci.append(i) stacj.append(j) stacd.append(0) while len(staci) != 0: ii = staci.pop() jj = stacj.pop() di = stacd.pop() matB[ii][jj] = cnt for k in range(1, 5): iii = ii + dely[k] jjj = jj + delx[k] if 0 <= iii < H and 0 <= jjj < W: if matA[ii][jj] == matA[iii][jjj] and k != delm[di]: staci.append(iii) stacj.append(jjj) stacd.append(k) if matB[ii][jj] == matB[iii][jjj] and k != delm[di]: print "possible" exit() print "impossible"