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
{
///
/// 適当な乱択
///
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;
var sq = MagicSquare.Create(n);
var p = Check(mat);
var rand = new Random();
var cnt = 0;
while (Check(sq.mat) != p)
{
var x = rand.Next() % n;
var y = rand.Next() % n;
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 public int Check(int[][] mat)
{
var m = mat.Length;
var inv = 0;
var a = new List();
for (int i = 0; i < m; i++)
for (int j = 0; j < m; j++) a.Add(mat[i][j]);
var dist = 0;
for (int i = 0; i < m; i++)
for (int j = 0; j < m; j++)
if (mat[i][j] == m * m) dist = (m - (i + 1) + m - (j + 1));
for (int i = 0; i < a.Count; i++)
{
for (int j = i + 1; j < a.Count; j++)
if (a[i] > a[j]) inv++;
}
return inv % 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