You are given two $n \times m$ matrices containing integers. A sequence of integers is strictly increasing if each next number is greater than the previous one. A row is strictly increasing if all numbers from left to right are strictly increasing. A column is strictly increasing if all numbers from top to bottom are strictly increasing. A matrix is increasing if all rows are strictly increasing and all columns are strictly increasing. 

For example, the matrix $\begin{bmatrix} 9&10&11\\ 11&12&14\\ \end{bmatrix}$ is increasing because each individual row and column is strictly increasing. On the other hand, the matrix $\begin{bmatrix} 1&1\\ 2&3\\ \end{bmatrix}$ is not increasing because the first row is not strictly increasing.

Let a position in the $i$-th row (from top) and $j$-th column (from left) in a matrix be denoted as $(i, j)$. 

In one operation, you can choose any two numbers $i$ and $j$ and swap the number located in $(i, j)$ in the first matrix with the number in $(i, j)$ in the second matrix. In other words, you can swap two numbers in different matrices if they are located in the corresponding positions.

You would like to make both matrices increasing by performing some number of operations (possibly none). Determine if it is possible to do this. If it is, print "Possible", otherwise, print "Impossible".


-----Input-----

The first line contains two integers $n$ and $m$ ($1 \leq n,m \leq 50$) — the dimensions of each matrix.

Each of the next $n$ lines contains $m$ integers $a_{i1}, a_{i2}, \ldots, a_{im}$ ($1 \leq a_{ij} \leq 10^9$) — the number located in position $(i, j)$ in the first matrix.

Each of the next $n$ lines contains $m$ integers $b_{i1}, b_{i2}, \ldots, b_{im}$ ($1 \leq b_{ij} \leq 10^9$) — the number located in position $(i, j)$ in the second matrix.


-----Output-----

Print a string "Impossible" or "Possible".


-----Examples-----
Input
2 2
2 10
11 5
9 4
3 12

Output
Possible

Input
2 3
2 4 5
4 5 6
3 6 7
8 10 11

Output
Possible

Input
3 2
1 3
2 4
5 10
3 1
3 6
4 8

Output
Impossible



-----Note-----

The first example, we can do an operation on the top left and bottom right cells of the matrices. The resulting matrices will be $\begin{bmatrix} 9&10\\ 11&12\\ \end{bmatrix}$ and $\begin{bmatrix} 2&4\\ 3&5\\ \end{bmatrix}$.

In the second example, we don't need to do any operations.

In the third example, no matter what we swap, we can't fix the first row to be strictly increasing in both matrices.

Difficulty: MEDIUM
Tags: Complete search

Greedy algorithms
Skill types: Complete search

Greedy algorithms

Starter code:

Solutions:
(n, m) = [int(i) for i in input().split()]
a = []
b = []
for i in range(n):
	a.append([int(i) for i in input().split()])
for i in range(n):
	b.append([int(i) for i in input().split()])
flag = 0
for i in range(n):
	for j in range(m):
		if a[i][j] > b[i][j]:
			(a[i][j], b[i][j]) = (b[i][j], a[i][j])
flag = 0
for i in range(n):
	for j in range(m - 1):
		if a[i][j] >= a[i][j + 1] or b[i][j] >= b[i][j + 1]:
			flag = 1
			break
for j in range(m):
	for i in range(n - 1):
		if a[i][j] >= a[i + 1][j] or b[i][j] >= b[i + 1][j]:
			flag = 1
			break
if flag:
	print('Impossible')
else:
	print('Possible')


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
(a, b) = ([], [])
(n, m) = f()
for _ in range(n):
	a.append(il())
for _ in range(n):
	b.append(il())
for i in range(n):
	for j in range(m):
		x = min(a[i][j], b[i][j])
		y = max(a[i][j], b[i][j])
		a[i][j] = x
		b[i][j] = y
for i in range(1, n):
	if a[i][0] <= a[i - 1][0] or b[i][0] <= b[i - 1][0]:
		exit(print('Impossible'))
for i in range(1, m):
	if a[0][i] <= a[0][i - 1] or b[0][i] <= b[0][i - 1]:
		exit(print('Impossible'))
for i in range(1, n):
	for j in range(1, m):
		if a[i][j] <= a[i - 1][j] or a[i][j] <= a[i][j - 1] or b[i][j] <= b[i - 1][j] or (b[i][j] <= b[i][j - 1]):
			exit(print('Impossible'))
print('Possible')


def check(A, H, W):
	for h in range(H):
		for w in range(W - 1):
			if A[h][w] >= A[h][w + 1]:
				return False
	for w in range(W):
		for h in range(H - 1):
			if A[h][w] >= A[h + 1][w]:
				return False
	return True

def solve():
	(H, W) = list(map(int, input().split()))
	A = [list(map(int, input().split())) for i in range(H)]
	B = [list(map(int, input().split())) for i in range(H)]
	if check(A, H, W) and check(B, H, W):
		return 'Possible'
	for h in range(H):
		for w in range(W):
			if A[h][w] > B[h][w]:
				(A[h][w], B[h][w]) = (B[h][w], A[h][w])
	if check(A, H, W) and check(B, H, W):
		return 'Possible'
	return 'Impossible'
print(solve())


(n, m) = map(int, input().split())
m1 = [0] * (n + 2)
m2 = [0] * (n + 2)
m1[0] = [0] * (m + 2)
m2[0] = [0] * (m + 2)
m1[n + 1] = [0] * (m + 2)
m2[n + 1] = [0] * (m + 2)
for i in range(1, n + 1):
	m1[i] = [0] + list(map(int, input().split())) + [0]
for i in range(1, n + 1):
	m2[i] = [0] + list(map(int, input().split())) + [0]
for i in range(1, n + 1):
	for j in range(1, m + 1):
		(m1[i][j], m2[i][j]) = (min(m1[i][j], m2[i][j]), max(m1[i][j], m2[i][j]))
flag = True
t = False
for i in range(1, n + 1):
	for j in range(1, m + 1):
		if m1[i][j] <= m1[i - 1][j] or m1[i][j] <= m1[i][j - 1] or m2[i][j] <= m2[i - 1][j] or (m2[i][j] <= m2[i][j - 1]):
			print('Impossible')
			flag = False
			t = True
			break
	if t:
		break
if flag:
	print('Possible')


import math
(n, m) = map(int, input().split())
l1 = [list(map(int, input().split())) for i in range(n)]
l2 = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
	for j in range(m):
		(l1[i][j], l2[i][j]) = (min(l1[i][j], l2[i][j]), max(l1[i][j], l2[i][j]))
ans = True
for i in range(n - 1):
	for j in range(m):
		if l1[i][j] >= l1[i + 1][j] or l2[i][j] >= l2[i + 1][j]:
			ans = False
for i in range(n):
	for j in range(m - 1):
		if l1[i][j] >= l1[i][j + 1] or l2[i][j] >= l2[i][j + 1]:
			ans = False
if ans == True:
	print('Possible')
else:
	print('Impossible')


n_m = input().split()
n = int(n_m[0])
m = int(n_m[1])
matrix = [[[None, None] for _ in range(m)] for _ in range(n)]
for i in range(n):
	nums = input().split()
	for j in range(m):
		num = int(nums[j])
		matrix[i][j][0] = num
for i in range(n):
	nums = input().split()
	for j in range(m):
		num = int(nums[j])
		matrix[i][j][1] = num
		if matrix[i][j][0] > matrix[i][j][1]:
			(matrix[i][j][0], matrix[i][j][1]) = (matrix[i][j][1], matrix[i][j][0])
r = True
for i in range(n):
	pre = -1
	for j in range(m):
		if matrix[i][j][0] <= pre:
			r = False
			break
		pre = matrix[i][j][0]
if r != False:
	for j in range(m):
		pre = -1
		for i in range(n):
			if matrix[i][j][0] <= pre:
				r = False
				break
			pre = matrix[i][j][0]
if r != False:
	for i in range(n):
		pre = -1
		for j in range(m):
			if matrix[i][j][1] <= pre:
				r = False
				break
			pre = matrix[i][j][1]
if r != False:
	for j in range(m):
		pre = -1
		for i in range(n):
			if matrix[i][j][1] <= pre:
				r = False
				break
			pre = matrix[i][j][1]
if r == False:
	print('Impossible')
else:
	print('Possible')


def main():
	(n, m) = map(int, input().strip().split())
	a = [list(map(int, input().strip().split())) for _ in range(n)]
	b = [list(map(int, input().strip().split())) for _ in range(n)]
	possible = True
	for row in range(n):
		last_a = a[row][0]
		last_b = b[row][0]
		for col in range(1, m):
			if last_a < a[row][col] and last_b < b[row][col]:
				last_a = a[row][col]
				last_b = b[row][col]
			else:
				(a[row][col], b[row][col]) = (b[row][col], a[row][col])
				if last_a < a[row][col] and last_b < b[row][col]:
					last_a = a[row][col]
					last_b = b[row][col]
				else:
					possible = False
					break
	if possible:
		for col in range(m):
			last_a = a[0][col]
			last_b = b[0][col]
			for row in range(1, n):
				if last_a < a[row][col] and last_b < b[row][col]:
					last_a = a[row][col]
					last_b = b[row][col]
				else:
					(a[row][col], b[row][col]) = (b[row][col], a[row][col])
					if last_a < a[row][col] and last_b < b[row][col]:
						last_a = a[row][col]
						last_b = b[row][col]
					else:
						possible = False
						break
	print('Possible' if possible else 'Impossible')
main()


from math import *
from itertools import *
(n, m) = map(int, input().split(' '))
a = []
b = []
for i in range(n):
	x = list(map(int, input().split(' ')))
	a.append(x)
for i in range(n):
	x = list(map(int, input().split(' ')))
	b.append(x)
c = []
for i in range(n):
	d = []
	for j in range(m):
		d.append([0, 0])
	c.append(d)
for i in range(n):
	for j in range(m):
		c[i][j][0] = min(a[i][j], b[i][j])
		c[i][j][1] = max(a[i][j], b[i][j])
flg = 0
for i in range(n):
	c1 = -1
	for j in range(m):
		if c[i][j][0] <= c1:
			flg = 1
		c1 = c[i][j][0]
for j in range(m):
	c1 = -1
	for i in range(n):
		if c[i][j][0] <= c1:
			flg = 1
		c1 = c[i][j][0]
for i in range(n):
	c1 = -1
	for j in range(m):
		if c[i][j][1] <= c1:
			flg = 1
		c1 = c[i][j][1]
for j in range(m):
	c1 = -1
	for i in range(n):
		if c[i][j][1] <= c1:
			flg = 1
		c1 = c[i][j][1]
if flg == 0:
	print('Possible')
else:
	print('Impossible')


def isincreasing(mat):
	n = len(mat)
	m = len(mat[0])
	for i in range(n):
		for j in range(1, m):
			if mat[i][j] <= mat[i][j - 1]:
				return False
	for j in range(m):
		for i in range(1, n):
			if mat[i][j] <= mat[i - 1][j]:
				return False
	return True
(n, m) = map(int, input().split())
a = []
b = []
for _ in range(n):
	row = [int(i) for i in input().split()]
	a.append(row)
for _ in range(n):
	row = [int(i) for i in input().split()]
	b.append(row)
minm = []
maxm = []
for i in range(n):
	temp1 = []
	temp2 = []
	for j in range(m):
		temp1 += [min(a[i][j], b[i][j])]
		temp2 += [max(a[i][j], b[i][j])]
	minm.append(temp1)
	maxm.append(temp2)
if isincreasing(minm) and isincreasing(maxm):
	print('Possible')
else:
	print('Impossible')


(n, m) = list(map(int, input().split()))
a = []
b = []
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(n):
	b.append(list(map(int, input().split())))
for i in range(n):
	for j in range(m):
		(a[i][j], b[i][j]) = (min(a[i][j], b[i][j]), max(a[i][j], b[i][j]))
for i in range(n):
	for j in range(m - 1):
		if a[i][j] >= a[i][j + 1]:
			print('Impossible')
			exit()
		if b[i][j] >= b[i][j + 1]:
			print('Impossible')
			exit()
for j in range(m):
	for i in range(n - 1):
		if a[i][j] >= a[i + 1][j]:
			print('Impossible')
			exit()
		if b[i][j] >= b[i + 1][j]:
			print('Impossible')
			exit()
print('Possible')


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve():
	(n, m) = sep()
	a = [0] * n
	b = [0] * n
	for i in range(n):
		a[i] = lis()
	for i in range(n):
		b[i] = lis()
	for i in range(n):
		for j in range(m):
			if a[i][j] > b[i][j]:
				(a[i][j], b[i][j]) = (b[i][j], a[i][j])
	for i in range(n):
		for j in range(1, m):
			if b[i][j] > b[i][j - 1]:
				continue
			else:
				print('Impossible')
				return
	for j in range(m):
		for i in range(1, n):
			if b[i][j] > b[i - 1][j]:
				continue
			else:
				print('Impossible')
				return
	for i in range(n):
		for j in range(1, m):
			if a[i][j] > a[i][j - 1]:
				continue
			else:
				print('Impossible')
				return
	for j in range(m):
		for i in range(1, n):
			if a[i][j] > a[i - 1][j]:
				continue
			else:
				print('Impossible')
				return
	print('Possible')
testcase(1)


t = list(map(int, input().split(' ')))
n = t[0]
m = t[1]
a = []
b = []
for i in range(n):
	t = list(map(int, input().split(' ')))
	a.append(t)
for i in range(n):
	t = list(map(int, input().split(' ')))
	b.append(t)
for i in range(n):
	for j in range(1, m):
		if a[i][j] > a[i][j - 1] and b[i][j] > b[i][j - 1]:
			continue
		elif a[i][j] <= a[i][j - 1] or b[i][j] <= b[i][j - 1]:
			if b[i][j] <= a[i][j - 1] or a[i][j] <= b[i][j - 1]:
				print('Impossible')
				exit()
			q = a[i][j]
			a[i][j] = b[i][j]
			b[i][j] = q
for i in range(1, n):
	for j in range(m):
		if a[i][j] > a[i - 1][j] and b[i][j] > b[i - 1][j]:
			continue
		elif a[i][j] <= a[i - 1][j] or b[i][j] <= b[i - 1][j]:
			if b[i][j] <= a[i - 1][j] or a[i][j] <= b[i - 1][j]:
				print('Impossible')
				exit()
			q = a[i][j]
			a[i][j] = b[i][j]
			b[i][j] = q
print('Possible')


(n, m) = list(map(int, input().strip().split()))
x = [list(map(int, input().strip().split())) for _ in range(n)]
y = [list(map(int, input().strip().split())) for _ in range(n)]

def row_check(arr):
	for i in range(n):
		b = -1
		for j in range(m):
			if arr[i][j] <= b:
				print('Impossible')
				exit()
			b = arr[i][j]

def col_check(arr):
	for j in range(m):
		b = -1
		for i in range(n):
			if arr[i][j] <= b:
				print('Impossible')
				exit()
			b = arr[i][j]
for i in range(n):
	for j in range(m):
		a = x[i][j]
		b = y[i][j]
		if a > b:
			x[i][j] = b
			y[i][j] = a
row_check(x)
col_check(x)
row_check(y)
col_check(y)
print('Possible')


def check_increasing(matrix):
	return all((all((j < k for (j, k) in zip(matrix[i], matrix[i + 1]))) for i in range(len(matrix) - 1))) and all((all((j < k for (j, k) in zip(i, i[1:]))) for i in matrix))
(y_len, x_len) = map(int, input().split())
matrix_a = [list(map(int, input().split())) for _ in range(y_len)]
matrix_b = [list(map(int, input().split())) for _ in range(y_len)]
new_matrix_a = [[min(k, l) for (k, l) in zip(i, j)] for (i, j) in zip(matrix_a, matrix_b)]
new_matrix_b = [[max(k, l) for (k, l) in zip(i, j)] for (i, j) in zip(matrix_a, matrix_b)]
print('Possible' if check_increasing(new_matrix_a) and check_increasing(new_matrix_b) else 'Impossible')


(n, m) = map(int, input().split())
a = [[] for i in range(n)]
b = [[] for i in range(n)]
for i in range(n):
	a[i] = list(map(int, input().split()))
for i in range(n):
	b[i] = list(map(int, input().split()))
for i in range(n):
	for j in range(m):
		(a[i][j], b[i][j]) = (min(a[i][j], b[i][j]), max(a[i][j], b[i][j]))

def pr(c):
	global n
	global m
	for i in range(1, n):
		for j in range(1, m):
			if c[i][j] <= c[i - 1][j] or c[i][j] <= c[i][j - 1]:
				return False
	for i in range(1, n):
		if c[i][0] <= c[i - 1][0]:
			return False
	for i in range(1, m):
		if c[0][i] <= c[0][i - 1]:
			return False
	return True
if pr(a) and pr(b):
	print('Possible')
else:
	print('Impossible')


(n, m) = map(int, input().split())
arr = [[int(i) for i in input().split()] for i in range(n)]
brr = [[int(i) for i in input().split()] for i in range(n)]
for i in range(n):
	for j in range(m):
		if arr[i][j] > brr[i][j]:
			(arr[i][j], brr[i][j]) = (brr[i][j], arr[i][j])
ok = True

def ok(c):
	for i in range(n):
		for j in range(m):
			if i + 1 < n and c[i][j] >= c[i + 1][j]:
				return False
			if j + 1 < m and c[i][j] >= c[i][j + 1]:
				return False
	return True
print('Possible' if ok(arr) and ok(brr) else 'Impossible')


(n, m) = map(int, input().split())
a = [[0 for _ in range(m)] for _ in range(n)]
b = [[0 for _ in range(m)] for _ in range(n)]
for i in range(n):
	a[i] = list(map(int, input().split()))
for i in range(n):
	b[i] = list(map(int, input().split()))
for i in range(n):
	for j in range(m):
		(a[i][j], b[i][j]) = (min(a[i][j], b[i][j]), max(a[i][j], b[i][j]))
works = True
for i in range(n):
	for j in range(m - 1):
		if a[i][j + 1] <= a[i][j]:
			works = False
		if b[i][j + 1] <= b[i][j]:
			works = False
for j in range(m):
	for i in range(n - 1):
		if a[i + 1][j] <= a[i][j]:
			works = False
		if b[i + 1][j] <= b[i][j]:
			works = False
if works:
	print('Possible')
else:
	print('Impossible')


(n, m) = map(int, input().split())
(a, b) = ([], [])
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(n):
	b.append(list(map(int, input().split())))
for i in range(n):
	for j in range(m):
		if a[i][j] > b[i][j]:
			(a[i][j], b[i][j]) = (b[i][j], a[i][j])

def check(c):
	for i in range(n):
		for j in range(m):
			if i + 1 < n and c[i][j] >= c[i + 1][j]:
				return False
			if j + 1 < m and c[i][j] >= c[i][j + 1]:
				return False
	return True
if check(a) and check(b):
	print('Possible')
else:
	print('Impossible')


import sys

def swap(row, col, matrix1, matrix2):
	old_val = matrix1[row][col]
	matrix1[row][col] = matrix2[row][col]
	matrix2[row][col] = old_val

def everythingCool(row, col, matrix1, matrix2):
	if col != 0 and (matrix1[row][col - 1] >= matrix1[row][col] or matrix2[row][col - 1] >= matrix2[row][col]):
		return False
	if row != 0 and (matrix1[row - 1][col] >= matrix1[row][col] or matrix2[row - 1][col] >= matrix2[row][col]):
		return False
	return True

def check_row(row, matrix1, matrix2, row_size, col_size):
	for col in range(col_size):
		if matrix1[row][col] > matrix2[row][col]:
			swap(row, col, matrix1, matrix2)
		if not everythingCool(row, col, matrix1, matrix2):
			return False
	return True
size = input().split(' ')
row_size = int(size[0])
col_size = int(size[1])
matrix1 = []
matrix2 = []
for i in range(row_size):
	line = input().split(' ')
	matrix1.append([int(x) for x in line])
for i in range(row_size):
	line = input().split(' ')
	matrix2.append([int(x) for x in line])
for row in range(row_size):
	if not check_row(row, matrix1, matrix2, row_size, col_size):
		print('Impossible')
		sys.exit(0)
print('Possible')


def increasing(m):
	for i in range(len(m)):
		prev = m[i][0]
		for j in range(1, len(m[i])):
			if m[i][j] <= prev:
				return False
			prev = m[i][j]
	for j in range(len(m[0])):
		prev = m[0][j]
		for i in range(1, len(m)):
			if m[i][j] <= prev:
				return False
			prev = m[i][j]
	return True

def sol(m1, m2):
	for i in range(len(m1)):
		for j in range(len(m1[i])):
			if m1[i][j] > m2[i][j]:
				(m1[i][j], m2[i][j]) = (m2[i][j], m1[i][j])
	if not increasing(m1) or not increasing(m2):
		return 'Impossible'
	return 'Possible'
