using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;
namespace Program
{
public class Solver
{
///
/// 転倒数の計算をBITでやる乱択
///
public void Solve()
{
var n = sc.Integer();
if (n == 2)
IO.Printer.Out.WriteLine("impossible");
else
{
IO.Printer.Out.WriteLine("possible");
var mat = Enumerate(n, x => sc.Integer(n));
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
if (mat[i][j] == 0) { mat[i][j] = n * n; dist = (n - (i + 1) + n - (j + 1)); }
var p = Check(mat);
var sq = MagicSquare.Create(n);
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
if (sq.mat[i][j] == n * n) { dist = (n - (i + 1) + n - (j + 1)); row = i; break; }
var rand = new Random();
var cnt = 0;
while (Check(sq.mat) != p)
{
var x = rand.Next() % n;
var y = rand.Next() % n;
if (x == row)
{
dist += x;dist -= y;
row = y;
}else if (y == row)
{
dist += y;dist -= x;
row = x;
}
Swap(ref sq.mat[x], ref sq.mat[y]);
cnt++;
}
foreach (var a in sq.mat)
IO.Printer.Out.WriteLine(a.AsJoinedString());
Debug.WriteLine(cnt);
}
}
static int dist;
static int row;
static public int Check(int[][] mat)
{
return MathEx.GetInversion(mat) % 2 == dist % 2 ? 0 : 1;
}
public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());
static T[] Enumerate(int n, Func f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }
static public void Swap(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
}
}
#region main
static class Ex
{
static public string AsString(this IEnumerable ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }
static public string AsJoinedString(this IEnumerable ie, string st = " ") { return string.Join(st, ie); }
static public void Main()
{
var solver = new Program.Solver();
solver.Solve();
Program.IO.Printer.Out.Flush();
}
}
#endregion
#region Ex
namespace Program.IO
{
using System.IO;
using System.Text;
using System.Globalization;
public class Printer : StreamWriter
{
static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
public static Printer Out { get; set; }
public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }
public void Write(string format, T[] source) { base.Write(format, source.OfType