You are given a square grid of size N, with rows numbered from 0 to N - 1 starting from the top and columns numbered from 0 to N - 1 starting from the left.   

A cell (u, v) refers to the cell that is on the u^{th} row and the v^{th} column. Each cell contains an integer - 0 or 1. You can pick any cell and flip the number in all the cells (including the picked cell) within the Manhattan distance D from the picked cell. A flip here means changing the number from 0 to 1 and vice-versa. The manhattan distance from the cell (u, v) to the cell (x, y) is equal to $|u-x|+|v-y|$ where $\left|i\right|$ is the absolute value of i.   

Your mission is to change all values in the grid to zero without using more than N×N flips.

Input Format 

The first line of the input contains two integers N and D  separated by a single space. 

Each line in the next N lines contains N integers separated by a single space which are either 0 or 1. the i_{th} number on the j_{th} line is the number on the cell (i - 1, j - 1) of the grid.

Constraints 

1 ≤  N ≤  20 

 0 ≤ D ≤ 40

Output Format 

If there is no solution, your output should contain exactly a single string "Impossible" (without quotes). If a solution exists, print out the string "Possible" (without quotes) in the first line of your output. In the second line, print out an integer M which represent the number of operations that you need. Each line in the next M lines should contain a pair of integers separated by a single space representing the cell that you picked for the corresponding operation. Note that if there is more than one solution you can pick any one of them.

Sample Input:#00

3 1
0 1 0
1 1 1
0 1 0

Sample Output:#00

Possible
1
1 1

Sample Input:#01

3 2
1 0 1 
1 1 0 
0 0 0 

Sample Output:#01

Impossible

Explanation

In the first testcase, we can perform the first operation in the center cell, this will flip all the elements to 0 within 1 manhattan distance. 

In the second testcase, we cannot make it an all 0 matrix under 9 moves. Hence, Impossible.

Difficulty: MEDIUM_HARD

Solutions:
(N, D) = map(int, input().split())
N2 = N * N
board = 0
for i in range(N):
	row = [int(x) for x in input().split()]
	for j in range(N):
		if row[j]:
			board |= 1 << i * N + j
bits = []
for i in range(N):
	for j in range(N):
		x = 1 << i * N + j + N2
		for m in range(N):
			for n in range(N):
				if abs(i - m) + abs(j - n) <= D:
					x |= 1 << m * N + n
		bits.append(x)
rank = 0
for i in range(N2):
	b = 1 << i
	j = rank
	while j < N2 and bits[j] & b == 0:
		j += 1
	if j >= N2:
		continue
	piv = bits[j]
	if board & b:
		board ^= piv
	if j > rank:
		bits[j] = bits[rank]
		bits[rank] = piv
	rank += 1
	for j in range(rank, N2):
		if bits[j] & b:
			bits[j] ^= piv
if board & (1 << N2) - 1:
	print('Impossible')
else:
	print('Possible')
	flips = []
	for i in range(N2):
		if board & 1 << i + N2:
			flips.append(divmod(i, N))
	print(len(flips))
	for f in flips:
		print(*f)


(N, D) = map(int, input().split())
N2 = N * N
board = 0
for i in range(N):
	row = [int(x) for x in input().split()]
	for j in range(N):
		if row[j]:
			board |= 1 << i * N + j
bits = []
for i in range(N):
	for j in range(N):
		x = 1 << i * N + j + N2
		for m in range(N):
			for n in range(N):
				if abs(i - m) + abs(j - n) <= D:
					x |= 1 << m * N + n
		bits.append(x)
rank = 0
for i in range(N2):
	b = 1 << i
	j = rank
	while j < N2 and bits[j] & b == 0:
		j += 1
	if j >= N2:
		continue
	piv = bits[j]
	if board & b:
		board ^= piv
	if j > rank:
		bits[j] = bits[rank]
		bits[rank] = piv
	rank += 1
	for j in range(rank, N2):
		if bits[j] & b:
			bits[j] ^= piv
if board & (1 << N2) - 1:
	print('Impossible')
else:
	print('Possible')
	flips = []
	for i in range(N2):
		if board & 1 << i + N2:
			flips.append(divmod(i, N))
	print(len(flips))
	for f in flips:
		print(*f)


(n, d) = list(map(int, input().split(' ')))
mat = []
inpmat = []
for i in range(n):
	for j in range(n):
		row = [0] * (n * n)
		inprow = [0] * (n * n)
		inprow[n * i + j] = 1
		for k in range(n):
			for l in range(n):
				if abs(i - k) + abs(j - l) <= d:
					row[n * k + l] = 1
		mat.append(row)
		inpmat.append(inprow)
currrow = 0
pivot = [-1] * (n * n)
for currcol in range(n * n):
	for i in range(currrow, n * n):
		if mat[i][currcol] == 1:
			temp = mat[i]
			mat[i] = mat[currrow]
			mat[currrow] = temp
			temp = inpmat[i]
			inpmat[i] = inpmat[currrow]
			inpmat[currrow] = temp
			pivot[currcol] = currrow
			break
	if pivot[currcol] != -1:
		for i in range(currrow + 1, n * n):
			if mat[i][currcol] == 1:
				for j in range(0, n * n):
					mat[i][j] = mat[i][j] ^ mat[currrow][j]
					inpmat[i][j] = inpmat[i][j] ^ inpmat[currrow][j]
		currrow += 1
	currcol += 1