[n, m] = [int(x) for x in input().split()]
(m1, m2) = ([], [])
for _ in range(n):
	m1.append([int(x) for x in input().split()])
for _ in range(n):
	m2.append([int(x) for x in input().split()])
print(sol(m1, m2))


def main():
	(n, m) = list(map(int, input().split()))
	m1 = [[] for _ in range(n)]
	m2 = [[] for _ in range(n)]
	for i in range(n):
		m1[i] = list(map(int, input().split()))
	for i in range(n):
		m2[i] = list(map(int, input().split()))
	for r in range(n):
		for c in range(m):
			(m1[r][c], m2[r][c]) = (min(m1[r][c], m2[r][c]), max(m1[r][c], m2[r][c]))

	def checkRow(row):
		for i in range(m - 1):
			if m1[row][i] >= m1[row][i + 1] or m2[row][i] >= m2[row][i + 1]:
				return False
		return True

	def checkCol(col):
		for i in range(n - 1):
			if m1[i][col] >= m1[i + 1][col] or m2[i][col] >= m2[i + 1][col]:
				return False
		return True
	ok = True
	for r in range(n):
		if not checkRow(r):
			ok = False
			break
	if ok:
		for c in range(m):
			if not checkCol(c):
				ok = False
				break
	print('Possible' if ok else 'Impossible')

def __starting_point():
	main()
__starting_point()


def main():
	(n, m) = map(int, input().split())
	fir = [[] for i in range(n)]
	sec = [[] for i in range(n)]
	for i in range(n):
		fir[i] = list(map(int, input().split()))
	for i in range(n):
		sec[i] = list(map(int, input().split()))
	for i in range(n):
		for j in range(m):
			(fir[i][j], sec[i][j]) = (min(fir[i][j], sec[i][j]), max(fir[i][j], sec[i][j]))
	for i in range(n):
		for j in range(m):
			if i > 0 and fir[i][j] <= fir[i - 1][j]:
				print('Impossible')
				return 0
			if j > 0 and fir[i][j] <= fir[i][j - 1]:
				print('Impossible')
				return 0
			if i > 0 and sec[i][j] <= sec[i - 1][j]:
				print('Impossible')
				return 0
			if j > 0 and sec[i][j] <= sec[i][j - 1]:
				print('Impossible')
				return 0
	print('Possible')
	return 0
main()


(n, m) = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]
B = [list(map(int, input().split())) for i in range(n)]
X = [[0] * m for i in range(n)]
Y = [[0] * m for i in range(n)]
for i in range(n):
	for j in range(m):
		X[i][j] = min(A[i][j], B[i][j])
		Y[i][j] = max(A[i][j], B[i][j])
for i in range(n):
	for j in range(m - 1):
		if X[i][j] >= X[i][j + 1]:
			print('Impossible')
			exit()
for j in range(m):
	for i in range(n - 1):
		if X[i][j] >= X[i + 1][j]:
			print('Impossible')
			exit()
for i in range(n):
	for j in range(m - 1):
		if Y[i][j] >= Y[i][j + 1]:
			print('Impossible')
			exit()
for j in range(m):
	for i in range(n - 1):
		if Y[i][j] >= Y[i + 1][j]:
			print('Impossible')
			exit()
print('Possible')


import collections
(m, n) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(m)]
b = [list(map(int, input().split())) for j in range(m)]
ans = 'Possible'
for i in range(m):
	j = 0
	(a[i][0], b[i][0]) = ((a[i][j], b[i][j]), (b[i][j], a[i][j]))[a[i][j] > b[i][j]]
	if i and (a[i][j] <= a[i - 1][j] or b[i][j] <= b[i - 1][j]):
		ans = 'Impossible'
		break
if ans == 'Possible':
	for j in range(n):
		i = 0
		(a[i][j], b[i][j]) = ((a[i][j], b[i][j]), (b[i][j], a[i][j]))[a[i][j] > b[i][j]]
		if j and (a[i][j] <= a[i][j - 1] or b[i][j] <= b[i][j - 1]):
			ans = 'Impossible'
			break
if ans == 'Possible':
	for i in range(1, m):
		if ans == 'Possible':
			for j in range(1, n):
				(a[i][j], b[i][j]) = ((a[i][j], b[i][j]), (b[i][j], a[i][j]))[a[i][j] > b[i][j]]
				if a[i][j] <= a[i - 1][j] or a[i][j] <= a[i][j - 1]:
					ans = 'Impossible'
					break
				if b[i][j] <= b[i - 1][j] or b[i][j] <= b[i][j - 1]:
					ans = 'Impossible'
					break
print(ans)


(n, m) = map(int, input().split())
a = [[*map(int, input().split())] for _ in range(n)]
b = [[*map(int, input().split())] for _ in range(n)]
for i in range(n):
	for j in range(m):
		(a[i][j], b[i][j]) = sorted([a[i][j], b[i][j]])

def check(l):
	for i in range(n):
		for j in range(1, m):
			if l[i][j - 1] >= l[i][j]:
				return False
	for i in range(1, n):
		for j in range(m):
			if l[i - 1][j] >= l[i][j]:
				return False
	return True
print('Possible' if check(a) and check(b) else 'Impossible')


import sys
input = sys.stdin.readline
(n, m) = list(map(int, input().split()))
a = [None] * n
b = [None] * n
a2 = [None] * n
b2 = [None] * n
for i in range(n):
	a[i] = list(map(int, input().split()))
for i in range(n):
	b[i] = list(map(int, input().split()))
a2 = [[min(x2, y2) for (x2, y2) in zip(x, y)] for (x, y) in zip(a, b)]
b2 = [[max(x2, y2) for (x2, y2) in zip(x, y)] for (x, y) in zip(a, b)]
flag = True
for i in range(n):
	if a2[i] == sorted(a2[i]) and b2[i] == sorted(b2[i]):
		if len(set(a2[i])) == m and len(set(b2[i])) == m:
			continue
	flag = False
	break
if flag:
	a2 = list(zip(*a2))
	b2 = list(zip(*b2))
	for i in range(m):
		if list(a2[i]) == sorted(a2[i]) and list(b2[i]) == sorted(b2[i]):
			if len(set(a2[i])) == n and len(set(b2[i])) == n:
				continue
		flag = False
		break
if flag:
	print('Possible')
else:
	print('Impossible')


def func(arr, n, m):
	for i in range(n):
		for j in range(1, m):
			if arr[i][j] <= arr[i][j - 1]:
				return 1
	for i in range(m):
		for j in range(1, n):
			if arr[j][i] <= arr[j - 1][i]:
				return 1
	return 0
(n, m) = list(map(int, input().split()))
arr = []
for i in range(n):
	arr.append(list(map(int, input().split())))
brr = []
for i in range(n):
	brr.append(list(map(int, input().split())))
for i in range(n):
	for j in range(m):
		if arr[i][j] > brr[i][j]:
			x = arr[i][j]
			arr[i][j] = brr[i][j]
			brr[i][j] = x
f = func(arr, n, m) | func(brr, n, m)
if f == 1:
	print('Impossible')
else:
	print('Possible')


import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque, Counter
from math import gcd, sqrt, factorial, ceil, log10, log2
from itertools import permutations
from heapq import heappush, heappop, heapify
inf = float('inf')
mod = 1000000007

def factorial_p(n, p):
	ans = 1
	if n <= p // 2:
		for i in range(1, n + 1):
			ans = ans * i % p
	else:
		for i in range(1, p - n):
			ans = ans * i % p
		ans = pow(ans, p - 2, p)
		if n % 2 == 0:
			ans = p - ans
	return ans

def nCr_p(n, r, p):
	ans = 1
	while n != 0 or r != 0:
		(a, b) = (n % p, r % p)
		if a < b:
			return 0
		ans = ans * factorial_p(a, p) * pow(factorial_p(b, p), p - 2, p) * pow(factorial_p(a - b, p), p - 2, p) % p
		n //= p
		r //= p
	return ans

def prime_sieve(n):
	flag = n % 6 == 2
	sieve = bytearray((n // 3 + flag >> 3) + 1)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if not sieve[i >> 3] >> (i & 7) & 1:
			k = 3 * i + 1 | 1
			for j in range(k * k // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
			for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
	return sieve

def prime_list(n):
	res = []
	if n > 1:
		res.append(2)
	if n > 2:
		res.append(3)
	if n > 4:
		sieve = prime_sieve(n + 1)
		res.extend((3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not sieve[i >> 3] >> (i & 7) & 1))
	return res

def binary(number):
	result = 0
	while number:
		result = result + 1
		number = number & number - 1
	return result

def is_prime(n):
	if n < 5 or n & 1 == 0 or n % 3 == 0:
		return 2 <= n <= 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			p = p * p % n
			if p == n - 1:
				break
		else:
			return False
	return True

def is_inc_row(mat, n, m):
	for i in range(n):
		for j in range(1, m):
			if mat[i][j] <= mat[i][j - 1]:
				return False
	return True

def is_inc_col(mat, n, m):
	for i in range(m):
		for j in range(1, n):
			if mat[j][i] <= mat[j - 1][i]:
				return False
	return True

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(n, m) = get_ints()
mat1 = []
mat2 = []
for i in range(n):
	mat1.append(get_array())
for i in range(n):
	mat2.append(get_array())
for i in range(n):
	for j in range(m):
		if mat1[i][j] > mat2[i][j]:
			(mat1[i][j], mat2[i][j]) = (mat2[i][j], mat1[i][j])
if is_inc_row(mat1, n, m) and is_inc_col(mat1, n, m) and is_inc_row(mat2, n, m) and is_inc_col(mat2, n, m):
	print('Possible')
else:
	print('Impossible')


(N, M) = map(int, input().split())
mat1 = [list(map(int, input().split())) for i in range(N)]
mat2 = [list(map(int, input().split())) for i in range(N)]
ans = 'Possible'
for r in range(N):
	for c in range(M):
		bigger_v = max(mat1[r][c], mat2[r][c])
		smaller_v = min(mat1[r][c], mat2[r][c])
		if r > 0:
			bigger_prev = max(mat1[r - 1][c], mat2[r - 1][c])
			smaller_prev = min(mat1[r - 1][c], mat2[r - 1][c])
			if not (bigger_v > bigger_prev and smaller_v > smaller_prev):
				ans = 'Impossible'
				break
		if c > 0:
			bigger_prev = max(mat1[r][c - 1], mat2[r][c - 1])
			smaller_prev = min(mat1[r][c - 1], mat2[r][c - 1])
			if not (bigger_v > bigger_prev and smaller_v > smaller_prev):
				ans = 'Impossible'
				break
	if ans == 'Impossible':
		break
print(ans)


(n, m) = map(int, input().split())
l1 = []
l2 = []
for i in range(n):
	k = list(map(int, input().split()))
	l1.append(k)
for i in range(n):
	k = list(map(int, input().split()))
	l2.append(k)
flag = 0
for i in range(n):
	for j in range(m):
		if l1[i][j] > l2[i][j]:
			(l1[i][j], l2[i][j]) = (l2[i][j], l1[i][j])
for i in range(n):
	for j in range(m):
		if j != m - 1:
			if l1[i][j] >= l1[i][j + 1] or l2[i][j] >= l2[i][j + 1]:
				flag = 1
				break
	if flag == 1:
		break
for i in range(m):
	for j in range(n):
		if j != n - 1:
			if l1[j][i] >= l1[j + 1][i] or l2[j][i] >= l2[j + 1][i]:
				flag = 1
				break
	if flag == 1:
		break
if flag == 1:
	print('Impossible')
else:
	print('Possible')


def convert(string):
	return string.split(sep=None, maxsplit=-1)

def toint(lst):
	result = []
	for i in lst:
		result.append(int(i))
	return result

def increasing(lst):
	done = True
	old = 0
	for i in range(len(lst)):
		new = lst[i]
		if not new > old:
			done = False
		old = new
	return done

def row_increasing(m):
	done = True
	for i in m:
		if not increasing(i):
			done = False
	return done

def column_increasing(m):
	done = True
	for i in range(len(m[0])):
		if not increasing(list(map(lambda x: x[i], m))):
			done = False
	return done
nm = toint(convert(input()))
n = nm[0]
m = nm[1]
(a, b) = ([], [])
for i in range(n):
	row = toint(convert(input()))
	a.append(row)
for i in range(n):
	row = toint(convert(input()))
	b.append(row)
for i in range(n):
	for j in range(m):
		if a[i][j] > b[i][j]:
			(a[i][j], b[i][j]) = (b[i][j], a[i][j])
answer = row_increasing(a) and row_increasing(b) and column_increasing(a) and column_increasing(b)
if answer:
	print('Possible')
else:
	print('Impossible')


(n, m) = map(int, input().split())
sp = [[0] * m for i in range(n)]
matr = [[0] * m for i in range(n)]
for i in range(n):
	sp[i] = list(map(int, input().split()))
for i in range(n):
	matr[i] = list(map(int, input().split()))
for i in range(n):
	for j in range(m):
		if sp[i][j] > matr[i][j]:
			(sp[i][j], matr[i][j]) = (matr[i][j], sp[i][j])
for i in sp:
	if i != sorted(list(set(i))):
		print('Impossible')
		exit()
for j in range(m):
	for i in range(1, n):
		if sp[i][j] <= sp[i - 1][j]:
			print('Impossible')
			exit()
		if matr[i][j] <= matr[i - 1][j]:
			print('Impossible')
			exit()
for i in matr:
	if i != sorted(list(set(i))):
		print('Impossible')
		exit()
print('Possible')


(n, m) = list(map(int, input().split()))
arr = []
brr = []
for i in range(n):
	lista = list(map(int, input().split()))
	arr.append(lista)
for i in range(n):
	listb = list(map(int, input().split()))
	brr.append(listb)
for i in range(n):
	for j in range(m):
		if arr[i][j] > brr[i][j]:
			(arr[i][j], brr[i][j]) = (brr[i][j], arr[i][j])
flag = 0
for i in range(n):
	for j in range(1, m):
		if arr[i][j] > arr[i][j - 1]:
			a = arr[i][j]
		else:
			flag = 1
			break
		if brr[i][j] > brr[i][j - 1]:
			b = brr[i][j]
		else:
			flag = 1
			break
	if flag == 1:
		break
for j in range(m):
	for i in range(1, n):
		if arr[i][j] > arr[i - 1][j]:
			a = arr[i][j]
		else:
			flag = 1
			break
		if brr[i][j] > brr[i - 1][j]:
			b = brr[i][j]
		else:
			flag = 1
			break
	if flag == 1:
		break
if flag == 1:
	print('Impossible')
else:
	print('Possible')


(n, m) = map(int, input().split())
mat1 = []
mat2 = []
for i in range(n):
	mat1.append(list(map(int, input().split())))
for i in range(n):
	mat2.append(list(map(int, input().split())))
for i in range(n):
	for j in range(m):
		if mat1[i][j] < mat2[i][j]:
			(mat1[i][j], mat2[i][j]) = (mat2[i][j], mat1[i][j])
for i in range(n):
	for j in range(1, m):
		if mat1[i][j] <= mat1[i][j - 1]:
			print('Impossible')
			exit(0)
		if mat2[i][j] <= mat2[i][j - 1]:
			print('Impossible')
			exit(0)
for i in range(1, n):
	for j in range(m):
		if mat1[i][j] <= mat1[i - 1][j]:
			print('Impossible')
			exit(0)
		if mat2[i][j] <= mat2[i - 1][j]:
			print('Impossible')
			exit(0)
print('Possible')


(n, m) = list(map(int, input().split()))
(a1, a2) = ([], [])
for i in range(n):
	a1.append(list(map(int, input().split())))
for i in range(n):
	a2.append(list(map(int, input().split())))
for i in range(n):
	for j in range(m):
		(a1[i][j], a2[i][j]) = (min(a1[i][j], a2[i][j]), max(a1[i][j], a2[i][j]))

def check(a):
	for i in range(n):
		for j in range(1, m):
			if a[i][j] <= a[i][j - 1]:
				return False
	for j in range(m):
		for i in range(1, n):
			if a[i][j] <= a[i - 1][j]:
				return False
	return True
ans = 'Possible' if check(a1) and check(a2) else 'Impossible'
print(ans)


(n, m) = map(int, input().split())
a = []
b = []
for i in range(n):
	temp = list(map(int, input().split()))
	a.append(temp)
for i in range(n):
	temp = list(map(int, input().split()))
	b.append(temp)
ans = True
for i in range(n):
	for j in range(m):
		x = a[i][j]
		y = b[i][j]
		a[i][j] = min(x, y)
		b[i][j] = max(x, y)
for i in range(n):
	if ans:
		for j in range(1, m):
			if a[i][j] <= a[i][j - 1]:
				ans = False
				break
			if b[i][j] <= b[i][j - 1]:
				ans = False
				break
if ans:
	for i in range(m):
		if ans:
			for j in range(1, n):
				if a[j][i] <= a[j - 1][i]:
					ans = False
					break
				if b[j][i] <= b[j - 1][i]:
					ans = False
					break
if ans:
	print('Possible')
else:
	print('Impossible')


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(n)]
order = lambda x, y: (min(x, y), max(x, y))
for r in range(n):
	for c in range(m):
		(mi, mx) = order(a[r][c], b[r][c])
		(a[r][c], b[r][c]) = (mi, mx)

def ok(w):
	for r in range(n):
		for c in range(m - 1):
			if w[r][c] >= w[r][c + 1]:
				return False
	for c in range(m):
		for r in range(n - 1):
			if w[r][c] >= w[r + 1][c]:
				return False
	return True
if ok(a) and ok(b):
	print('Possible')
else:
	print('Impossible')


import math

def checkMat(mat):
	n = len(mat)
	m = len(mat[0])
	for i in range(n):
		for j in range(1, m):
			if mat[i][j] <= mat[i][j - 1]:
				return 0
	for j in range(m):
		for i in range(1, n):
			if mat[i][j] <= mat[i - 1][j]:
				return 0
	return 1

def solve():
	(n, m) = map(int, input().split())
	mat1 = []
	mat2 = []
	for i in range(n):
		l = list(map(int, input().split()))
		mat1.append(l)
	for i in range(n):
		l = list(map(int, input().split()))
		mat2.append(l)
	for i in range(n):
		for j in range(m):
			(mat1[i][j], mat2[i][j]) = (min(mat1[i][j], mat2[i][j]), max(mat1[i][j], mat2[i][j]))
	return checkMat(mat1) and checkMat(mat2)
t = 1
while t > 0:
	t -= 1
	val = solve()
	if val == 1:
		print('Possible')
	else:
		print('Impossible')


(n, m) = map(int, input().split())
T1 = [[] for i in range(n)]
T2 = [[] for i in range(n)]
S1 = [[-1] * m for i in range(n)]
S2 = [[-1] * m for i in range(n)]
for i in range(n):
	T1[i] = list(map(int, input().split()))
for i in range(n):
	T2[i] = list(map(int, input().split()))
for i in range(n):
	for j in range(m):
		S1[i][j] = min(T1[i][j], T2[i][j])
		S2[i][j] = max(T1[i][j], T2[i][j])
for i in range(n):
	for j in range(1, m):
		if S1[i][j] <= S1[i][j - 1] or S2[i][j] <= S2[i][j - 1]:
			print('Impossible')
			exit()
for j in range(m):
	for i in range(1, n):
		if S1[i][j] <= S1[i - 1][j] or S2[i][j] <= S2[i - 1][j]:
			print('Impossible')
			exit()
print('Possible')


from sys import stdin, stdout
from math import *

def main():
	(n, m) = [int(x) for x in stdin.readline().split()]
	a = []
	for i in range(n):
		a.append([int(x) for x in stdin.readline().split()])
	b = []
	for i in range(n):
		b.append([int(x) for x in stdin.readline().split()])
	verd = 'Possible'
	try:
		for i in range(n):
			for j in range(m):
				if i > 0:
					assert max(a[i - 1][j], b[i - 1][j]) < max(a[i][j], b[i][j]) and min(a[i - 1][j], b[i - 1][j]) < min(a[i][j], b[i][j])
				if j > 0:
					assert max(a[i][j - 1], b[i][j - 1]) < max(a[i][j], b[i][j]) and min(a[i][j - 1], b[i][j - 1]) < min(a[i][j], b[i][j])
	except:
		verd = 'Impossible'
	stdout.write(verd)
	return 0
main()


from collections import defaultdict, deque
from heapq import heappush, heappop
from math import inf
ri = lambda : map(int, input().split())

def solve():
	(n, m) = ri()
	A = []
	for _ in range(n):
		A.append(list(ri()))
	B = []
	for _ in range(n):
		B.append(list(ri()))
	for i in range(n):
		for j in range(m):
			if i == 0 and j == 0:
				if A[i][j] > B[i][j]:
					(A[i][j], B[i][j]) = (B[i][j], A[i][j])
				continue
			if A[i][j] > B[i][j]:
				should = True
				if j - 1 >= 0:
					if B[i][j] <= A[i][j - 1]:
						should = False
				if i - 1 >= 0:
					if B[i][j] <= A[i - 1][j]:
						should = False
				if should:
					(A[i][j], B[i][j]) = (B[i][j], A[i][j])

	def valid(lst):
		for i in range(len(lst)):
			for j in range(len(lst[0])):
				if j > 0 and lst[i][j] <= lst[i][j - 1]:
					return False
				if i > 0 and lst[i][j] <= lst[i - 1][j]:
					return False
		return True
	if valid(A) and valid(B):
		print('Possible')
	else:
		print('Impossible')
t = 1
while t:
	t -= 1
	solve()


(n, m) = map(int, input().split())
m1 = [None] * n
m2 = [None] * n
for i in range(n):
	m1[i] = [int(o) for o in input().split()]
for i in range(n):
	m2[i] = [int(o) for o in input().split()]
lol = 0
for i in range(n):
	for j in range(m):
		if i > 0:
			if m1[i][j] <= m1[i - 1][j]:
				(m1[i][j], m2[i][j]) = (m2[i][j], m1[i][j])
			if m2[i][j] <= m2[i - 1][j]:
				(m1[i][j], m2[i][j]) = (m2[i][j], m1[i][j])
			if m1[i][j] <= m1[i - 1][j] or m2[i][j] <= m2[i - 1][j]:
				lol = 1
				break
		if j > 0:
			if m1[i][j] <= m1[i][j - 1]:
				(m1[i][j], m2[i][j]) = (m2[i][j], m1[i][j])
			if m2[i][j] <= m2[i][j - 1]:
				(m1[i][j], m2[i][j]) = (m2[i][j], m1[i][j])
			if m1[i][j] <= m1[i][j - 1] or m2[i][j] <= m2[i][j - 1]:
				lol = 1
				break
print('Possible' if lol == 0 else 'Impossible')


import math
from collections import deque, defaultdict
from sys import stdin, stdout
from copy import deepcopy
input = stdin.readline

def check(a):
	for i in range(n - 1):
		for j in range(m):
			if a[i][j] >= a[i + 1][j]:
				return 1
	for i in range(n):
		for j in range(m - 1):
			if a[i][j] >= a[i][j + 1]:
				return 1
	return 0
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())
(n, m) = mapin()
a = []
for i in range(n):
	a.append(listin())
b = []
for i in range(n):
	b.append(listin())
for i in range(n):
	for j in range(m):
		if a[i][j] > b[i][j]:
			(a[i][j], b[i][j]) = (b[i][j], a[i][j])
if check(a) or check(b):
	print('Impossible')
else:
	print('Possible')


MatrixLength = list(map(int, input().split()))
n = MatrixLength[0]
m = MatrixLength[1]
l1 = []
l2 = []
for i in range(0, 2):
	for j in range(n):
		if i % 2 == 0:
			l1.append(list(map(int, input().split())))
		else:
			l2.append(list(map(int, input().split())))
Lmin = [[0] * m for i in range(n)]
Lmax = [[0] * m for i in range(n)]
for i in range(0, n):
	for j in range(0, m):
		Lmin[i][j] = min(l1[i][j], l2[i][j])
		Lmax[i][j] = max(l1[i][j], l2[i][j])
for i in range(0, n):
	for j in range(0, m):
		if i - 1 >= 0:
			if Lmin[i - 1][j] >= Lmin[i][j] or Lmax[i - 1][j] >= Lmax[i][j]:
				print('Impossible')
				exit(0)
		if j - 1 >= 0:
			if Lmin[i][j - 1] >= Lmin[i][j] or Lmax[i][j - 1] >= Lmax[i][j]:
				print('Impossible')
				exit(0)
print('Possible')


from math import *
[n, m] = list(map(int, input().split(' ')))
a = []
b = []
cond = True
for i in range(n):
	a.append(list(map(int, input().split(' '))))
for i in range(n):
	b.append(list(map(int, input().split(' '))))
for j in range(n):
	for k in range(m):
		if cond:
			if k < m - 1 and (a[j][k] >= a[j][k + 1] or b[j][k] >= b[j][k + 1]):
				if b[j][k] < a[j][k + 1] and a[j][k] < b[j][k + 1]:
					(a[j][k + 1], b[j][k + 1]) = (b[j][k + 1], a[j][k + 1])
				else:
					cond = False
					break
			if j < n - 1 and (a[j][k] >= a[j + 1][k] or b[j][k] >= b[j + 1][k]):
				if b[j][k] < a[j + 1][k] and a[j][k] < b[j + 1][k]:
					(a[j + 1][k], b[j + 1][k]) = (b[j + 1][k], a[j + 1][k])
				else:
					cond = False
					break
if cond:
	print('Possible')
else:
	print('Impossible')


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, m) = list(map(int, input().split()))
a = []
b = []
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(n):
	b.append(list(map(int, input().split())))
