import java.util.Scanner;

/**
 * Created by szewczm1 on 9/16/2015.
 */
public class Solution {
    public static void main(String[] param) {
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        if (N < 0) {
            System.out.print("ERROR");
            return;
        }
        // eat white spaces
        s.nextLine();
        int[][] tab = new int[N][];
        for (int i = 0; i < N; i++) {
            if (s.hasNextLine()) {
                final String l = s.nextLine();
                String[] ints = l.split("\\s+");
                tab[i] = new int[ints.length];
                for (int j = 0; j < ints.length; j++) {
                    tab[i][j] = Integer.parseInt(ints[j]);
                }
            } else {
                System.out.print("ERROR");
                return;
            }
        }
        if (!validDimension(tab)) {
            System.out.print("ERROR");
            return;
        }

        for (int i = 0; i < tab.length / 2; i++) {
            rotateCircle(tab, i);
        }

        printTab(tab);
    }

    private static void rotateCircle(final int[][] tab, final int i) {
        int n = tab.length - 1;

        int topRight = tab[i][n - i];
        // top
        for (int a = 0; a + i < n - i; a++) {
            tab[i][n - a - i] = tab[i][n - a - i - 1];
        }
        // left
        for (int a = 0; a + i < n - i; a++) {
            tab[i + a][i] = tab[i + a + 1][i];
        }
        // bottom
        for (int a = 0; a + i < n - i; a++) {
            tab[n - i][i + a] = tab[n - i][i + a + 1];
        }
        // right
        for (int a = 0; a + i < n - i; a++) {
            tab[n - i - a][n - i] = tab[n - i - a - 1][n - i];
        }

        tab[i + 1][n - i] = topRight;
    }

    private static void printTab(final int[][] tab) {
        for (int i = 0; i < tab.length; i++) {
            for (int j = 0; j < tab.length; j++) {
                System.out.printf("%d", tab[i][j]);
                if (tab.length - 1 != j) {
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
        System.out.println();
    }

    private static boolean validDimension(final int[][] tab) {
        if (tab == null || tab[0] == null || tab.length != tab[0].length) {
            return false;
        }
        for (final int[] aTab : tab) {
            if (aTab.length != tab[0].length) {
                return false;
            }
        }
        return true;
    }
}

@@ -223,16 +223,17 @@
  if (N %3C
+=
  0) %7B%0A  
@@ -250,32 +250,34 @@
 System.out.print
+ln
 (%22ERROR%22);%0A     
@@ -781,32 +781,34 @@
 System.out.print
+ln
 (%22ERROR%22);%0A     
@@ -914,16 +914,18 @@
 ut.print
+ln
 (%22ERROR%22
@@ -2270,24 +2270,43 @@
 b == null %7C%7C
+ tab.length == 0 %7C%7C
  tab%5B0%5D == n

Update Solution.java