vec = []
for i in range(n):
	toadd = list(map(int, input().rstrip().split(' ')))
	vec.extend(toadd)
sol = [0] * (n * n)
isimp = False
for currcol in range(n * n):
	if vec[currcol] == 1:
		if pivot[currcol] == -1:
			isimp = True
			break
		else:
			for j in range(n * n):
				vec[j] = vec[j] ^ mat[pivot[currcol]][j]
				sol[j] = sol[j] ^ inpmat[pivot[currcol]][j]
if isimp:
	print('Impossible')
else:
	print('Possible')
	total = sum(sol)
	print(total)
	for i in range(n):
		for j in range(n):
			if sol[n * i + j] == 1:
				print(i, j)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos == 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


(N, D) = map(int, input().split())
N2 = N * N
board = 0
for i in range(N):
	row = [int(x) for x in input().split()]
	for j in range(N):
		if row[j]:
			board |= 1 << i * N + j
bits = []
for i in range(N):
	for j in range(N):
		x = 1 << i * N + j + N2
		for m in range(N):
			for n in range(N):
				if abs(i - m) + abs(j - n) <= D:
					x |= 1 << m * N + n
		bits.append(x)
rank = 0
for i in range(N2):
	b = 1 << i
	j = rank
	while j < N2 and bits[j] & b == 0:
		j += 1
	if j >= N2:
		continue
	piv = bits[j]
	if board & b:
		board ^= piv
	if j > rank:
		bits[j] = bits[rank]
		bits[rank] = piv
	rank += 1
	for j in range(rank, N2):
		if bits[j] & b:
			bits[j] ^= piv
if board & (1 << N2) - 1:
	print('Impossible')
else:
	print('Possible')
	flips = []
	for i in range(N2):
		if board & 1 << i + N2:
			flips.append(divmod(i, N))
	print(len(flips))
	for f in flips:
		print(*f)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


(N, D) = map(int, input().split())
N2 = N * N
board = 0
for i in range(N):
	row = [int(x) for x in input().split()]
	for j in range(N):
		if row[j]:
			board |= 1 << i * N + j
bits = []
for i in range(N):
	for j in range(N):
		x = 1 << i * N + j + N2
		for m in range(N):
			for n in range(N):
				if abs(i - m) + abs(j - n) <= D:
					x |= 1 << m * N + n
		bits.append(x)
rank = 0
for i in range(N2):
	b = 1 << i
	j = rank
	while j < N2 and bits[j] & b == 0:
		j += 1
	if j >= N2:
		continue
	piv = bits[j]
	if board & b:
		board ^= piv
	if j > rank:
		bits[j] = bits[rank]
		bits[rank] = piv
	rank += 1
	for j in range(rank, N2):
		if bits[j] & b:
			bits[j] ^= piv
if board & (1 << N2) - 1:
	print('Impossible')
else:
	print('Possible')
	flips = []
	for i in range(N2):
		if board & 1 << i + N2:
			flips.append(divmod(i, N))
	print(len(flips))
	for f in flips:
		print(*f)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)


read_ints = lambda : list(map(int, input().split()))

def solve(rect, mat_len):
	l = len(rect)
	ret = [0 for i in range(l)]
	pos = 0
	for i in range(l):
		while True:
			find = False
			for j in range(i, l):
				if rect[j][pos] == 1:
					(rect[i], rect[j]) = (rect[j], rect[i])
					find = True
					break
			if find:
				break
			else:
				pos += 1
				if pos == l:
					break
		if pos == l:
			break
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
		pos += 1
		if pos == l:
			break
	rect.reverse()
	for i in range(l):
		pos = -1
		for j in range(l + 1):
			if rect[i][j]:
				pos = j
				break
		if pos == l:
			print('Impossible')
			return
		if pos == -1:
			continue
		ret[pos] = rect[i][l]
		for j in range(i + 1, l):
			if rect[j][pos]:
				for k in range(pos, l + 1):
					rect[j][k] ^= rect[i][k]
	print('Possible')
	print(sum(ret))
	k = 0
	for i in range(mat_len):
		for j in range(mat_len):
			if ret[k]:
				print(i, j)
			k += 1
[r, d] = read_ints()
mat = []
for i in range(r):
	mat.append(read_ints())
rect = []
k = 0
for i in range(r):
	for j in range(r):
		rect.append([])
		for iter_i in range(r):
			for iter_j in range(r):
				if abs(i - iter_i) + abs(j - iter_j) <= d:
					rect[k].append(1)
				else:
					rect[k].append(0)
		if mat[i][j]:
			rect[k].append(1)
		else:
			rect[k].append(0)
		k += 1
solve(rect, r)