for i in range(n):
	for j in range(m):
		if a[i][j] > b[i][j]:
			(a[i][j], b[i][j]) = (b[i][j], a[i][j])
f = 0
for i in range(n):
	for j in range(m):
		if i == 0 and j == 0:
			continue
		elif i > 0 and i < n and (j > 0) and (j < m):
			if a[i][j] > a[i - 1][j] and a[i][j] > a[i][j - 1]:
				continue
			else:
				f = 1
				break
		elif i == 0 and a[i][j] > a[i][j - 1]:
			continue
		elif j == 0 and a[i][j] > a[i - 1][j]:
			continue
		else:
			f = 1
			break
	if f == 1:
		break
if f == 1:
	print('Impossible')
else:
	for i in range(n):
		for j in range(m):
			if i == 0 and j == 0:
				continue
			elif i > 0 and i < n and (j > 0) and (j < m):
				if b[i][j] > b[i - 1][j] and b[i][j] > b[i][j - 1]:
					continue
				else:
					f = 1
					break
			elif i == 0 and b[i][j] > b[i][j - 1]:
				continue
			elif j == 0 and b[i][j] > b[i - 1][j]:
				continue
			else:
				f = 1
				break
		if f == 1:
			break
	if f == 1:
		print('Impossible')
	else:
		print('Possible')


(n, m) = map(int, input().split())
m1 = [list(map(int, input().split())) for i in range(n)]
m2 = [list(map(int, input().split())) for i in range(n)]

def ok(c):
	n = len(c)
	m = len(c[0])
	for i in range(n):
		for j in range(m):
			if i + 1 < n and c[i][j] >= c[i + 1][j]:
				return False
			if j + 1 < m and c[i][j] >= c[i][j + 1]:
				return False
	return True
for i in range(n):
	for j in range(m):
		if m1[i][j] > m2[i][j]:
			(m1[i][j], m2[i][j]) = (m2[i][j], m1[i][j])
if ok(m1) and ok(m2):
	print('Possible')
else:
	print('Impossible')


(n, m) = map(int, input().split())
(a, b) = ([], [])
for i in range(n):
	l = list(map(int, input().split()))
	a.append(l)
for i in range(n):
	l = list(map(int, input().split()))
	b.append(l)
for i in range(n):
	for j in range(m):
		if a[i][j] > b[i][j]:
			(a[i][j], b[i][j]) = (b[i][j], a[i][j])
for i in range(n):
	for j in range(m - 1):
		if a[i][j] >= a[i][j + 1] or b[i][j] >= b[i][j + 1]:
			print('Impossible')
			quit()
for j in range(m):
	for i in range(n - 1):
		if a[i][j] >= a[i + 1][j] or b[i][j] >= b[i + 1][j]:
			print('Impossible')
			quit()
print('Possible')


from math import *
from collections import *
from bisect import *
import sys
input = sys.stdin.readline
t = 1

def check(a, n, m):
	ff = 0
	for i in range(n):
		for j in range(m - 1):
			if a[i][j] < a[i][j + 1]:
				continue
			ff = 1
			break
	ff1 = 0
	for i in range(m):
		for j in range(n - 1):
			if a[j][i] < a[j + 1][i]:
				continue
			ff1 = 1
			break
	if ff1 + ff == 0:
		return 1
	return 0
while t:
	t -= 1
	(n, m) = map(int, input().split())
	a = []
	for i in range(n):
		x = list(map(int, input().split()))
		a.append(x)
	b = []
	for i in range(n):
		x = list(map(int, input().split()))
		b.append(x)
	for i in range(n):
		for j in range(m):
			if a[i][j] > b[i][j]:
				(a[i][j], b[i][j]) = (b[i][j], a[i][j])
	if check(a, n, m) and check(b, n, m):
		print('Possible')
	else:
		print('Impossible')


import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from random import randint as rand

def li():
	return list(map(int, input().split()))

def num():
	return map(int, input().split())

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	gg = find_gcd(x, y)
	return x * y // gg
mm = 1000000007
yp = 0

def cl(a, i, j, n, m):
	if j - 1 >= 0:
		if a[i][j] > a[i][j - 1]:
			return True
		else:
			return False
	else:
		return True

def cd(a, i, j, n, m):
	if i + 1 < n:
		if a[i][j] < a[i + 1][j]:
			return True
		else:
			return False
	else:
		return True

def cr(a, i, j, n, m):
	if j + 1 < m:
		if a[i][j] < a[i][j + 1]:
			return True
		else:
			return False
	else:
		return True

def cu(a, i, j, n, m):
	if i - 1 >= 0:
		if a[i][j] > a[i - 1][j]:
			return True
		else:
			return False
	else:
		return True

def solve():
	t = 1
	for _ in range(t):
		(n, m) = num()
		a = [0] * n
		b = [0] * n
		for i in range(n):
			a[i] = li()
		for j in range(n):
			b[j] = li()
			for k in range(m):
				tp = a[j][k]
				qp = b[j][k]
				a[j][k] = min(tp, qp)
				b[j][k] = max(tp, qp)
		fl = True
		for i in range(n):
			for j in range(m):
				if cl(a, i, j, n, m) and cu(a, i, j, n, m) and cd(a, i, j, n, m) and cr(a, i, j, n, m) and cl(b, i, j, n, m) and cu(b, i, j, n, m) and cd(b, i, j, n, m) and cr(b, i, j, n, m):
					continue
				tp = a[i][j]
				qp = b[i][j]
				a[i][j] = qp
				b[i][j] = tp
				if cl(a, i, j, n, m) and cu(a, i, j, n, m) and cd(a, i, j, n, m) and cr(a, i, j, n, m) and cl(b, i, j, n, m) and cu(b, i, j, n, m) and cd(b, i, j, n, m) and cr(b, i, j, n, m):
					continue
				a[i][j] = tp
				b[i][j] = qp
		for i in range(n):
			for j in range(m):
				if cl(a, i, j, n, m) and cu(a, i, j, n, m) and cd(a, i, j, n, m) and cr(a, i, j, n, m) and cl(b, i, j, n, m) and cu(b, i, j, n, m) and cd(b, i, j, n, m) and cr(b, i, j, n, m):
					continue
				fl = False
		if fl:
			print('Possible')
		else:
			print('Impossible')
solve()


def che(z):
	for i in range(a):
		for j in range(1, b):
			if z[i][j] <= z[i][j - 1]:
				return False
	for i in range(1, a):
		for j in range(b):
			if z[i][j] <= z[i - 1][j]:
				return False
	return True
(a, b) = map(int, input().split())
z = [list(map(int, input().split())) for _ in ' ' * a]
z1 = [list(map(int, input().split())) for _ in ' ' * a]
for i in range(a):
	for j in range(b):
		(z[i][j], z1[i][j]) = (min(z[i][j], z1[i][j]), max(z1[i][j], z[i][j]))
if che(z) and che(z1):
	print('Possible')
else:
	print('Impossible')


(n, m) = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(n)]
B = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
	for j in range(m):
		if A[i][j] > B[i][j]:
			(A[i][j], B[i][j]) = (B[i][j], A[i][j])
ans = 'Possible'
for c in A:
	if c != sorted(c) or len(set(c)) != m:
		ans = 'Impossible'
for c in B:
	if c != sorted(c) or len(set(c)) != m:
		ans = 'Impossible'
for j in range(m):
	ddd = []
	d2 = []
	for i in range(n):
		ddd.append(A[i][j])
		d2.append(B[i][j])
	if ddd != sorted(ddd) or len(set(ddd)) != n or len(set(d2)) != n or (d2 != sorted(d2)):
		ans = 'Impossible'
print(ans)


import sys
(n, m) = map(int, input().split())
mat1 = []
mat2 = []
for _ in range(n):
	mat1.append(list(map(int, input().split())))
for _ in range(n):
	mat2.append(list(map(int, input().split())))
for i in range(n):
	for j in range(m):
		if mat2[i][j] < mat1[i][j]:
			(mat1[i][j], mat2[i][j]) = (mat2[i][j], mat1[i][j])
for i in range(n):
	for j in range(1, m):
		if mat1[i][j] <= mat1[i][j - 1] or mat2[i][j] <= mat2[i][j - 1]:
			print('Impossible')
			sys.exit()
for i in range(1, n):
	for j in range(m):
		if mat1[i][j] <= mat1[i - 1][j] or mat2[i][j] <= mat2[i - 1][j]:
			print('Impossible')
			sys.exit()
print('Possible')


(n, m) = map(int, input().split())
ans1 = []
ans2 = []
for i in range(n):
	t = list(map(int, input().split()))
	ans1.append(t)
for i in range(n):
	t = list(map(int, input().split()))
	ans2.append(t)
ans3 = [[0 for i in range(m)] for i in range(n)]
gns = [[0 for i in range(m)] for i in range(n)]
flag = 0
for i in range(n):
	for j in range(m):
		m1 = min(ans1[i][j], ans2[i][j])
		m2 = max(ans1[i][j], ans2[i][j])
		if i == 0:
			e1 = 0
		else:
			e1 = ans3[i - 1][j]
		if j == 0:
			e2 = 0
		else:
			e2 = ans3[i][j - 1]
		if m1 > max(e1, e2):
			ans3[i][j] = m1
			gns[i][j] = m2
		elif m2 > max(e1, e2):
			ans3[i][j] = m2
			gns[i][j] = m1
		else:
			flag = 1
			break
for i in range(n):
	for j in range(m):
		if i == 0:
			e1 = 0
		else:
			e1 = gns[i - 1][j]
		if j == 0:
			e2 = 0
		else:
			e2 = gns[i][j - 1]
		if gns[i][j] <= max(e1, e2):
			flag = 1
			break
if flag == 1:
	print('Impossible')
else:
	print('Possible')


(n, m) = input().split()
n = int(n)
m = int(m)
(m1, m2) = ([], [])
for i in range(n):
	linha = [*map(int, input().split())]
	m1.append(linha)
for i in range(n):
	linha = [*map(int, input().split())]
	m2.append(linha)
i = 0
possible = True
while possible and i < n:
	j = 0
	while possible and j < m - 1:
		if m1[i][j] >= m1[i][j + 1]:
			if m1[i][j + 1] > m2[i][j] and m2[i][j + 1] > m1[i][j]:
				aux = m1[i][j + 1]
				m1[i][j + 1] = m2[i][j + 1]
				m2[i][j + 1] = aux
			else:
				increasing = possible = False
		if m2[i][j] >= m2[i][j + 1]:
			if m2[i][j + 1] > m1[i][j] and m1[i][j + 1] > m2[i][j]:
				aux = m2[i][j + 1]
				m2[i][j + 1] = m1[i][j + 1]
				m1[i][j + 1] = aux
			else:
				increasing = possible = False
		j += 1
	i += 1
i = 0
while possible and i < m:
	j = 0
	while possible and j < n - 1:
		if m1[j][i] >= m1[j + 1][i]:
			if m2[j + 1][i] > m1[j][i] and m1[j + 1][i] > m2[j][i]:
				aux = m1[j + 1][i]
				m1[j + 1][i] = m2[j + 1][i]
				m2[j + 1][i] = aux
			else:
				possible = False
		if m2[j][i] >= m2[j + 1][i]:
			if m1[j + 1][i] > m2[j][i] and m2[j + 1][i] > m1[j][i]:
				aux = m2[j + 1][i]
				m2[j + 1][i] = m1[j + 1][i]
				m1[j + 1][i] = aux
			else:
				possible = False
		j += 1
	i += 1
if possible:
	print('Possible')
else:
	print('Impossible')


(n, m) = map(int, input().split())
(a, b) = ([], [])
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(n):
	b.append(list(map(int, input().split())))

def swap(a, b):
	return (b, a)
for i in range(n):
	for j in range(m):
		if a[i][j] > b[i][j]:
			(a[i][j], b[i][j]) = swap(a[i][j], b[i][j])
flag = 0
for i in range(n):
	for j in range(1, m):
		if a[i][j] <= a[i][j - 1]:
			flag = 1
			break
for i in range(n):
	for j in range(1, m):
		if b[i][j] <= b[i][j - 1]:
			flag = 1
			break
for i in range(m):
	for j in range(1, n):
		if a[j][i] <= a[j - 1][i]:
			flag = 1
			break
for i in range(m):
	for j in range(1, n):
		if b[j][i] <= b[j - 1][i]:
			flag = 1
			break
if flag:
	print('Impossible')
else:
	print('Possible')


(n, m) = map(int, input().split())
ar = []
for i in range(n):
	ar.append(list(map(int, input().split())))
br = []
for i in range(n):
	br.append(list(map(int, input().split())))
for i in range(n):
	for j in range(m):
		if ar[i][j] > br[i][j]:
			ar[i][j] ^= br[i][j]
			br[i][j] ^= ar[i][j]
			ar[i][j] ^= br[i][j]
flag = True
ac = 0
bc = 0
for i in range(n):
	for j in range(m):
		if ar[i][j] <= ac or br[i][j] <= bc:
			flag = False
		else:
			ac = ar[i][j]
			bc = br[i][j]
		if j == m - 1:
			ac = 0
			bc = 0
acc = 0
bcc = 0
for i in range(m):
	for j in range(n):
		if ar[j][i] <= acc or br[j][i] <= bcc:
			flag = False
		else:
			acc = ar[j][i]
			bcc = br[j][i]
		if j == n - 1:
			acc = 0
			bcc = 0
if flag:
	print('Possible')
else:
	print('Impossible')


import sys
(n, m) = list(map(int, input().split()))

def read_matrix():
	M = []
	for i in range(n):
		M.append(list(map(int, input().split())))
	return M
(A, B) = (read_matrix(), read_matrix())
for i in range(n):
	for j in range(m):
		(A[i][j], B[i][j]) = (min(A[i][j], B[i][j]), max(A[i][j], B[i][j]))
		if i > 0 and (A[i][j] <= A[i - 1][j] or B[i][j] <= B[i - 1][j]) or (j > 0 and (A[i][j] <= A[i][j - 1] or B[i][j] <= B[i][j - 1])):
			print('Impossible')
			return
print('Possible')


from sys import exit
(N, M) = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
B = [list(map(int, input().split())) for _ in range(N)]
C = [[0] * M for _ in range(N)]
D = [[0] * M for _ in range(N)]

def imp():
	print('Impossible')
	exit()
for i in range(N):
	for j in range(M):
		C[i][j] = max(A[i][j], B[i][j])
		D[i][j] = min(A[i][j], B[i][j])
for i in range(N):
	for j in range(M - 1):
		if C[i][j + 1] <= C[i][j]:
			imp()
		if D[i][j + 1] <= D[i][j]:
			imp()
for j in range(M):
	for i in range(N - 1):
		if C[i + 1][j] <= C[i][j]:
			imp()
		if D[i + 1][j] <= D[i][j]:
			imp()
print('Possible')


def main():
	(n, m) = map(int, input().split())
	a = [[int(i) for i in input().split()] for j in range(n)]
	b = [[int(i) for i in input().split()] for j in range(n)]
	possible = True
	for i in range(n):
		(ok_a, ok_b) = (a[i][0], b[i][0])
		for j in range(1, m):
			if ok_a < a[i][j] and ok_b < b[i][j]:
				ok_a = a[i][j]
				ok_b = b[i][j]
			else:
				(a[i][j], b[i][j]) = (b[i][j], a[i][j])
				if ok_a < a[i][j] and ok_b < b[i][j]:
					ok_a = a[i][j]
					ok_b = b[i][j]
				else:
					possible = False
					break
	for j in range(m):
		(ok_a, ok_b) = (a[0][j], b[0][j])
		for i in range(1, n):
			if ok_a < a[i][j] and ok_b < b[i][j]:
				ok_a = a[i][j]
				ok_b = b[i][j]
			else:
				(a[i][j], b[i][j]) = (b[i][j], a[i][j])
				if ok_a < a[i][j] and ok_b < b[i][j]:
					ok_a = a[i][j]
					ok_b = b[i][j]
				else:
					possible = False
					break
	if possible:
		print('Possible')
	else:
		print('Impossible')
main()


import sys
(n, m) = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
	for j in range(m):
		(a[i][j], b[i][j]) = (max(a[i][j], b[i][j]), min(a[i][j], b[i][j]))

def check(x):
	for i in range(1, n):
		for j in range(m):
			if x[i][j] <= x[i - 1][j]:
				return False
	for i in range(n):
		for j in range(1, m):
			if x[i][j] <= x[i][j - 1]:
				return False
	return True
if check(a) and check(b):
	print('Possible')
else:
	print('Impossible')


(r, c) = map(int, input().split())
a = []
b = []
for i in range(r):
	a.append(list(map(int, input().split())))
for i in range(r):
	b.append(list(map(int, input().split())))
for i in range(r):
	for j in range(c):
		(a[i][j], b[i][j]) = (min(a[i][j], b[i][j]), max(a[i][j], b[i][j]))
fine = True
for i in range(0, r):
	for j in range(0, c):
		if i == 0 and j == 0:
			continue
		mxa = 0
		mxb = 0
		if i != 0:
			mxa = a[i - 1][j]
			mxb = b[i - 1][j]
		if j != 0:
			mxa = max(mxa, a[i][j - 1])
			mxb = max(mxb, b[i][j - 1])
		if a[i][j] <= mxa or b[i][j] <= mxb:
			fine = False
			break
print('Possible' if fine else 'Impossible')


def valid(a):
	valid = 1
	for i in range(n):
		for j in range(m - 1):
			if a[i][j] >= a[i][j + 1]:
				valid = 0
				break
	for i in range(n - 1):
		for j in range(m):
			if a[i][j] >= a[i + 1][j]:
				valid = 0
				break
	return valid
(n, m) = [int(x) for x in input().split()]
(a, b) = ([], [])
for i in range(n):
	a.append([int(x) for x in input().split()])
for i in range(n):
	b.append([int(x) for x in input().split()])
for i in range(n):
	for j in range(m):
		if a[i][j] > b[i][j]:
			(a[i][j], b[i][j]) = (b[i][j], a[i][j])
print(['Impossible', 'Possible'][valid(a) & valid(b)])


(n, m) = map(int, input().split())

def check(matrix):
	for i in range(n):
		for j in range(m - 1):
			if matrix[i][j][0] >= matrix[i][j + 1][0] or matrix[i][j][1] >= matrix[i][j + 1][1]:
				return False
	for i in range(m):
		for j in range(n - 1):
			if matrix[j][i][0] >= matrix[j + 1][i][0] or matrix[j][i][1] >= matrix[j + 1][i][1]:
				return False
	return True
m1 = []
for i in range(n):
	row = list(map(int, input().split()))
	m1.append(row)
m2 = []
merged = []
for i in range(n):
	row = list(map(int, input().split()))
	m2.append(row)
	merged.append([])
	for j in range(m):
		merged[i].append(sorted((m1[i][j], m2[i][j])))
if check(merged):
	print('Possible')
else:
	print('Impossible')


(n, m) = map(int, input().split())
M1 = []
M2 = []
for i in range(n):
	M1.append(list(map(int, input().split())))
for i in range(n):
	M2.append(list(map(int, input().split())))
for i in range(n):
	for j in range(m):
		(M1[i][j], M2[i][j]) = (min(M1[i][j], M2[i][j]), max(M1[i][j], M2[i][j]))
f = 1
for i in range(n):
	for j in range(m):
		if i > 0 and (M1[i][j] <= M1[i - 1][j] or M2[i][j] <= M2[i - 1][j]):
			f = 0
			break
		if j > 0 and (M1[i][j] <= M1[i][j - 1] or M2[i][j] <= M2[i][j - 1]):
			f = 0
			break
if f == 1:
	print('Possible')
else:
	print('Impossible')


def verificaMatriz(matriz):
	for i in range(len(matriz)):
		for j in range(len(matriz[i]) - 1):
			e = matriz[i][j]
			e2 = matriz[i][j + 1]
			if e >= e2:
				return False
	for j in range(len(matriz[0])):
		for i in range(len(matriz) - 1):
			e = matriz[i][j]
			e2 = matriz[i + 1][j]
			if e >= e2:
				return False
	return True
(n, m) = map(int, input().split())
matriz1 = []
matriz2 = []
for ele in range(n):
	linha = list(map(int, input().split()))
	matriz1.append(linha)
for ele in range(n):
	linha = list(map(int, input().split()))
	matriz2.append(linha)
for i in range(len(matriz1)):
	for j in range(len(matriz1[i])):
		if matriz1[i][j] > matriz2[i][j]:
			aux = matriz1[i][j]
			matriz1[i][j] = matriz2[i][j]
			matriz2[i][j] = aux
if verificaMatriz(matriz1) and verificaMatriz(matriz2):
	print('Possible')
else:
	print('Impossible')


def isIncreasing(matrix, n, m):
	for j in range(m - 1):
		if matrix[0][j + 1] <= matrix[0][j]:
			return False
	for i in range(n - 1):
		if matrix[i + 1][0] <= matrix[i][0]:
			return False
	for i in range(1, n):
		for j in range(1, m):
			if matrix[i][j] <= matrix[i - 1][j] or matrix[i][j] <= matrix[i][j - 1]:
				return False
	return True
(n, m) = list(map(int, input().split()))
A = []
B = []
for i in range(n):
	A.append(list(map(int, input().split())))
for i in range(n):
	B.append(list(map(int, input().split())))
for i in range(n):
	for j in range(m):
		(A[i][j], B[i][j]) = (min(A[i][j], B[i][j]), max(A[i][j], B[i][j]))
if isIncreasing(A, n, m) and isIncreasing(B, n, m):
	print('Possible')
else:
	print('Impossible')


def main():
	(n, m) = list(map(int, input().split()))
	l1 = [[0] * m for index in range(n)]
	l2 = [[0] * m for index in range(n)]
	for i in range(0, n):
		l1[i] = list(map(int, input().split()))
	for i in range(0, n):
		l2[i] = list(map(int, input().split()))
	for i in range(0, n):
		for j in range(0, m):
			x = l1[i][j]
			y = l2[i][j]
			l1[i][j] = min(x, y)
			l2[i][j] = max(x, y)
	ans = 'Possible'
	for i in range(0, n):
		for j in range(0, m):
			if i > 0 and l1[i][j] <= l1[i - 1][j]:
				ans = 'Impossible'
			if j > 0 and l1[i][j] <= l1[i][j - 1]:
				ans = 'Impossible'
	for i in range(0, n):
		for j in range(0, m):
			if i > 0 and l2[i][j] <= l2[i - 1][j]:
				ans = 'Impossible'
			if j > 0 and l2[i][j] <= l2[i][j - 1]:
				ans = 'Impossible'
	print(ans)
main()


from sys import stdin, stdout
(r, c) = [int(x) for x in stdin.readline().split()]
data = [[None] * c for _ in range(r)]
data2 = [[None] * c for _ in range(r)]
for i in range(r):
	arr = [int(x) for x in stdin.readline().split()]
	for j in range(c):
		data[i][j] = arr[j]
		data2[i][j] = arr[j]
for i in range(r):
	arr = [int(x) for x in stdin.readline().split()]
	for j in range(c):
		data[i][j] = min(data[i][j], arr[j])
		data2[i][j] = max(data2[i][j], arr[j])
flag = 0
for i in range(r):
	for j in range(1, c):
		if data[i][j] <= data[i][j - 1]:
			flag = 1
		if data2[i][j] <= data2[i][j - 1]:
			flag = 1
for j in range(c):
	for i in range(1, r):
		if data[i][j] <= data[i - 1][j]:
			flag = 1
		if data2[i][j] <= data2[i - 1][j]:
			flag = 1
if flag == 0:
	print('Possible')
else:
	print('Impossible')


from sys import stdin
(n, m) = map(int, stdin.readline().strip().split())
A = []
B = []
for _ in range(n):
	A.append(list(map(int, stdin.readline().strip().split())))
for _ in range(n):
	B.append(list(map(int, stdin.readline().strip().split())))
for i in range(n):
	for j in range(m):
		if A[i][j] > B[i][j]:
			temp = A[i][j]
			A[i][j] = B[i][j]
			B[i][j] = temp
for i in range(n):
	for j in range(1, m):
		if A[i][j] <= A[i][j - 1] or B[i][j] <= B[i][j - 1]:
			print('Impossible')
			quit()
for j in range(m):
	for i in range(1, n):
		if A[i][j] <= A[i - 1][j] or B[i][j] <= B[i - 1][j]:
			print('Impossible')
			quit()
print('Possible')


(n, m) = map(int, input().split())
m1 = [list(map(int, input().split())) for _ in range(n)]
m2 = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
	for j in range(m):
		(m1[i][j], m2[i][j]) = (max(m1[i][j], m2[i][j]), min(m1[i][j], m2[i][j]))

def check(matrix):
	return all((all((y > x for (x, y) in zip(row, row[1:]))) for row in matrix))
print('Possible' if check(m1) and check(m2) and check(list(map(list, zip(*m1)))) and check(list(map(list, zip(*m2)))) else 'Impossible')


def check(a):
	(n, m) = (len(a), len(a[0]))
	for i in range(n):
		for j in range(m):
			if i > 0 and a[i - 1][j] >= a[i][j] or (j > 0 and a[i][j - 1] >= a[i][j]):
				return False
	return True
(n, m) = [int(i) for i in input().split()]
a = [[int(j) for j in input().split()] for i in range(n)]
b = [[int(j) for j in input().split()] for i in range(n)]
c = [[max(a[i][j], b[i][j]) for j in range(m)] for i in range(n)]
d = [[min(a[i][j], b[i][j]) for j in range(m)] for i in range(n)]
if check(c) and check(d):
	print('Possible')
else:
	print('Impossible')


def check(c):
	for i in range(n - 1):
		for j in range(m):
			if c[i][j] >= c[i + 1][j]:
				return 1
	for i in range(n):
		for j in range(m - 1):
			if c[i][j] >= c[i][j + 1]:
				return 1
	return 0
x = lambda : [*map(int, input().split())]
(n, m) = x()
(a, b) = [[x() for _ in range(n)] for _ in [0, 1]]
for i in range(n):
	for j in range(m):
		if a[i][j] > b[i][j]:
			(a[i][j], b[i][j]) = (b[i][j], a[i][j])
print('Impossible' if check(a) | check(b) else 'Possible')


(n, m) = input().split()
(n, m) = (int(n), int(m))
a = []
c = []
d = []
e = []
f1 = 'Possible'
for i in range(n):
	b = [int(s) for s in input().split()]
	a.append(b)
for i in range(n):
	d = [int(s) for s in input().split()]
	for j in range(m):
		if a[i][j] > d[j]:
			(a[i][j], d[j]) = (d[j], a[i][j])
	c.append(d)
for i in range(n):
	for j in range(1, m):
		if a[i][j] > a[i][j - 1] and c[i][j] > c[i][j - 1]:
			continue
		else:
			f1 = 'Impossible'
			break
for j in range(m):
	if f1 == 'Impossible':
		break
	else:
		for j in range(m):
			if f1 == 'impossible':
				break
			for i in range(1, n):
				if a[i][j] > a[i - 1][j] and c[i][j] > c[i - 1][j]:
					continue
				else:
					f1 = 'Impossible'
					break
print(f1)


(a, b) = map(int, input().split())
d = [0] * 60
e = [d] * 60
f = [d] * 60
for i in range(0, a):
	e[i] = list(map(int, input().split()))
for i in range(0, a):
	f[i] = list(map(int, input().split()))
for i in range(0, a):
	for j in range(0, b):
		if e[i][j] < f[i][j]:
			c = e[i][j]
			e[i][j] = f[i][j]
			f[i][j] = c
for i in range(a + b - 3, 0, -1):
	for j in range(0, i + 1):
		c = 0
		x = j
		y = i - j
		if x < a and y < b:
			if x == a - 1:
				c += 1
			elif e[x][y] < e[x + 1][y]:
				c += 1
			if y == b - 1:
				c += 1
			elif e[x][y] < e[x][y + 1]:
				c += 1
			if c < 2:
				c = e[x][y]
				e[x][y] = f[x][y]
				f[x][y] = c
ans = 0
for i in range(0, a):
	for j in range(0, b):
		c = 0
		if i < a - 1:
			if e[i][j] >= e[i + 1][j]:
				c = 1
			if f[i][j] >= f[i + 1][j]:
				c = 1
		if j < b - 1:
			if e[i][j] >= e[i][j + 1]:
				c = 1
			if f[i][j] >= f[i][j + 1]:
				c = 1
		if c == 1:
			ans = 1
if ans == 0:
	print('Possible')
else:
	print('Impossible')


import sys
(n, m) = map(int, input().split())
matrix1 = []
matrix2 = []
for i in range(n):
	matrix1.append(list(map(int, input().split())))
for i in range(n):
	matrix2.append(list(map(int, input().split())))
x = [0] * m
test1 = []
test2 = []
for i in range(n):
	test1.append(x.copy())
	test2.append(x.copy())
for i in range(n):
	for j in range(m):
		test1[i][j] = min(matrix1[i][j], matrix2[i][j])
		test2[i][j] = max(matrix1[i][j], matrix2[i][j])
for i in range(n):
	for j in range(1, m):
		if test1[i][j] <= test1[i][j - 1] or test2[i][j] <= test2[i][j - 1]:
			print('Impossible')
			sys.exit()
for i in range(1, n):
	for j in range(m):
		if test1[i][j] <= test1[i - 1][j] or test2[i][j] <= test2[i - 1][j]:
			print('Impossible')
			sys.exit()
print('Possible')


(n, m) = [int(p) for p in input().split()]
m1 = []
m2 = []
for i in range(n):
	m1.append([int(p) for p in input().split()])
for i in range(n):
	m2.append([int(p) for p in input().split()])
ans1 = []
ans2 = []
for i in range(n):
	ans1.append([0] * m)
	ans2.append([0] * m)
for i in range(n):
	for j in range(m):
		if i == 0:
			top = -1
		else:
			top = ans1[i - 1][j]
		if i == n - 1:
			bottom = -1
		else:
			bottom = ans1[i + 1][j]
		if j == 0:
			left = -1
		else:
			left = ans1[i][j - 1]
		if j == m - 1:
			right = -1
		else:
			right = ans1[i][j + 1]
		Max = max(left, right, top, bottom)
		Min = min(m1[i][j], m2[i][j])
		if Min > Max:
			ans1[i][j] = Min
			ans2[i][j] = max(m1[i][j], m2[i][j])
		else:
			print('Impossible')
			exit()
cnt1 = 0
cnt2 = 0
for i in ans1:
	if sorted(i) == i and len(set(i)) == len(i):
		cnt1 += 1
for i in range(m):
	p1 = []
	for j in range(n):
		p1.append(ans1[j][i])
	if sorted(p1) == p1 and len(set(p1)) == len(p1):
		cnt1 += 1
for i in ans2:
	if sorted(i) == i and len(set(i)) == len(i):
		cnt2 += 1
for i in range(m):
	p1 = []
	for j in range(n):
		p1.append(ans2[j][i])
	if sorted(p1) == p1 and len(set(p1)) == len(p1):
		cnt2 += 1
if cnt1 == cnt2 and cnt1 == m + n:
	print('Possible')
else:
	print('Impossible')


(h, s) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
b = [list(map(int, input().split())) for j in range(h)]
for i in range(h):
	for j in range(s):
		a1 = min(a[i][j], b[i][j])
		b1 = max(a[i][j], b[i][j])
		a[i][j] = a1
		b[i][j] = b1
k = 0
otv = 'Possible'
for i in range(h):
	k = 0
	for j in range(s):
		if a[i][j] > k:
			k = a[i][j]
		else:
			otv = 'Impossible'
for j in range(s):
	k = 0
	for i in range(h):
		if a[i][j] > k:
			k = a[i][j]
		else:
			otv = 'Impossible'
for i in range(h):
	k = 0
	for j in range(s):
		if b[i][j] > k:
			k = b[i][j]
		else:
			otv = 'Impossible'
for j in range(s):
	k = 0
	for i in range(h):
		if b[i][j] > k:
			k = b[i][j]
		else:
			otv = 'Impossible'
print(otv)


import math
import bisect
import heapq
from collections import defaultdict

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, x, y) = egcd(b % a, a)
		return (g, y - b // a * x, x)

def mulinv(b, n):
	(g, x, _) = egcd(b, n)
	if g == 1:
		return x % n
primes = []

def isprime(n):
	for d in range(2, int(math.sqrt(n)) + 1):
		if n % d == 0:
			return False
	return True

def argsort(ls):
	return sorted(range(len(ls)), key=ls.__getitem__)

def f(p=0):
	if p == 1:
		return map(int, input().split())
	elif p == 2:
		return list(map(int, input().split()))
	else:
		return int(input())
(n, m) = f(1)
a = [[0 for _ in range(m)] for _ in range(n)]
b = [[0 for _ in range(m)] for _ in range(n)]
for i in range(n):
	s = f(2)
	for j in range(m):
		a[i][j] = s[j]
for i in range(n):
	s = f(2)
	for j in range(m):
		b[i][j] = s[j]
for i in range(n):
	for j in range(m):
		aa = a[i][j]
		bb = b[i][j]
		a[i][j] = min(aa, bb)
		b[i][j] = max(aa, bb)
for i in range(n):
	for j in range(m):
		if i > 0 and (a[i - 1][j] >= a[i][j] or b[i - 1][j] >= b[i][j]):
			print('Impossible')
			exit()
		if j > 0 and (a[i][j - 1] >= a[i][j] or b[i][j - 1] >= b[i][j]):
			print('Impossible')
			exit()
print('Possible')


(n, m) = map(int, input().strip().split())
ma1 = []
ma2 = []
for i in range(n):
	ma1.append([int(i) for i in input().strip().split()])
for i in range(n):
	ma2.append([int(i) for i in input().strip().split()])

def check_row(ma):
	for i in range(n):
		for j in range(1, m):
			if ma[i][j - 1] >= ma[i][j]:
				return False
	return True

def check_col(ma):
	for j in range(m):
		for i in range(n - 1):
			if ma[i][j] >= ma[i + 1][j]:
				return False
	return True
for row in range(n):
	for col in range(m):
		if ma1[row][col] < ma2[row][col]:
			temp = ma2[row][col]
			ma2[row][col] = ma1[row][col]
			ma1[row][col] = temp
if check_row(ma1) and check_col(ma1) and check_col(ma2) and check_row(ma2):
	print('Possible')
else:
	print('Impossible')


(n, m) = map(int, input().split())
A = []
B = []
for i in range(n):
	A.append(list(map(int, input().split())))
for i in range(n):
	B.append(list(map(int, input().split())))
x = True
for i in range(0, n):
	for k in range(0, m - 1):
		if not x:
			break
		elif min(A[i][k], B[i][k]) >= min(A[i][k + 1], B[i][k + 1]) or max(A[i][k], B[i][k]) >= max(A[i][k + 1], B[i][k + 1]):
			x = False
			break
	if not x:
		break
if x:
	for i in range(0, n - 1):
		for k in range(0, m):
			if not x:
				break
			elif min(A[i][k], B[i][k]) >= min(A[i + 1][k], B[i + 1][k]) or max(A[i][k], B[i][k]) >= max(A[i + 1][k], B[i + 1][k]):
				x = False
				break
		if not x:
			break
if x:
	print('Possible')
else:
	print('Impossible')


(n, m) = map(int, input().split())
matrix1 = []
matrix2 = []
for _ in range(n):
	matrix1.append(list(map(int, input().split())))
for _ in range(n):
	matrix2.append(list(map(int, input().split())))
p = False
for i in range(n):
	for j in range(m):
		(mini_next_row, maxi_next_row, mini_next_col, maxi_next_col) = (float('inf'), float('inf'), float('inf'), float('inf'))
		(mini, maxi) = (min(matrix1[i][j], matrix2[i][j]), max(matrix1[i][j], matrix2[i][j]))
		if j + 1 < m:
			(mini_next_row, maxi_next_row) = (min(matrix1[i][j + 1], matrix2[i][j + 1]), max(matrix1[i][j + 1], matrix2[i][j + 1]))
		if i + 1 < n:
			(mini_next_col, maxi_next_col) = (min(matrix1[i + 1][j], matrix2[i + 1][j]), max(matrix1[i + 1][j], matrix2[i + 1][j]))
		if not (mini < mini_next_row and mini < mini_next_col and (maxi < maxi_next_row) and (maxi < maxi_next_col)):
			print('Impossible')
			p = True
			break
	if p:
		break
if not p:
	print('Possible')


def getn():
	return int(input())

def getns():
	return [int(x) for x in input().split()]
(n, m) = getns()
a = [[0] * m for i in range(n)]
b = [[0] * m for i in range(n)]
a = []
b = []
for i in range(n):
	a.append(getns())
for i in range(n):
	b.append(getns())
for i in range(n):
	for j in range(m):
		(a[i][j], b[i][j]) = (min(a[i][j], b[i][j]), max(a[i][j], b[i][j]))

def check(x):
	for i in range(n):
		for j in range(m - 1):
			if x[i][j] >= x[i][j + 1]:
				return False
	for i in range(n - 1):
		for j in range(m):
			if x[i][j] >= x[i + 1][j]:
				return False
	return True
if check(a) and check(b):
	print('Possible')
else:
	print('Impossible')
quit()
print(a)
print(b)


import sys, os
from io import BytesIO, IOBase
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(stdin, stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def ceil(a, b):
	return (a + b - 1) // b
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
(n, m) = mp()
mat1 = [lmp() for i in range(n)]
mat2 = [lmp() for i in range(n)]
for i in range(n):
	for j in range(m):
		(a, b) = (mat1[i][j], mat2[i][j])
		mat1[i][j] = min(a, b)
		mat2[i][j] = max(a, b)
flg = True
for i in range(n):
	for j in range(m):
		if i:
			if mat1[i][j] <= mat1[i - 1][j] or mat2[i][j] <= mat2[i - 1][j]:
				flg = False
				break
		if j:
			if mat1[i][j] <= mat1[i][j - 1] or mat2[i][j] <= mat2[i][j - 1]:
				flg = False
				break
	if not flg:
		break
print('Possible' if flg else 'Impossible')


from math import *
from collections import *
import sys
sys.setrecursionlimit(10 ** 9)
(n, m) = map(int, input().split())
a = []
b = []
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(n):
	b.append(list(map(int, input().split())))
for i in range(n):
	for j in range(m):
		if a[i][j] < b[i][j]:
			(a[i][j], b[i][j]) = (b[i][j], a[i][j])
for i in range(n):
	for j in range(m - 1):
		if a[i][j] >= a[i][j + 1]:
			print('Impossible')
			exit(0)
for i in range(n):
	for j in range(m - 1):
		if b[i][j] >= b[i][j + 1]:
			print('Impossible')
			exit(0)
for i in range(m):
	for j in range(n - 1):
		if a[j][i] >= a[j + 1][i]:
			print('Impossible')
			exit(0)
for i in range(m):
	for j in range(n - 1):
		if b[j][i] >= b[j + 1][i]:
			print('Impossible')
			exit(0)
print('Possible')


(n, m) = map(int, input().split())

def validate(matrix):
	for row in matrix:
		for i in range(len(row) - 1):
			if row[i] >= row[i + 1]:
				return False
	for i in range(m):
		for j in range(n - 1):
			if matrix[j][i] >= matrix[j + 1][i]:
				return False
	return True
a = [[int(val) for val in input().split()] for _ in range(n)]
b = [[int(val) for val in input().split()] for _ in range(n)]
for i in range(n):
	for j in range(m):
		(a[i][j], b[i][j]) = (min(a[i][j], b[i][j]), max(a[i][j], b[i][j]))
if validate(a) and validate(b):
	print('Possible')
else:
	print('Impossible')


(n, m) = [int(t) for t in input().split(' ')]
a = [[int(t) for t in input().split(' ')] for _ in range(n)]
b = [[int(t) for t in input().split(' ')] for _ in range(n)]
ap = []
bp = []
for i in range(n):
	ap.append([])
	bp.append([])
	for j in range(m):
		ap[-1].append(min(a[i][j], b[i][j]))
		bp[-1].append(max(a[i][j], b[i][j]))

def incLine(mat, i, j, i_step, j_step):
	increasing = True
	while i + i_step < len(mat) and j + j_step < len(mat[0]):
		increasing &= mat[i][j] < mat[i + i_step][j + j_step]
		i += i_step
		j += j_step
	return increasing

def isIncreasing(mat):
	increasing = True
	for i in range(n):
		increasing &= incLine(mat, i, 0, 0, 1)
	for j in range(m):
		increasing &= incLine(mat, 0, j, 1, 0)
	return increasing
print('Possible' if isIncreasing(ap) and isIncreasing(bp) else 'Impossible')


def check(c, i, j):
	for x in range(i - 1):
		for y in range(j):
			if c[x][y] >= c[x + 1][y]:
				return True
	for x in range(i):
		for y in range(j - 1):
			if c[x][y] >= c[x][y + 1]:
				return True
	return False
(n, m) = map(int, input().split())
a = [[list(map(int, input().split())) for _ in range(n)], [list(map(int, input().split())) for _ in range(n)]]
for i in range(n):
	for j in range(m):
		if a[0][i][j] > a[1][i][j]:
			(a[0][i][j], a[1][i][j]) = (a[1][i][j], a[0][i][j])
print(('Imp' if check(a[0], n, m) or check(a[1], n, m) else 'P') + 'ossible')


ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
si = lambda : input()
(n, m) = mi()
(a, b) = [[li() for _ in range(n)] for _ in [0, 1]]
for i in range(n):
	for j in range(m):
		if a[i][j] > b[i][j]:
			(a[i][j], b[i][j]) = (b[i][j], a[i][j])

def g(c):
	for i in range(n - 1):
		for j in range(m):
			if c[i][j] >= c[i + 1][j]:
				return True
	for i in range(n):
		for j in range(m - 1):
			if c[i][j] >= c[i][j + 1]:
				return True
	return False
print('Impossible' if g(a) or g(b) else 'Possible')


(n, m) = list(map(int, input().split()))
m1 = [list(map(int, input().split())) for i in range(n)]
m2 = [list(map(int, input().split())) for i in range(n)]
import sys
for i in range(n - 1):
	for j in range(m - 1):
		(a, b) = (m1[i][j], m2[i][j])
		(c, d) = (m1[i + 1][j], m2[i + 1][j])
		(e, f) = (m1[i][j + 1], m2[i][j + 1])
		if a > b:
			(a, b) = (b, a)
		if c > d:
			(c, d) = (d, c)
		if e > f:
			(e, f) = (f, e)
		if b >= d:
			print('Impossible')
			return
		elif a >= c:
			print('Impossible')
			return
		if b >= f:
			print('Impossible')
			return
		elif a >= e:
			print('Impossible')
			return
for i in range(n - 1):
	j = m - 1
	(a, b) = (m1[i][j], m2[i][j])
	(c, d) = (m1[i + 1][j], m2[i + 1][j])
	if a > b:
		(a, b) = (b, a)
	if c > d:
		(c, d) = (d, c)
	if b >= d:
		print('Impossible')
		return
	elif a >= c:
		print('Impossible')
		return
for j in range(m - 1):
	i = n - 1
	(a, b) = (m1[i][j], m2[i][j])
	(e, f) = (m1[i][j + 1], m2[i][j + 1])
	if a > b:
		(a, b) = (b, a)
	if e > f:
		(e, f) = (f, e)
	if b >= f:
		print('Impossible')
		return
	elif a >= e:
		print('Impossible')
		return
print('Possible')


(n, m) = [int(x) for x in input().split()]
a = []
b = []
T_F = True
for i in range(n):
	a.append([int(x) for x in input().split()])
for i in range(n):
	b.append([int(x) for x in input().split()])
for i in range(n):
	for j in range(m):
		if a[i][j] > b[i][j]:
			(a[i][j], b[i][j]) = (b[i][j], a[i][j])
for i in range(n):
	for j in range(m):
		if i + 1 < n:
			if a[i][j] >= a[i + 1][j]:
				T_F = False
			elif T_F:
				T_F = True
		if j + 1 < m:
			if a[i][j] >= a[i][j + 1]:
				T_F = False
			elif T_F:
				T_F = True
		if i + 1 < n:
			if b[i][j] >= b[i + 1][j]:
				T_F = False
			elif T_F:
				T_F = True
		if j + 1 < m:
			if b[i][j] >= b[i][j + 1]:
				T_F = False
			elif T_F:
				T_F = True
if T_F:
	print('Possible')
else:
	print('Impossible')


(n, m) = map(int, input().split())
a = [[int(i) for i in input().split()] for j in range(n)]
b = [[int(i) for i in input().split()] for j in range(n)]
for i in range(n):
	for j in range(m):
		if a[i][j] < b[i][j]:
			(a[i][j], b[i][j]) = (b[i][j], a[i][j])
pode = True
for i in range(n):
	for j in range(m):
		if j + 1 < m and a[i][j] >= a[i][j + 1]:
			pode = False
		if j + 1 < m and b[i][j] >= b[i][j + 1]:
			pode = False
		if i + 1 < n and a[i][j] >= a[i + 1][j]:
			pode = False
		if i + 1 < n and b[i][j] >= b[i + 1][j]:
			pode = False
	if not pode:
		break
if pode:
	print('Possible')
else:
	print('Impossible')


(n, m) = map(int, input().split())
(a, b) = ([], [])
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(n):
	b.append(list(map(int, input().split())))

def row_check(arr, r):
	for j in range(m - 1):
		if arr[r][j] >= arr[r][j + 1]:
			return False
	return True

def col_check(arr, c):
	for i in range(n - 1):
		if arr[i][c] >= arr[i + 1][c]:
			return False
	return True
for i in range(n):
	for j in range(m):
		if a[i][j] > b[i][j]:
			(a[i][j], b[i][j]) = (b[i][j], a[i][j])
for i in range(n):
	if not row_check(a, i) or not row_check(b, i):
		print('Impossible')
		exit()
for j in range(m):
	if not col_check(a, j) or not col_check(b, j):
		print('Impossible')
		exit()
print('Possible')


def read(n, m):
	r = []
	for i in range(n):
		l = list(map(int, input().split()))
		r.append(l)
	return r
(n, m) = map(int, input().split())
a = read(n, m)
b = read(n, m)
for i in range(n):
	for j in range(m):
		xa = min(a[i][j], b[i][j])
		xb = max(a[i][j], b[i][j])
		a[i][j] = xa
		b[i][j] = xb
incr = True
for i in range(n):
	for j in range(m - 1):
		if a[i][j] >= a[i][j + 1]:
			incr = False
		if b[i][j] >= b[i][j + 1]:
			incr = False
for j in range(m):
	for i in range(n - 1):
		if a[i][j] >= a[i + 1][j]:
			incr = False
		if b[i][j] >= b[i + 1][j]:
			incr = False
if incr:
	print('Possible')
else:
	print('Impossible')


(n, m) = list(map(int, input().split()))
a = []
for i in range(n):
	line = list(map(int, input().split()))
	a.append(line)
b = []
for i in range(n):
	line = list(map(int, input().split()))
	b.append(line)
possible = True
for row in range(n):
	for col in range(m):
		if a[row][col] > b[row][col]:
			temp = a[row][col]
			a[row][col] = b[row][col]
			b[row][col] = temp
		if row != 0:
			if a[row][col] <= a[row - 1][col]:
				possible = False
				break
			if b[row][col] <= b[row - 1][col]:
				possible = False
				break
		if col != 0:
			if a[row][col] <= a[row][col - 1]:
				possible = False
				break
			if b[row][col] <= b[row][col - 1]:
				possible = False
				break
if possible:
	print('Possible')
else:
	print('Impossible')


(n, m) = map(int, input().split())
a = []
b = []
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(n):
	b.append(list(map(int, input().split())))
for i in range(n):
	for j in range(m):
		if a[i][j] > b[i][j]:
			(a[i][j], b[i][j]) = (b[i][j], a[i][j])
flag = True
for i in range(n):
	for j in range(m - 1):
		if a[i][j + 1] - a[i][j] <= 0 or b[i][j + 1] - b[i][j] <= 0:
			flag = False
			break
	if not flag:
		break
if flag:
	for i in range(m):
		for j in range(n - 1):
			if a[j + 1][i] - a[j][i] <= 0 or b[j + 1][i] - b[j][i] <= 0:
				flag = False
				break
		if not flag:
			break
if flag:
	print('Possible')
else:
	print('Impossible')


(n, m) = map(int, input().split())
mat1 = []
mat2 = []
for _ in range(n):
	inp = list(map(int, input().split()))
	mat1.append(inp)
for _ in range(n):
	inp = list(map(int, input().split()))
	mat2.append(inp)
poss = 1
for i in range(n):
	if poss == 1:
		for j in range(m - 1):
			if min(mat1[i][j], mat2[i][j]) < min(mat1[i][j + 1], mat2[i][j + 1]):
				if max(mat1[i][j], mat2[i][j]) < max(mat1[i][j + 1], mat2[i][j + 1]):
					pass
				else:
					poss = 0
					break
			else:
				poss = 0
				break
	else:
		break
if poss == 1:
	for i in range(n - 1):
		if poss == 1:
			for j in range(m):
				if min(mat1[i][j], mat2[i][j]) < min(mat1[i + 1][j], mat2[i + 1][j]):
					if max(mat1[i][j], mat2[i][j]) < max(mat1[i + 1][j], mat2[i + 1][j]):
						pass
					else:
						poss = 0
						break
				else:
					poss = 0
					break
		else:
			break
if poss == 1:
	print('Possible')
else:
	print('Impossible')


import sys
(m, n) = [int(s) for s in input().split()]
array_1 = []
for i in range(m):
	str = [int(s) for s in input().split()]
	array_1.append(str)
array_2 = []
for i in range(m):
	str = [int(s) for s in input().split()]
	array_2.append(str)
if array_1[0][0] > array_2[0][0]:
	(array_1[0][0], array_2[0][0]) = (array_2[0][0], array_1[0][0])
for i in range(1, m):
	if array_2[i][0] < array_1[i][0] and array_2[i][0] > array_1[i - 1][0]:
		(array_1[i][0], array_2[i][0]) = (array_2[i][0], array_1[i][0])
	if array_1[i][0] <= array_1[i - 1][0] or array_2[i][0] <= array_2[i - 1][0]:
		print('Impossible')
		sys.exit(0)
for i in range(1, n):
	if array_2[0][i] < array_1[0][i] and array_2[0][i] > array_1[0][i - 1]:
		(array_1[0][i], array_2[0][i]) = (array_2[0][i], array_1[0][i])
	if array_1[0][i] <= array_1[0][i - 1] or array_2[0][i] <= array_2[0][i - 1]:
		print('Impossible')
		sys.exit(0)
for i in range(1, m):
	for j in range(1, n):
		if array_2[i][j] < array_1[i][j] and array_2[i][j] > array_1[i - 1][j] and (array_2[i][j] > array_1[i][j - 1]):
			(array_1[i][j], array_2[i][j]) = (array_2[i][j], array_1[i][j])
		if array_1[i][j] <= array_1[i - 1][j] or array_2[i][j] <= array_2[i - 1][j]:
			print('Impossible')
			sys.exit(0)
		if array_1[i][j] <= array_1[i][j - 1] or array_2[i][j] <= array_2[i][j - 1]:
			print('Impossible')
			sys.exit(0)
print('Possible')


(n, m) = list(map(int, input().split()))
mat1 = []
mat2 = []
for i in range(n):
	mat1.append(list(map(int, input().split())))
for i in range(n):
	mat2.append(list(map(int, input().split())))

def makeMatrixGood(matrix, secMatrix):
	for i in range(n):
		for g in range(m):
			if matrix[i][g] >= secMatrix[i][g]:
				(matrix[i][g], secMatrix[i][g]) = (secMatrix[i][g], matrix[i][g])

def checkMatrix(matrix):
	fl = True
	for i in range(n):
		for g in range(m - 1):
			if matrix[i][g] >= matrix[i][g + 1]:
				fl = False
	for i in range(n - 1):
		for g in range(m):
			if matrix[i][g] >= matrix[i + 1][g]:
				fl = False
	return fl
makeMatrixGood(mat1, mat2)
makeMatrixGood(mat2, mat1)
if checkMatrix(mat1) and checkMatrix(mat2):
	print('Possible')
else:
	print('Impossible')


(n, m) = map(int, input().split())
a = [None] * n
b = [None] * n
for i in range(n):
	a[i] = [int(x) for x in input().split()]
for i in range(n):
	b[i] = [int(x) for x in input().split()]
mi = [[None] * m for _ in range(n)]
ma = [[None] * m for _ in range(n)]
for i in range(n):
	for j in range(m):
		mi[i][j] = min(a[i][j], b[i][j])
		ma[i][j] = max(a[i][j], b[i][j])
for i in range(n):
	for j in range(m):
		if i > 0 and mi[i][j] <= mi[i - 1][j] or (i < n - 1 and mi[i][j] >= mi[i + 1][j]) or (j > 0 and mi[i][j] <= mi[i][j - 1]) or (j < m - 1 and mi[i][j] >= mi[i][j + 1]):
			print('Impossible')
			raise SystemExit(0)
		if i > 0 and ma[i][j] <= ma[i - 1][j] or (i < n - 1 and ma[i][j] >= ma[i + 1][j]) or (j > 0 and ma[i][j] <= ma[i][j - 1]) or (j < m - 1 and ma[i][j] >= ma[i][j + 1]):
			print('Impossible')
			raise SystemExit(0)
print('Possible')


def good(a):
	n = len(a)
	m = len(a[0])
	for i in range(n):
		for j in range(m - 1):
			if a[i][j] >= a[i][j + 1]:
				return False
	for j in range(m):
		for i in range(n - 1):
			if a[i][j] >= a[i + 1][j]:
				return False
	return True
(n, m) = map(int, input().split())
a = []
b = []
for _ in range(n):
	x = [int(x) for x in input().split()]
	a.append(x)
for _ in range(n):
	x = [int(x) for x in input().split()]
	b.append(x)
for i in range(n):
	for j in range(m):
		if a[i][j] > b[i][j]:
			(a[i][j], b[i][j]) = (b[i][j], a[i][j])
print('Possible' if good(a) and good(b) else 'Impossible')


(n, m) = [int(x) for x in input().split()]
(m1, m2) = ([], [])
for i in range(n):
	row = list(map(int, input().split()))
	m1.append(row)
for i in range(n):
	row = list(map(int, input().split()))
	m2.append(row)
possible = True
i = 0
while possible and i < n:
	j = 0
	while possible and j < m - 1:
		if m1[i][j] >= m1[i][j + 1]:
			if m1[i][j + 1] > m2[i][j] and m2[i][j + 1] > m1[i][j]:
				(m1[i][j + 1], m2[i][j + 1]) = (m2[i][j + 1], m1[i][j + 1])
			else:
				increasing = possible = False
		if m2[i][j] >= m2[i][j + 1]:
			if m2[i][j + 1] > m1[i][j] and m1[i][j + 1] > m2[i][j]:
				(m2[i][j + 1], m1[i][j + 1]) = (m1[i][j + 1], m2[i][j + 1])
			else:
				increasing = possible = False
		j += 1
	i += 1
i = 0
while possible and i < m:
	j = 0
	while possible and j < n - 1:
		if m1[j][i] >= m1[j + 1][i]:
			if m2[j + 1][i] > m1[j][i] and m1[j + 1][i] > m2[j][i]:
				(m1[j + 1][i], m2[j + 1][i]) = (m2[j + 1][i], m1[j + 1][i])
			else:
				possible = False
		if m2[j][i] >= m2[j + 1][i]:
			if m1[j + 1][i] > m2[j][i] and m2[j + 1][i] > m1[j][i]:
				(m2[j + 1][i], m1[j + 1][i]) = (m1[j + 1][i], m2[j + 1][i])
			else:
				possible = False
		j += 1
	i += 1
print('Possible' if possible else 'Impossible')


(n, m) = map(int, input().split())
a = []
b = []
for i in range(n):
	temp = list(map(int, input().split()))
	a.append(temp)
for i in range(n):
	temp = list(map(int, input().split()))
	b.append(temp)
for i in range(n - 1):
	for j in range(m - 1):
		t1 = [a[i][j], b[i][j]]
		t2 = [a[i + 1][j], b[i + 1][j]]
		t3 = [a[i][j + 1], b[i][j + 1]]
		t1.sort()
		t2.sort()
		t3.sort()
		if t2[0] <= t1[0] or t3[0] <= t1[0] or t2[1] <= t1[1] or (t3[1] <= t1[0]):
			print('Impossible')
			exit(0)
for i in range(m - 1):
	t1 = [a[n - 1][i], b[n - 1][i]]
	t2 = [a[n - 1][i + 1], b[n - 1][i + 1]]
	t1.sort()
	t2.sort()
	if t2[0] <= t1[0] or t2[1] <= t1[1]:
		print('Impossible')
		exit(0)
for i in range(n - 1):
	t1 = [a[i][m - 1], b[i][m - 1]]
	t2 = [a[i + 1][m - 1], b[i + 1][m - 1]]
	t1.sort()
	t2.sort()
	if t2[0] <= t1[0] or t2[1] <= t1[1]:
		print('Impossible')
		exit(0)
print('Possible')


(n, m) = [int(x) for x in input().split()]
a = []
b = []
for i in range(n):
	c = [int(x) for x in input().split()]
	a.append(c)
for i in range(n):
	c = [int(x) for x in input().split()]
	b.append(c)
for i in range(n):
	for j in range(m):
		(x, y) = (a[i][j], b[i][j])
		a[i][j] = min(x, y)
		b[i][j] = max(x, y)
		if j > 0:
			if a[i][j] <= a[i][j - 1] or b[i][j] <= b[i][j - 1]:
				print('Impossible')
				return
		if i > 0:
			if a[i][j] <= a[i - 1][j] or b[i][j] <= b[i - 1][j]:
				print('Impossible')
				return
print('Possible')


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split())) for i in range(n)]
new_a = [[0] * m for i in range(n)]
new_b = [[0] * m for i in range(n)]
for i in range(n):
	for j in range(m):
		new_a[i][j] = min(a[i][j], b[i][j])
		new_b[i][j] = max(a[i][j], b[i][j])

def judge(matrix):
	for i in range(n):
		for j in range(m):
			for (prev_i, prev_j) in [[i - 1, j], [i, j - 1]]:
				if 0 <= prev_i < n and 0 <= prev_j < m:
					if matrix[prev_i][prev_j] >= matrix[i][j]:
						return False
			for (next_i, next_j) in [[i + 1, j], [i, j + 1]]:
				if 0 <= next_i < n and 0 <= next_j < m:
					if matrix[next_i][next_j] <= matrix[i][j]:
						return False
	return True
if judge(new_a) and judge(new_b):
	print('Possible')
else:
	print('Impossible')


def main():
	(n, m) = map(int, input().split())
	m1 = [list(map(int, input().split())) for _ in range(n)]
	m2 = [list(map(int, input().split())) for _ in range(n)]
	for i in range(n):
		for j in range(m):
			(m1[i][j], m2[i][j]) = sorted([m1[i][j], m2[i][j]])
	for i in range(n):
		for j in range(1, m):
			if m1[i][j] <= m1[i][j - 1] or m2[i][j] <= m2[i][j - 1]:
				return 'Impossible'
	for j in range(m):
		for i in range(1, n):
			if m1[i][j] <= m1[i - 1][j] or m2[i][j] <= m2[i - 1][j]:
				return 'Impossible'
	return 'Possible'
print(main())


i = lambda : [*map(int, input().split())]
(n, m) = i()
r = range
u = lambda : sum((i() for _ in r(n)), [])
a = u()
b = u()
for _ in r(n * m):
	if a[_] > b[_]:
		(a[_], b[_]) = (b[_], a[_])
f = lambda x: any((_ % m * (x[_ - 1] >= x[_]) | (_ >= m) & (x[_ - m] >= x[_]) for _ in r(n * m)))
print(['P', 'Imp'][f(a) | f(b)] + 'ossible')


(n, m) = list(map(int, input().strip().split()))

def increasing(A, n, m):
	for i in range(n):
		for j in range(1, m):
			if A[i][j - 1] >= A[i][j]:
				return False
	for j in range(m):
		for i in range(1, n):
			if A[i - 1][j] >= A[i][j]:
				return False
	return True
first = []
for _ in range(n):
	first.append(list(map(int, input().strip().split())))
second = []
for _ in range(n):
	second.append(list(map(int, input().strip().split())))
for i in range(n):
	for j in range(m):
		(a, b) = (first[i][j], second[i][j])
		(first[i][j], second[i][j]) = (min(a, b), max(a, b))
if increasing(first, n, m) and increasing(second, n, m):
	print('Possible')
else:
	print('Impossible')


(n, m) = [int(x) for x in input().split()]
mat1 = [[0] * m] * n
mat2 = [[0] * m] * n
for i in range(n):
	mat1[i] = [int(x) for x in input().split()]
for i in range(n):
	mat2[i] = [int(x) for x in input().split()]
for i in range(n):
	for j in range(m):
		mn = min(mat1[i][j], mat2[i][j])
		mx = max(mat1[i][j], mat2[i][j])
		mat1[i][j] = mn
		mat2[i][j] = mx
for i in range(n):
	for j in range(1, m):
		if mat1[i][j] <= mat1[i][j - 1] or mat2[i][j] <= mat2[i][j - 1]:
			print('Impossible')
			exit()
for i in range(m):
	for j in range(1, n):
		if mat1[j][i] <= mat1[j - 1][i] or mat2[j][i] <= mat2[j - 1][i]:
			print('Impossible')
			exit()
print('Possible')


(n, m) = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for _ in range(n)]
b = [[int(i) for i in input().split()] for _ in range(n)]
for i in range(n):
	for j in range(m):
		top = sorted([a[i - 1][j], b[i - 1][j]] if i > 0 else [0, 0])
		left = sorted([a[i][j - 1], b[i][j - 1]] if j > 0 else [0, 0])
		now = sorted([a[i][j], b[i][j]])
		if now[0] <= left[0] or now[0] <= top[0] or now[1] <= left[1] or (now[1] <= top[1]):
			print('Impossible')
			exit()
print('Possible')


def valid(a, x, y):
	if y - 1 >= 0 and a[x][y] <= a[x][y - 1]:
		return False
	if x > 0 and a[x][y] <= a[x - 1][y]:
		return False
	return True
cin = lambda : [*map(int, input().split())]
(n, m) = cin()
(a, b) = [[cin() for _ in range(n)] for _ in range(2)]
c = [[min(a[i][j], b[i][j]) for j in range(m)] for i in range(n)]
d = [[max(a[i][j], b[i][j]) for j in range(m)] for i in range(n)]
if sum((valid(c, i, j) for j in range(m) for i in range(n))) + sum((valid(d, i, j) for j in range(m) for i in range(n))) == 2 * n * m:
	print('Possible')
else:
	print('Impossible')


(n, m) = map(int, input().split())
y = 1
a = [[0] * m] * n
b = [[0] * m] * n
for i in range(n):
	a[i] = [int(z) for z in input().split()]
for i in range(n):
	b[i] = [int(z) for z in input().split()]
for i in range(n):
	for j in range(m):
		(n1, n2) = (max(b[i][j], a[i][j]), min(b[i][j], a[i][j]))
		(b[i][j], a[i][j]) = (n1, n2)
for i in range(1, n):
	if a[i][0] > a[i - 1][0] and b[i][0] > b[i - 1][0]:
		pass
	else:
		y = 0
		break
for j in range(1, m):
	if a[0][j] > a[0][j - 1] and b[0][j] > b[0][j - 1]:
		pass
	else:
		y = 0
		break
if n > 1 and m > 1:
	for i in range(1, n):
		for j in range(1, m):
			if a[i][j] > a[i - 1][j] and a[i][j] > a[i][j - 1] and (b[i][j] > b[i - 1][j]) and (b[i][j] > b[i][j - 1]):
				pass
			else:
				y = 0
				break
				break
print(['Impossible', 'Possible'][y])


def double_matrix(n, m, matrix_1, matrix_2):
	for i in range(n):
		if matrix_1[i][0] > matrix_2[i][0]:
			(matrix_1[i][0], matrix_2[i][0]) = (matrix_2[i][0], matrix_1[i][0])
		for j in range(1, m):
			if matrix_1[i][j] > matrix_2[i][j]:
				(matrix_1[i][j], matrix_2[i][j]) = (matrix_2[i][j], matrix_1[i][j])
			if not matrix_1[i][j] > matrix_1[i][j - 1] or not matrix_2[i][j] > matrix_2[i][j - 1]:
				return 'Impossible'
	for k in range(m):
		for l in range(1, n):
			if not matrix_1[l][k] > matrix_1[l - 1][k] or not matrix_2[l][k] > matrix_2[l - 1][k]:
				return 'Impossible'
	return 'Possible'
(n, m) = map(int, input().split())
matrix_1 = []
matrix_2 = []
for _ in range(n):
	matrix_1.append(list(map(int, input().split())))
for __ in range(n):
	matrix_2.append(list(map(int, input().split())))
print(double_matrix(n, m, matrix_1, matrix_2))


(n, m) = map(int, input().split())
mat1 = []
mat2 = []
for i in range(n):
	mat1.append(list(map(int, input().split())))
for i in range(n):
	mat2.append(list(map(int, input().split())))
positions = []
positions2 = []
for i in range(n):
	for j in range(m - 1):
		if mat1[i][j] >= mat1[i][j + 1] or mat2[i][j] >= mat2[i][j + 1]:
			positions.append([i, j])
for i in range(n - 1):
	for j in range(m):
		if mat1[i][j] >= mat1[i + 1][j] or mat2[i][j] >= mat2[i + 1][j]:
			positions2.append([i, j])
for pos in positions:
	(i, j) = (pos[0], pos[1])
	if mat1[i][j] < mat2[i][j + 1] and mat2[i][j] < mat1[i][j + 1]:
		continue
	else:
		print('Impossible')
		quit()
for pos in positions2:
	(i, j) = (pos[0], pos[1])
	if mat1[i][j] < mat2[i + 1][j] and mat2[i][j] < mat1[i + 1][j]:
		continue
	else:
		print('Impossible')
		quit()
print('Possible')


def fun(a, b):
	for i in range(n):
		for j in range(m):
			if a[i][j] > b[i][j]:
				(a[i][j], b[i][j]) = (b[i][j], a[i][j])
	for i in range(n):
		for j in range(m - 1):
			if a[i][j] >= a[i][j + 1] or b[i][j] >= b[i][j + 1]:
				return 'Impossible'
	for i in range(n - 1):
		for j in range(m):
			if a[i][j] >= a[i + 1][j] or b[i][j] >= b[i + 1][j]:
				return 'Impossible'
	return 'Possible'
a = []
b = []
(n, m) = map(int, input().split())
for _ in range(n):
	row = list(map(int, input().split()))
	a.append(row)
for _ in range(n):
	row = list(map(int, input().split()))
	b.append(row)
print(fun(a, b))


ints = [int(x) for x in input().split()]
n = ints[0]
m = ints[1]
r = []
pos = True
for i in range(n):
	r.append([int(x) for x in input().split()])
for i in range(n):
	r.append([int(x) for x in input().split()])
	for j in range(m):
		if r[i][j] > r[i + n][j]:
			temp = r[i][j]
			r[i][j] = r[i + n][j]
			r[i + n][j] = temp
for i in range(2 * n):
	for j in range(m - 1):
		if r[i][j] >= r[i][j + 1]:
			pos = False
for i in range(m):
	for j in range(n - 1):
		if r[j][i] >= r[j + 1][i]:
			pos = False
		if r[j + n][i] >= r[j + n + 1][i]:
			pos = False
if pos:
	print('Possible')
else:
	print('Impossible')


(n, m) = map(int, input().split())
first = [list(map(int, input().split())) for _ in range(n)]
second = [list(map(int, input().split())) for _ in range(n)]
row = 0
column = 0
done = False
for i in range(n):
	for j in range(m):
		(first[i][j], second[i][j]) = (min(first[i][j], second[i][j]), max(first[i][j], second[i][j]))
for i in range(n - 1):
	for j in range(m):
		if first[i][j] >= first[i + 1][j] or second[i][j] >= second[i + 1][j]:
			done = True
	if done:
		break
for i in range(n):
	for j in range(m - 1):
		if first[i][j] >= first[i][j + 1] or second[i][j] >= second[i][j + 1]:
			done = True
	if done:
		break
if done:
	print('Impossible')
else:
	print('Possible')


import sys
input = sys.stdin.readline

def pprint(mat):
	for r in mat:
		print(r)

def swap(mat1, mat2, r, c):
	(mat1[r][c], mat2[r][c]) = (mat2[r][c], mat1[r][c])

def good(n, m, mat):
	for r in range(n):
		for c in range(m):
			if r > 0 and mat[r][c] <= mat[r - 1][c]:
				return False
			if c > 0 and mat[r][c] <= mat[r][c - 1]:
				return False
	return True
(n, m) = map(int, input().split())
mat1 = [[0] * m for _ in range(n)]
mat2 = [[0] * m for _ in range(n)]
for mat in (mat1, mat2):
	for r in range(n):
		row = mat[r]
		for (c, v) in enumerate(map(int, input().split())):
			row[c] = v
for r in range(n):
	for c in range(m):
		if mat1[r][c] > mat2[r][c]:
			swap(mat1, mat2, r, c)
if good(n, m, mat1) and good(n, m, mat2):
	print('Possible')
else:
	print('Impossible')


def chek(a):
	flag = False
	for i in range(1, len(a)):
		for j in range(1, len(a[i])):
			if a[i][j] <= a[i - 1][j] or a[i][j] <= a[i][j - 1]:
				flag = True
	if flag:
		return False
	return True
(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split())) for i in range(n)]
flag = False
a1 = [[-1 for k in range(m + 1)] for l in range(n + 1)]
for k in range(n):
	for l in range(m):
		a1[k + 1][l + 1] = min(a[k][l], b[k][l])
b1 = [[-1 for k in range(m + 1)] for l in range(n + 1)]
for k in range(n):
	for l in range(m):
		b1[k + 1][l + 1] = max(b[k][l], a[k][l])
if chek(b1) and chek(a1):
	flag = True
if flag:
	print('Possible')
else:
	print('Impossible')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, m) = map(int, input().split())
a = []
b = []
for i in range(n):
	l = list(map(int, input().split()))
	a.append(l)
for i in range(n):
	l = list(map(int, input().split()))
	b.append(l)
f = 0
for i in range(n):
	for j in range(m):
		if a[i][j] > b[i][j]:
			(a[i][j], b[i][j]) = (b[i][j], a[i][j])
for i in range(n):
	for j in range(m):
		t = 0
		if i >= 1 and a[i][j] <= a[i - 1][j]:
			t = 1
		elif j >= 1 and a[i][j] <= a[i][j - 1]:
			t = 1
		elif i < n - 1 and a[i][j] >= a[i + 1][j]:
			t = 1
		elif j < m - 1 and a[i][j] >= a[i][j + 1]:
			t = 1
		elif i >= 1 and b[i][j] <= b[i - 1][j]:
			t = 1
		elif j >= 1 and b[i][j] < b[i][j - 1]:
			t = 1
		elif i < n - 1 and b[i][j] >= b[i + 1][j]:
			t = 1
		elif j < m - 1 and b[i][j] >= b[i][j + 1]:
			t = 1
		if t == 1:
			f = 1
			break
if f == 1:
	print('Impossible')
else:
	print('Possible')


(n, m) = [int(i) for i in input().strip().split(' ')]
A = []
for _ in range(n):
	A += [[int(i) for i in input().strip().split(' ')]]
B = []
for _ in range(n):
	B += [[int(i) for i in input().strip().split(' ')]]

def get(M, i, j):
	if not 0 <= i < len(M) or not 0 <= j < len(M[0]):
		return None
	return M[i][j]

def choose(A, B, i, j):
	max_a = max(get(A, i - 1, j) or 0, get(A, i, j - 1) or 0)
	max_b = max(get(B, i - 1, j) or 0, get(B, i, j - 1) or 0)
	if max_a <= max_b:
		(A[i][j], B[i][j]) = (min(A[i][j], B[i][j]), max(A[i][j], B[i][j]))
	else:
		(A[i][j], B[i][j]) = (max(A[i][j], B[i][j]), min(A[i][j], B[i][j]))
	if not max_a < A[i][j]:
		return False
	elif not max_b < B[i][j]:
		return False
	return True
for i in range(n):
	for j in range(m):
		if i == 0 and j == 0:
			continue
		if not choose(A, B, i, j):
			print('Impossible')
			exit()
print('Possible')
exit()


i = lambda : [*map(int, input().split())]
(n, m) = i()
(a, b) = [[i() for _ in range(n)] for _ in [0, 1]]
for x in range(n):
	for y in range(m):
		if a[x][y] > b[x][y]:
			(a[x][y], b[x][y]) = (b[x][y], a[x][y])

def g(c):
	for x in range(n - 1):
		for y in range(m):
			if c[x][y] >= c[x + 1][y]:
				return 1
	for x in range(n):
		for y in range(m - 1):
			if c[x][y] >= c[x][y + 1]:
				return 1
	return 0
print(('Imp' if g(a) | g(b) else 'P') + 'ossible')


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
	for j in range(m):
		if a[i][j] > b[i][j]:
			(a[i][j], b[i][j]) = (b[i][j], a[i][j])

def go(x):
	for i in range(n):
		for j in range(m):
			if i and x[i][j] <= x[i - 1][j]:
				return 0
			if j and x[i][j] <= x[i][j - 1]:
				return 0
	return 1
print('Possible' if go(a) and go(b) else 'Impossible')


(n, m) = map(int, input().split())
A = []
for _ in range(n):
	A += [[int(x) for x in input().split()]]
B = []
for _ in range(n):
	B += [[int(x) for x in input().split()]]
for i in range(n):
	for j in range(m):
		(A[i][j], B[i][j]) = sorted([A[i][j], B[i][j]])
good = True
for i in range(n):
	for j in range(m - 1):
		good &= A[i][j] < A[i][j + 1]
for i in range(n):
	for j in range(m - 1):
		good &= B[i][j] < B[i][j + 1]
for j in range(m):
	for i in range(n - 1):
		good &= A[i][j] < A[i + 1][j]
for j in range(m):
	for i in range(n - 1):
		good &= B[i][j] < B[i + 1][j]
print('Possible' if good else 'Impossible')


def relation_type(x, y):
	if min(y) > max(x):
		return 'any'
	elif min(y) > min(x) and max(y) > max(x):
		if (y[1] > y[0]) == (x[1] > x[0]):
			return 'equal'
		else:
			return 'opposite'
	else:
		return 'infeasible'

class InfeasibleRelation(Exception):
	pass

class Swapper:

	def __init__(self, a_mat, b_mat):
		self.matrix = (a_mat, b_mat)
		self.v_size = len(a_mat)
		self.h_size = len(b_mat[0])
		free_elem = set()
		for i in range(self.v_size):
			free_elem |= {(i, j) for j in range(self.h_size)}
		self.free_elem = free_elem
		self.active_elem = set()
		self.hold_elem = dict()

	def relation(self, x, y):
		(xi, xj) = x
		(yi, yj) = y
		if xi in range(self.v_size) and xj in range(self.h_size) and (yi in range(self.v_size)) and (yj in range(self.h_size)):
			if abs(xi - yi) == 1 and xj == yj or (xi == yi and abs(xj - yj) == 1):
				(xi, yi) = (min(xi, yi), max(xi, yi))
				(xj, yj) = (min(xj, yj), max(xj, yj))
				pair_a = (self.matrix[0][xi][xj], self.matrix[1][xi][xj])
				pair_b = (self.matrix[0][yi][yj], self.matrix[1][yi][yj])
				return relation_type(pair_a, pair_b)
		return 'any'

	def relation_matrix(self):
		v_size = self.v_size
		h_size = self.h_size
		v_rel = [[None] * h_size for _ in range(v_size)]
		h_rel = [[None] * h_size for _ in range(v_size)]
		for i in range(v_size):
			for j in range(h_size):
				v_rel[i][j] = self.relation((i, j), (i + 1, j))
				h_rel[i][j] = self.relation((i, j), (i, j + 1))
		return (v_rel, h_rel)

	def _mark_neighbours(self, elem):
		(m, n) = elem
		free_elem = self.free_elem
		active_elem = self.active_elem
		for cand in [(m - 1, n), (m, n - 1), (m + 1, n), (m, n + 1)]:
			rel = self.relation(elem, cand)
			if cand in free_elem and rel != 'any':
				free_elem.remove(cand)
				active_elem.add(cand)

	def _derive_from_neighbour(self, elem):
		hold_elem = self.hold_elem
		derived_val = []
		(m, n) = elem
		for neighbour in [(m - 1, n), (m, n - 1), (m + 1, n), (m, n + 1)]:
			if neighbour in hold_elem:
				rel = self.relation(elem, neighbour)
				if rel == 'equal':
					val = hold_elem[neighbour]
					derived_val.append(val)
				elif rel == 'opposite':
					val = not hold_elem[neighbour]
					derived_val.append(val)
				elif rel == 'any':
					pass
				elif rel == 'infeasible':
					raise InfeasibleRelation()
				else:
					raise AssertionError('unknown relation type')
		assert derived_val, 'active element has no hold neighbours'
		common_val = derived_val[0]
		if all((val == common_val for val in derived_val)):
			return common_val
		else:
			raise InfeasibleRelation()

	def _process_active_elem(self):
		active_elem = self.active_elem
		hold_elem = self.hold_elem
		while active_elem:
			elem = active_elem.pop()
			self._mark_neighbours(elem)
			val = self._derive_from_neighbour(elem)
			hold_elem[elem] = val

	def find_swap_mat(self):
		free_elem = self.free_elem
		active_elem = self.active_elem
		hold_elem = self.hold_elem
		while free_elem:
			elem = free_elem.pop()
			hold_elem[elem] = False
			self._mark_neighbours(elem)
			self._process_active_elem()
		assert not free_elem
		assert not active_elem
		swap_mat = [[None] * self.h_size for _ in range(self.v_size)]
		for i in range(self.v_size):
			for j in range(self.h_size):
				swap_mat[i][j] = hold_elem[i, j]
		return swap_mat

def print_relation(swapper):
	(v_rel, h_rel) = swapper.relation_matrix()
	rel_code = {'equal': '=', 'opposite': '!', 'any': '?', 'infeasible': '#'}
	print('vertical relation')
	for row in v_rel:
		row_code = [rel_code[rel] for rel in row]
		print(' '.join(row_code))
	print('horizontal relation')
	for row in h_rel:
		row_code = [rel_code[rel] for rel in row]
		print(' '.join(row_code))

def swap_matrix(a_mat, b_mat, swap_mat):
	v_size = len(a_mat)
	h_size = len(a_mat[0])
	for i in range(v_size):
		for j in range(h_size):
			if swap_mat[i][j]:
				(a_mat[i][j], b_mat[i][j]) = (b_mat[i][j], a_mat[i][j])

def is_ascending(mat):
	v_size = len(mat)
	h_size = len(mat[0])
	for i in range(v_size - 1):
		for j in range(h_size):
			if not mat[i + 1][j] > mat[i][j]:
				return False
	for i in range(v_size):
		for j in range(h_size - 1):
			if not mat[i][j + 1] > mat[i][j]:
				return False
	return True

def check_matrix(a_mat, b_mat):
	swapper = Swapper(a_mat, b_mat)
	try:
		swap_mat = swapper.find_swap_mat()
	except InfeasibleRelation:
		return False
	swap_matrix(a_mat, b_mat, swap_mat)
	assert is_ascending(a_mat)
	assert is_ascending(b_mat)
	return True
(v_size, h_size) = [int(num) for num in input().split()]
a_mat = []
for _ in range(v_size):
	row = [int(num) for num in input().split()]
	a_mat.append(row)
b_mat = []
for _ in range(v_size):
	row = [int(num) for num in input().split()]
	b_mat.append(row)
if check_matrix(a_mat, b_mat):
	print('Possible')
else:
	print('Impossible')


(n, m) = [int(item) for item in input().split()]
a = []
b = []
for _ in range(n):
	a.append([int(item) for item in input().split()])
for _ in range(n):
	b.append([int(item) for item in input().split()])

def ok(arr, i, j):
	if i == 0 and j == 0:
		return True
	elif i == 0:
		return arr[i][j] > arr[i][j - 1]
	elif j == 0:
		return arr[i][j] > arr[i - 1][j]
	return arr[i][j] > max(arr[i][j - 1], arr[i - 1][j])

def solve():
	for i in range(n):
		for j in range(m):
			(a[i][j], b[i][j]) = (min(b[i][j], a[i][j]), max(b[i][j], a[i][j]))
			if not ok(a, i, j) or not ok(b, i, j):
				return False
	return True
print('Possible' if solve() else 'Impossible')


def f(n, m, M1, M2):
	for i in range(n):
		for j in range(m):
			maior = max(M1[i][j], M2[i][j])
			menor = min(M1[i][j], M2[i][j])
			(M1[i][j], M2[i][j]) = (menor, maior)
			if i - 1 >= 0:
				if M1[i - 1][j] >= M1[i][j] or M2[i - 1][j] >= M2[i][j]:
					return 'Impossible'
			if j - 1 >= 0:
				if M1[i][j - 1] >= M1[i][j] or M2[i][j - 1] >= M2[i][j]:
					return 'Impossible'
	return 'Possible'
(n, m) = [int(a) for a in input().split()]
M1 = [[int(a) for a in input().split()] for b in range(n)]
M2 = [[int(a) for a in input().split()] for b in range(n)]
print(f(n, m, M1, M2))


def double_matrix(N: int, M: int, A: list, B: list) -> bool:

	def ok(mat: list, i: int, j: int) -> bool:
		if 0 < i and mat[i][j] <= mat[i - 1][j]:
			return False
		if 0 < j and mat[i][j] <= mat[i][j - 1]:
			return False
		return True
	for i in range(N):
		for j in range(M):
			(ua, ub) = (0, 0) if i == 0 else (A[i - 1][j], B[i - 1][j])
			(la, lb) = (0, 0) if j == 0 else (A[i][j - 1], B[i][j - 1])
			(a, b) = (A[i][j], B[i][j])
			if ua < a and la < a and (ub < b) and (lb < b):
				continue
			if ua < a and lb < a and (ub < b) and (la < b):
				continue
			if ub < a and la < a and (ua < b) and (lb < b):
				continue
			if ub < a and lb < a and (ua < b) and (la < b):
				continue
			return False
	return True
N = 0
(N, M) = map(int, input().split())
A = [[int(s) for s in input().split()] for _ in range(N)]
B = [[int(s) for s in input().split()] for _ in range(N)]
yes = double_matrix(N, M, A, B)
print('Possible' if yes else 'Impossible')


def go():
	(n, m) = map(int, input().split(' '))
	m1 = []
	m2 = []
	max1 = max2 = 0
	for _ in range(n):
		m1.append([int(i) for i in input().split(' ')])
	for _ in range(n):
		m2.append([int(i) for i in input().split(' ')])
	for i in range(n):
		for j in range(m):
			(m1[i][j], m2[i][j]) = (max(m1[i][j], m2[i][j]), min(m1[i][j], m2[i][j]))
			max1 = max(max1, m1[i][j])
			max2 = max(max2, m2[i][j])
	if verify_matrix(m1, n, m) and verify_matrix(m2, n, m) and (m1[n - 1][m - 1] == max1) and (m2[n - 1][m - 1] == max2):
		return 'Possible'
	return 'Impossible'

def verify_matrix(a, n, m):
	maximum = 0
	for i in range(n):
		for j in range(1, m):
			if a[i][j] <= a[i][j - 1]:
				return False
	for i in range(m):
		for j in range(1, n):
			if a[j][i] <= a[j - 1][i]:
				return False
	return True
print(go())


(n, m) = list(map(int, input().split()))
a = []
b = []
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(n):
	b.append(list(map(int, input().split())))
for i in range(n):
	for j in range(m):
		if a[i][j] > b[i][j]:
			(a[i][j], b[i][j]) = (b[i][j], a[i][j])
f = 0
for i in range(n):
	for j in range(m):
		if i == 0 and j == 0:
			continue
		elif i > 0 and i < n and (j > 0) and (j < m):
			if a[i][j] > a[i - 1][j] and a[i][j] > a[i][j - 1]:
				continue
			else:
				f = 1
				break
		elif i == 0 and a[i][j] > a[i][j - 1]:
			continue
		elif j == 0 and a[i][j] > a[i - 1][j]:
			continue
		else:
			f = 1
			break
	if f == 1:
		break
if f == 1:
	print('Impossible')
else:
	for i in range(n):
		for j in range(m):
			if i == 0 and j == 0:
				continue
			elif i > 0 and i < n and (j > 0) and (j < m):
				if b[i][j] > b[i - 1][j] and b[i][j] > b[i][j - 1]:
					continue
				else:
					f = 1
					break
			elif i == 0 and b[i][j] > b[i][j - 1]:
				continue
			elif j == 0 and b[i][j] > b[i - 1][j]:
				continue
			else:
				f = 1
				break
		if f == 1:
			break
	if f == 1:
		print('Impossible')
	else:
		print('Possible')


def main():
	from sys import stdin, stdout

	def read():
		return stdin.readline().rstrip('\n')

	def read_array(sep=None, maxsplit=-1):
		return read().split(sep, maxsplit)

	def read_int():
		return int(read())

	def read_int_array(sep=None, maxsplit=-1):
		return [int(a) for a in read_array(sep, maxsplit)]

	def write(*args, **kwargs):
		sep = kwargs.get('sep', ' ')
		end = kwargs.get('end', '\n')
		stdout.write(sep.join((str(a) for a in args)) + end)

	def write_array(array, **kwargs):
		sep = kwargs.get('sep', ' ')
		end = kwargs.get('end', '\n')
		stdout.write(sep.join((str(a) for a in array)) + end)
	(n, m) = read_int_array()
	(minm, maxm) = ([], [])
	for _ in range(n):
		minm.append(read_int_array())
	for _ in range(n):
		maxm.append(read_int_array())
	for r in range(n):
		for c in range(m):
			minx = min(minm[r][c], maxm[r][c])
			maxx = max(minm[r][c], maxm[r][c])
			if r:
				if minx <= minm[r - 1][c] or maxx <= maxm[r - 1][c]:
					write('Impossible')
					return
			if c:
				if minx <= minm[r][c - 1] or maxx <= maxm[r][c - 1]:
					write('Impossible')
					return
			minm[r][c] = minx
			maxm[r][c] = maxx
	write('Possible')
main()


from functools import reduce
(n, m) = list(map(int, input().split(' ')))

def is_rows_asc(lst):
	res = True
	for i in range(len(lst)):
		for j in range(len(lst[i]) - 1):
			if lst[i][j] >= lst[i][j + 1]:
				return False
	return res

def is_cols_asc(lst):
	res = True
	for i in range(len(lst) - 1):
		for j in range(len(lst[i])):
			if lst[i][j] >= lst[i + 1][j]:
				return False
	return res
l1 = [0 for _ in range(n)]
for i in range(n):
	l1[i] = list(map(int, input().split(' ')))
l2 = [0 for _ in range(n)]
for i in range(n):
	l2[i] = list(map(int, input().split(' ')))
for i in range(n):
	for j in range(m):
		if l1[i][j] > l2[i][j]:
			(l1[i][j], l2[i][j]) = (l2[i][j], l1[i][j])
if is_rows_asc(l1) and is_cols_asc(l1) and is_rows_asc(l2) and is_cols_asc(l2):
	print('Possible')
else:
	print('Impossible')


N = 55
a = [[1061109567] * N] * N
b = [[1061109567] * N] * N
(n, m) = map(int, input().split())
for i in range(n):
	a[i] = list(map(int, input().split()))
	a[i].append(1061109567)
for i in range(n):
	b[i] = list(map(int, input().split()))
	b[i].append(1061109567)
for i in range(n):
	for j in range(m):
		if a[i][j] > b[i][j]:
			(a[i][j], b[i][j]) = (b[i][j], a[i][j])
for i in range(n):
	for j in range(m):
		if a[i][j] >= a[i][j + 1] or a[i][j] >= a[i + 1][j] or b[i][j] >= b[i + 1][j] or (b[i][j] >= b[i][j + 1]):
			print('Impossible')
			exit()
print('Possible')


from sys import stdin
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
hg = lambda x, y: (y + x - 1) // x * x
chk = lambda r, c: True if a[r][c] >= a[r + 1][c] <= b[r][c] or a[r][c] >= b[r + 1][c] <= b[r][c] or a[r][c] >= a[r][c + 1] <= b[r][c] or (a[r][c] >= b[r][c + 1] <= b[r][c]) or (a[r + 1][c] <= a[r][c] >= b[r + 1][c]) or (a[r + 1][c] <= b[r][c] >= b[r + 1][c]) or (a[r][c + 1] <= a[r][c] >= b[r][c + 1]) or (a[r][c + 1] <= b[r][c] >= b[r][c + 1]) else False
N = 10 ** 9 + 7

def mtrx(r, c):
	mtx = []
	for i in range(r):
		mtx += (list(R()) + [N],)
	return mtx + [[N] * (c + 1)]
(r, c) = R()
a = mtrx(r, c)
b = mtrx(r, c)
for i in range(r):
	for j in range(c):
		if chk(i, j):
			exit(print('Impossible'))
print('Possible')


import math
import os
import random
import re
import sys

def main():
	(n, m) = map(int, input().split())
	a = []
	b = []
	for _ in range(0, n):
		a.append([*map(int, input().split())])
	for _ in range(0, n):
		b.append([*map(int, input().split())])
	for i in range(0, n):
		for j in range(0, m):
			(a[i][j], b[i][j]) = sorted([a[i][j], b[i][j]])
	for tmp in range(2):
		if tmp == 0:
			matrix = a
		else:
			matrix = b
		for i in range(0, n):
			for j in range(0, m - 1):
				if matrix[i][j] >= matrix[i][j + 1]:
					print('Impossible')
					return
		for i in range(0, n - 1):
			for j in range(0, m):
				if matrix[i][j] >= matrix[i + 1][j]:
					print('Impossible')
					return
	print('Possible')

def return_input_tuple():
	return tuple(map(int, input().split(' ')))
main()


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
arr1 = []
for i in range(n):
	arr1.append(list(map(int, input().split())))
arr2 = []
for i in range(n):
	arr2.append(list(map(int, input().split())))
arr3 = []
arr4 = []
for i in range(n):
	arr3.append([])
	arr4.append([])
	for j in range(m):
		arr3[i].append(min(arr1[i][j], arr2[i][j]))
		arr4[i].append(max(arr1[i][j], arr2[i][j]))
flag = False
for i in range(n):
	for j in range(m):
		try:
			if arr3[i][j] >= arr3[i][j + 1] or arr4[i][j] >= arr4[i][j + 1]:
				print('Impossible')
				flag = True
				break
		except:
			pass
		try:
			if arr3[i][j] >= arr3[i + 1][j] or arr4[i][j] >= arr4[i + 1][j]:
				print('Impossible')
				flag = True
				break
		except:
			pass
	if flag:
		break
if not flag:
	print('Possible')


(n, m) = [int(x) for x in input().split()]

def check(matr):
	for row in matr:
		for i in range(len(row) - 1):
			if row[i] >= row[i + 1]:
				return False
	for i in range(m):
		for j in range(n - 1):
			if matr[j][i] >= matr[j + 1][i]:
				return False
	return True
a = [[int(elem) for elem in input().split()] for _ in range(n)]
b = [[int(elem) for elem in input().split()] for _ in range(n)]
for i in range(n):
	for j in range(m):
		(a[i][j], b[i][j]) = (min(a[i][j], b[i][j]), max(a[i][j], b[i][j]))
if check(a) and check(b):
	print('Possible')
else:
	print('Impossible')


from sys import stdin, stdout

def row(a, r):
	prev = a[r][0]
	for i in range(1, cc):
		if a[r][i] <= prev:
			return False
		prev = a[r][i]
	return True

def col(a, c):
	prev = a[0][c]
	for i in range(1, rr):
		if a[i][c] <= prev:
			return False
		prev = a[i][c]
	return True
for _ in range(1):
	(rr, cc) = list(map(int, stdin.readline().split()))
	a = [list(map(int, stdin.readline().split())) for _ in range(rr)]
	b = [list(map(int, stdin.readline().split())) for _ in range(rr)]
	for i in range(rr):
		for j in range(cc):
			if b[i][j] < a[i][j]:
				(b[i][j], a[i][j]) = (a[i][j], b[i][j])
	f = 1
	for i in range(rr):
		if not row(a, i) or not row(b, i):
			f = 0
			break
	for i in range(cc):
		if not col(a, i) or not col(b, i):
			f = 0
			break
	print('Possible' if f else 'Impossible')


(n, m) = [int(x) for x in input().split()]
a = []
b = []
T_F = True
for i in range(n):
	a.append([int(x) for x in input().split()])
for i in range(n):
	b.append([int(x) for x in input().split()])
for i in range(n):
	for j in range(m):
		if a[i][j] > b[i][j]:
			(a[i][j], b[i][j]) = (b[i][j], a[i][j])

def sort_mat(a):
	for i in range(n):
		for j in range(m):
			if i + 1 < n:
				if a[i][j] >= a[i + 1][j]:
					return False
			if j + 1 < m:
				if a[i][j] >= a[i][j + 1]:
					return False
	return True
if sort_mat(a) and sort_mat(b):
	print('Possible')
else:
	print('Impossible')


(n, m) = map(int, input().split())
a = []
b = []
for i in range(n):
	a.append([int(x) for x in input().split()])
for i in range(n):
	b.append([int(x) for x in input().split()])
for i in range(1, n):
	for j in range(m):
		if not (a[i][j] > a[i - 1][j] and b[i][j] > b[i - 1][j] or (a[i][j] > b[i - 1][j] and b[i][j] > a[i - 1][j])):
			print('Impossible')
			break
	else:
		continue
	break
else:
	for i in range(n):
		for j in range(1, m):
			if not (a[i][j] > a[i][j - 1] and b[i][j] > b[i][j - 1] or (a[i][j] > b[i][j - 1] and b[i][j] > a[i][j - 1])):
				print('Impossible')
				break
		else:
			continue
		break
	else:
		print('Possible')


(n, m) = map(int, input().split())
a = [[int(s) for s in input().split()] for i in range(n)]
b = [[int(s) for s in input().split()] for i in range(n)]
for i in range(n):
	for j in range(m):
		(a[i][j], b[i][j]) = (min(a[i][j], b[i][j]), max(a[i][j], b[i][j]))
for i in range(n):
	for j in range(m - 1):
		if a[i][j] >= a[i][j + 1] or b[i][j] >= b[i][j + 1]:
			print('Impossible')
			exit()
for j in range(m):
	for i in range(n - 1):
		if a[i][j] >= a[i + 1][j] or b[i][j] >= b[i + 1][j]:
			print('Impossible')
			exit()
print('Possible')


import sys
import io, os
import math
gcd = math.gcd

def ceil(a, b):
	a = -a
	f = a // b
	return -f
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def binsearch(arr, k):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		mid = (l + r) // 2
		if not arr[mid] > k:
			l = mid + 1
			ans = mid
		else:
			r = mid - 1
	return ans + 1

def strinp(testcases):
	k = 5
	if testcases == -1 or testcases == 1:
		k = 1
	f = str(input())
	f = f[2:len(f) - k]
	return f

def ind(a):
	return ord(a) - ord('a') + 1

def main():
	t = 1
	for _ in range(t):
		inf = list(map(int, input().split()))
		n = inf[0]
		m = inf[1]
		mat1 = [0] * n
		mat2 = [0] * n
		for i in range(n):
			mat1[i] = list(map(int, input().split()))
		for i in range(n):
			mat2[i] = list(map(int, input().split()))
		for i in range(n):
			for j in range(m):
				cur = mat1[i][j]
				pot = mat2[i][j]
				if i > 0 and cur > mat1[i - 1][j] and (j > 0) and (cur > mat1[i][j - 1]):
					if pot >= cur:
						continue
					if i > 0 and pot > mat1[i - 1][j] and (j > 0) and (pot > mat1[i][j - 1]):
						mat1[i][j] = pot
						mat2[i][j] = cur
						continue
				elif j == 0 and i > 0 and (cur > mat1[i - 1][j]):
					if pot >= cur:
						continue
					if j == 0 and i > 0 and (pot > mat1[i - 1][j]):
						mat1[i][j] = pot
						mat2[i][j] = cur
						continue
				elif i == 0 and j > 0 and (cur > mat1[i][j - 1]):
					if pot >= cur:
						continue
					if i == 0 and j > 0 and (pot > mat1[i][j - 1]):
						mat1[i][j] = pot
						mat2[i][j] = cur
						continue
				elif i == 0 and j == 0:
					mat1[i][j] = min(cur, pot)
					mat2[i][j] = cur + pot - mat1[i][j]
				else:
					mat1[i][j] = pot
					mat2[i][j] = cur
		trig = False
		arr = mat1
		for i in range(n):
			for j in range(1, m):
				if arr[i][j] <= arr[i][j - 1] or mat2[i][j] <= mat2[i][j - 1]:
					trig = True
					break
			if trig:
				break
		if trig:
			print('Impossible')
			continue
		for i in range(m):
			for j in range(1, n):
				if arr[j][i] <= arr[j - 1][i] or mat2[j][i] <= mat2[j - 1][i]:
					trig = True
					break
			if trig:
				break
		if trig:
			print('Impossible')
		else:
			print('Possible')
main()


def is_increasing(mat):
	for i in range(1, len(mat)):
		for j in range(len(mat[0])):
			if mat[i][j] <= mat[i - 1][j]:
				return False
	for i in range(len(mat)):
		for j in range(1, len(mat[0])):
			if mat[i][j] <= mat[i][j - 1]:
				return False
	return True
(n, m) = map(int, input().strip().split())
ma = [[], []]
for i in range(2):
	for j in range(n):
		ma[i].append(list(map(int, input().strip().split())))
for i in range(len(ma[0])):
	for j in range(len(ma[0][0])):
		if ma[0][i][j] > ma[1][i][j]:
			(ma[0][i][j], ma[1][i][j]) = (ma[1][i][j], ma[0][i][j])
if is_increasing(ma[0]) and is_increasing(ma[1]):
	print('Possible')
else:
	print('Impossible')


def check(a, b, n, m):
	for i in range(n):
		for j in range(1, m):
			if a[i][j] <= a[i][j - 1] or b[i][j] <= b[i][j - 1]:
				return False
	for j in range(m):
		for i in range(1, n):
			if a[i][j] <= a[i - 1][j] or b[i][j] <= b[i - 1][j]:
				return False
	return True
(n, m) = map(int, input().split())
a = [[] * m] * n
b = [[] * m] * n
for i in range(n):
	a[i] = list(map(int, input().split()))
for i in range(n):
	b[i] = list(map(int, input().split()))
for i in range(n):
	for j in range(m):
		(a[i][j], b[i][j]) = (min(a[i][j], b[i][j]), max(a[i][j], b[i][j]))
if check(a, b, n, m):
	print('Possible')
else:
	print('Impossible')


def check(a, n, m):
	for i in range(n):
		if sorted(a[i]) != a[i] or len(a[i]) != len(set(a[i])):
			return 0
	return 1
(n, m) = map(int, input().split())
a = []
b = []
a1 = []
b1 = []
for i in range(m):
	a1.append([0] * n)
	b1.append([0] * n)
for i in range(n):
	l = [int(x) for x in input().split()]
	a.append(l)
for i in range(n):
	l = [int(x) for x in input().split()]
	b.append(l)
for i in range(n):
	for j in range(m):
		x = a[i][j]
		y = b[i][j]
		a[i][j] = min(x, y)
		b[i][j] = max(x, y)
for i in range(n):
	for j in range(m):
		a1[j][i] = a[i][j]
		b1[j][i] = b[i][j]
if check(a, n, m) == 1 and check(a1, m, n) == 1 and (check(b, n, m) == 1) and (check(b1, m, n) == 1):
	print('Possible')
else:
	print('Impossible')


(n, m) = list(map(int, input().split()))
a = []
b = []
for i in range(n):
	tl = list(map(int, input().split()))
	a.append(tl)
for i in range(n):
	tl = list(map(int, input().split()))
	b.append(tl)
mim = []
mam = []
for i in range(n):
	mimtl = []
	mamtl = []
	for j in range(m):
		mimtl.append(min(a[i][j], b[i][j]))
		mamtl.append(max(a[i][j], b[i][j]))
	mim.append(mimtl)
	mam.append(mamtl)
p = True
for i in range(n - 1):
	if not p:
		break
	for j in range(m - 1):
		if mim[i][j] >= mim[i + 1][j] or mam[i][j] >= mam[i + 1][j] or mim[i][j] >= mim[i][j + 1] or (mam[i][j] >= mam[i][j + 1]):
			p = False
			break
for i in range(n - 1):
	if mim[i][m - 1] >= mim[i + 1][m - 1] or mam[i][m - 1] >= mam[i + 1][m - 1]:
		p = False
		break
for j in range(m - 1):
	if mim[n - 1][j] >= mim[n - 1][j + 1] or mam[n - 1][j] >= mam[n - 1][j + 1]:
		p = False
		break
print('Possible' if p else 'Impossible')


def main():
	[n, m] = list(map(int, input().split()))
	A = [list(map(int, input().split())) for i in range(n)]
	B = [list(map(int, input().split())) for i in range(n)]
	for i in range(n):
		prev1 = A[i][0]
		prev2 = B[i][0]
		for j in range(1, m):
			if prev1 < A[i][j] and prev2 < B[i][j]:
				prev1 = A[i][j]
				prev2 = B[i][j]
			elif prev1 < B[i][j] and prev2 < A[i][j]:
				(A[i][j], B[i][j]) = (B[i][j], A[i][j])
				prev1 = A[i][j]
				prev2 = B[i][j]
			else:
				print('Impossible')
				return
	for j in range(m):
		prev1 = A[0][j]
		prev2 = B[0][j]
		for i in range(1, n):
			if prev1 < A[i][j] and prev2 < B[i][j]:
				prev1 = A[i][j]
				prev2 = B[i][j]
			elif prev1 < B[i][j] and prev2 < A[i][j]:
				(A[i][j], B[i][j]) = (B[i][j], A[i][j])
				prev1 = A[i][j]
				prev2 = B[i][j]
			else:
				print('Impossible')
				return
	print('Possible')
main()


import sys

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline().strip()

def main():
	(n, m) = get_ints()
	A = [0] * n
	B = [0] * n
	for i in range(n):
		A[i] = get_array()
	for i in range(n):
		B[i] = get_array()
	for i in range(n):
		for j in range(m):
			if A[i][j] < B[i][j]:
				(A[i][j], B[i][j]) = (B[i][j], A[i][j])
	for i in range(n):
		for j in range(m):
			if i > 0 and A[i][j] <= A[i - 1][j]:
				print('Impossible')
				return
			if j > 0 and A[i][j] <= A[i][j - 1]:
				print('Impossible')
				return
	for i in range(n):
		for j in range(m):
			if i > 0 and B[i][j] <= B[i - 1][j]:
				print('Impossible')
				return
			if j > 0 and B[i][j] <= B[i][j - 1]:
				print('Impossible')
				return
	print('Possible')
main()


si = lambda : input()
ii = lambda : int(input())
ti = lambda : map(int, input().split())
li = lambda : list(ti())
(n, m) = ti()
(m1, m2, ms, mb) = ([], [], [], [])
for x in range(0, n):
	m1.append(li())
for x in range(0, n):
	m2.append(li())
for x in range(0, n):
	ms.append([min(m1[x][i], m2[x][i]) for i in range(0, m)])
	mb.append([max(m1[x][i], m2[x][i]) for i in range(0, m)])
flag = 1
for x in range(0, n):
	for y in range(0, m - 1):
		if ms[x][y] >= ms[x][y + 1]:
			flag = 0
		if mb[x][y] >= mb[x][y + 1]:
			flag = 0
for x in range(0, m):
	for y in range(0, n - 1):
		if ms[y][x] >= ms[y + 1][x]:
			flag = 0
		if mb[y][x] >= mb[y + 1][x]:
			flag = 0
if flag == 1:
	print('Possible')
else:
	print('Impossible')


(n, m) = [int(i) for i in input().split(' ')]
m1 = [None] * n
m2 = [None] * n
for mtx in [m1, m2]:
	for i in range(n):
		mtx[i] = [int(i) for i in input().split(' ')]
possible = True
for i in range(n):
	for j in range(m):
		if m1[i][j] > m2[i][j]:
			(m1[i][j], m2[i][j]) = (m2[i][j], m1[i][j])
for i in range(n):
	for j in range(m):
		if i > 0:
			if m1[i][j] <= m1[i - 1][j] or m2[i][j] <= m2[i - 1][j]:
				possible = False
				break
		if j > 0:
			if m1[i][j] <= m1[i][j - 1] or m2[i][j] <= m2[i][j - 1]:
				possible = False
				break
print('Possible' if possible else 'Impossible')


(n, m) = map(int, input().split())
sp1 = []
sp2 = []
for i in range(n):
	sp1.append(list(map(int, input().split())))
for i in range(n):
	sp2.append(list(map(int, input().split())))
for i in range(n):
	for j in range(m):
		if j < m - 1 and sp1[i][j] >= sp1[i][j + 1]:
			if sp2[i][j] < sp1[i][j + 1] and sp1[i][j] < sp2[i][j + 1]:
				(sp1[i][j], sp2[i][j]) = (sp2[i][j], sp1[i][j])
			else:
				print('Impossible')
				exit(0)
		if i < n - 1 and sp1[i][j] >= sp1[i + 1][j]:
			if sp2[i][j] < sp1[i + 1][j] and sp1[i][j] < sp2[i + 1][j]:
				(sp1[i][j], sp2[i][j]) = (sp2[i][j], sp1[i][j])
			else:
				print('Impossible')
				exit(0)
		if j < m - 1 and sp2[i][j] >= sp2[i][j + 1]:
			if sp1[i][j] < sp2[i][j + 1] and sp2[i][j] < sp1[i][j + 1]:
				(sp2[i][j], sp1[i][j]) = (sp1[i][j], sp2[i][j])
			else:
				print('Impossible')
				exit(0)
		if i < n - 1 and sp2[i][j] >= sp2[i + 1][j]:
			if sp1[i][j] < sp2[i + 1][j] and sp2[i][j] < sp1[i + 1][j]:
				(sp1[i][j], sp2[i][j]) = (sp2[i][j], sp1[i][j])
			else:
				print('Impossible')
				exit(0)
print('Possible')


exec('m, n = [int(i) for i in input().split()]\nmat1 = []\nfor i in range(m):\n    mat1.append([int(j) for j in input().split()])\nmat2 = []\nfor i in range(m):\n    mat2.append([int(j) for j in input().split()])\n\nfor i in range(m):\n    for j in range(n):\n        mat1[i][j], mat2[i][j] = min(mat1[i][j], mat2[i][j]), max(mat1[i][j], mat2[i][j])\n\n\ndef isgood(mat):\n    for i in range(m):\n        a = -1\n        for j in range(n):\n            if mat[i][j] <= a:\n                return False\n            a = mat[i][j]\n    for j in range(n):\n        a = -1\n        for i in range(m):\n            if mat[i][j] <= a:\n                return False\n            a = mat[i][j]\n    return True\n\nif isgood(mat1) and isgood(mat2):\n    print("Possible")\nelse:\n    print(\'Impossible\')')


(N, M) = map(int, input().split())
First = []
Second = []
for i in range(N):
	temp = [int(x) for x in input().split()]
	First.append(temp)
for i in range(N):
	temp = [int(x) for x in input().split()]
	Second.append(temp)
Resultant = [[0 for i in range(M)] for j in range(N)]
for i in range(N):
	for j in range(M):
		Resultant[i][j] = sorted([First[i][j], Second[i][j]])
flag = 0
for i in range(1, M):
	if Resultant[0][i][0] <= Resultant[0][i - 1][0]:
		flag = 1
		break
	if Resultant[0][i][1] <= Resultant[0][i - 1][1]:
		flag = 1
		break
for j in range(1, N):
	if Resultant[j][0][0] <= Resultant[j - 1][0][0]:
		flag = 1
		break
	if Resultant[j][0][1] <= Resultant[j - 1][0][1]:
		flag = 1
		break
if flag:
	print('Impossible')
	exit()
for i in range(1, N):
	for j in range(1, M):
		if Resultant[i][j][0] <= Resultant[i][j - 1][0] or Resultant[i][j][0] <= Resultant[i - 1][j][0]:
			flag = 1
			break
		if Resultant[i][j][1] <= Resultant[i][j - 1][1] or Resultant[i][j][1] <= Resultant[i - 1][j][1]:
			flag = 1
			break
	if flag:
		break
if flag:
	print('Impossible')
else:
	print('Possible')


(n, m) = map(int, input().split())
a = []
b = []
for i in range(n):
	l = list(map(int, input().split()))
	a.append(l)
for i in range(n):
	l = list(map(int, input().split()))
	b.append(l)

def app(c):
	for i in range(1, m):
		if c[0][i] <= c[0][i - 1]:
			return False
	for i in range(1, n):
		if c[i][0] <= c[i - 1][0]:
			return False
	for i in range(1, n):
		for j in range(i, m):
			if c[i][j] <= c[i - 1][j] or c[i][j] <= c[i][j - 1]:
				return False
	return True
for i in range(n):
	for j in range(m):
		if a[i][j] > b[i][j]:
			(a[i][j], b[i][j]) = (b[i][j], a[i][j])
if app(a) and app(b):
	print('Possible')
else:
	print('Impossible')


def main():
	(n, m) = map(int, input().split())
	(a, b) = ([], [])
	for i in range(n):
		a.append(list(map(int, input().split())))
	for i in range(n):
		b.append(list(map(int, input().split())))

	def check(mat, i, j):
		if i > 0 and mat[i][j] <= mat[i - 1][j]:
			return False
		if j > 0 and mat[i][j] <= mat[i][j - 1]:
			return False
		return True
	for i in range(n):
		for j in range(m):
			(a[i][j], b[i][j]) = (min(a[i][j], b[i][j]), max(a[i][j], b[i][j]))
	for i in range(n):
		for j in range(m):
			if not check(a, i, j) or not check(b, i, j):
				print('Impossible')
				return
	print('Possible')

def __starting_point():
	main()
__starting_point()


import os
import heapq
import sys, threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10 ** 5)
from io import BytesIO, IOBase

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def power(x, p, m):
	res = 1
	while p:
		if p & 1:
			res = res * x % m
		x = x * x % m
		p >>= 1
	return res

def inar():
	return [int(k) for k in input().split()]

def lcm(num1, num2):
	return num1 * num2 // gcd(num1, num2)

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def check(n, m, arr):
	(c1, c2) = (1, 1)
	for i in range(n):
		for j in range(1, m):
			if arr[i][j] > arr[i][j - 1]:
				continue
			else:
				c1 = 0
				break
	for i in range(m):
		for j in range(1, n):
			if arr[j][i] > arr[j - 1][i]:
				continue
			else:
				c2 = 0
				break
	if c1 and c2:
		return True
	else:
		return False

def main():
	(n, m) = inar()
	arr1 = []
	arr2 = []
	for i in range(n):
		take = inar()
		arr1.append(take)
	for i in range(n):
		take = inar()
		arr2.append(take)
	for i in range(n):
		for j in range(m):
			mn = min(arr1[i][j], arr2[i][j])
			mx = max(arr1[i][j], arr2[i][j])
			(arr1[i][j], arr2[i][j]) = (mn, mx)
	if check(n, m, arr1) and check(n, m, arr2):
		print('Possible')
	else:
		print('Impossible')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(n, m) = map(int, input().split())
f = []
for i in range(n):
	f.append(list(map(int, input().split())))
s = []
for i in range(n):
	s.append(list(map(int, input().split())))

def check(a, i, j):
	if i > 0 and j > 0:
		if a[i][j] > a[i - 1][j] and a[i][j] > a[i][j - 1]:
			return True
	elif i == 0 and j > 0:
		if a[i][j] > a[i][j - 1]:
			return True
	elif i > 0 and j == 0:
		if a[i][j] > a[i - 1][j]:
			return True
	else:
		return True
	return False
for i in range(n):
	for j in range(m):
		t = max(f[i][j], s[i][j])
		f[i][j] = min(f[i][j], s[i][j])
		s[i][j] = t
for i in range(n):
	for j in range(m):
		if not check(f, i, j) or not check(s, i, j):
			print('Impossible')
			exit()
print('Possible')


def works(a, b, c, d):
	(a, b) = (min(a, b), max(a, b))
	(c, d) = (min(c, d), max(c, d))
	if a < c and b < d:
		return True
	else:
		return False

def process(A, B):
	n = len(A)
	m = len(A[0])
	for i in range(n):
		for j in range(m):
			x1 = A[i][j]
			y1 = B[i][j]
			if i > 0:
				x2 = A[i - 1][j]
				y2 = B[i - 1][j]
				if not works(x2, y2, x1, y1):
					return 'Impossible'
			if j > 0:
				x2 = A[i][j - 1]
				y2 = B[i][j - 1]
				if not works(x2, y2, x1, y1):
					return 'Impossible'
	return 'Possible'
(n, m) = [int(x) for x in input().split()]
A = []
for i in range(n):
	row = [int(x) for x in input().split()]
	A.append(row)
B = []
for j in range(n):
	row = [int(x) for x in input().split()]
	B.append(row)
print(process(A, B))


import atexit
import io
import sys
_I_B = sys.stdin.read().splitlines()
input = iter(_I_B).__next__
_O_B = io.StringIO()
sys.stdout = _O_B

@atexit.register
def write():
	sys.__stdout__.write(_O_B.getvalue())

def main():
	(n, m) = map(int, input().split())
	m1 = []
	m2 = []
	for _ in range(n):
		m1.append(list(map(int, input().split())))
	for _ in range(n):
		m2.append(list(map(int, input().split())))
	for i in range(n):
		for j in range(m):
			if m1[i][j] < m2[i][j]:
				(m1[i][j], m2[i][j]) = (m2[i][j], m1[i][j])
	for i in range(n):
		for j in range(m):
			if i == 0:
				if j != 0:
					if m1[i][j] <= m1[i][j - 1] or m2[i][j] <= m2[i][j - 1]:
						print('Impossible')
						exit(0)
			elif j == 0:
				if m1[i][j] <= m1[i - 1][j] or m2[i][j] <= m2[i - 1][j]:
					print('Impossible')
					exit(0)
			elif m1[i][j] <= m1[i - 1][j] or m1[i][j] <= m1[i][j - 1] or m2[i][j] <= m2[i - 1][j] or (m2[i][j] <= m2[i][j - 1]):
				print('Impossible')
				exit(0)
	print('Possible')
main()


(n, m) = (int(i) for i in input().split())
L1 = [[int(j) for j in input().split()] for i in range(n)]
L2 = [[int(j) for j in input().split()] for i in range(n)]
for i in range(n):
	for j in range(m):
		if L1[i][j] > L2[i][j]:
			buf = L1[i][j]
			L1[i][j] = L2[i][j]
			L2[i][j] = buf
t = 1
for i in range(n):
	for j in range(m):
		if i > 0:
			if L1[i][j] <= L1[i - 1][j]:
				t = 0
			if L2[i][j] <= L2[i - 1][j]:
				t = 0
		if j > 0:
			if L1[i][j] <= L1[i][j - 1]:
				t = 0
			if L2[i][j] <= L2[i][j - 1]:
				t = 0
if not t:
	print('Impossible')
else:
	print('Possible')


a = [[] for i in range(55)]
b = [[] for i in range(55)]
(n, m) = map(int, input().split())
for i in range(n):
	a[i] = list(map(int, input().split()))
for i in range(n):
	b[i] = list(map(int, input().split()))
flag = 1
for i in range(n):
	for j in range(m):
		if j > 0 and (a[i][j] <= a[i][j - 1] and a[i][j] <= b[i][j - 1] or (b[i][j] <= a[i][j - 1] and b[i][j] <= b[i][j - 1])) or (i > 0 and (a[i][j] <= a[i - 1][j] and a[i][j] <= b[i - 1][j] or (b[i][j] <= a[i - 1][j] and b[i][j] <= b[i - 1][j]))):
			flag = 0
		if j < m - 1 and (a[i][j] >= a[i][j + 1] and a[i][j] >= b[i][j + 1] or (b[i][j] >= a[i][j + 1] and b[i][j] >= b[i][j + 1])) or (i < n - 1 and (a[i][j] >= a[i + 1][j] and a[i][j] >= b[i + 1][j] or (b[i][j] >= a[i + 1][j] and b[i][j] >= b[i + 1][j]))):
			flag = 0
if flag == 0:
	print('Impossible')
else:
	print('Possible')


(n, m) = map(int, input().split())
matrix1 = []
matrix2 = []
for i in range(n):
	matrix1.append([int(z) for z in input().split()])
for i in range(n):
	matrix2.append([int(z) for z in input().split()])
(newmatrix1, newmatrix2) = ([], [])
for i in range(n):
	(r1, r2) = ([], [])
	for j in range(m):
		r1.append(max(matrix1[i][j], matrix2[i][j]))
		r2.append(min(matrix1[i][j], matrix2[i][j]))
	newmatrix1.append(r1)
	newmatrix2.append(r2)
c1 = 0
for i in range(n):
	if newmatrix1[i] == sorted(list(set(newmatrix1[i]))) and newmatrix2[i] == sorted(list(set(newmatrix2[i]))):
		c1 += 1
	c1 -= 1
c2 = 0
for j in range(m):
	col1 = []
	col2 = []
	for i in range(n):
		col1.append(newmatrix1[i][j])
		col2.append(newmatrix2[i][j])
	if col1 == sorted(list(set(col1))) and col2 == sorted(list(set(col2))):
		c2 += 1
	c2 -= 1
if c1 == 0 == c2:
	print('Possible')
else:
	print('Impossible')


import sys

class Main:

	def __init__(self):
		self.buff = None
		self.index = 0

	def next(self):
		if self.buff is None or self.index == len(self.buff):
			self.buff = self.next_line()
			self.index = 0
		val = self.buff[self.index]
		self.index += 1
		return val

	def next_line(self):
		return sys.stdin.readline().split()

	def next_ints(self):
		return [int(x) for x in sys.stdin.readline().split()]

	def next_int(self):
		return int(self.next())

	def solve(self):
		(n, m) = self.next_ints()
		a = [self.next_ints() for _ in range(0, n)]
		b = [self.next_ints() for _ in range(0, n)]
		c = [[min(a[i][j], b[i][j]) for j in range(0, m)] for i in range(0, n)]
		d = [[max(a[i][j], b[i][j]) for j in range(0, m)] for i in range(0, n)]
		for i in range(0, n):
			for j in range(0, m):
				if i > 0 and c[i][j] <= c[i - 1][j]:
					print('Impossible')
					return
				if i > 0 and d[i][j] <= d[i - 1][j]:
					print('Impossible')
					return
				if j > 0 and c[i][j] <= c[i][j - 1]:
					print('Impossible')
					return
				if j > 0 and d[i][j] <= d[i][j - 1]:
					print('Impossible')
					return
		print('Possible')
Main().solve()


def Possible():
	(n, m) = map(int, input().split())
	A = [[int(j) for j in input().split()] for i in range(n)]
	B = [[int(j) for j in input().split()] for i in range(n)]
	for i in range(n):
		for j in range(m):
			if A[i][j] > B[i][j]:
				(A[i][j], B[i][j]) = (B[i][j], A[i][j])
	for i in range(n):
		for j in range(m):
			if j != m - 1:
				if A[i][j] >= A[i][j + 1] or B[i][j] >= B[i][j + 1]:
					return False
			if i != n - 1:
				if A[i][j] >= A[i + 1][j] or B[i][j] >= B[i + 1][j]:
					return False
	return True
print('Possible' if Possible() else 'Impossible')