func_code_string: #include <bits/stdc++.h>   using namespace std;   int N;   int A[20];   void Work1() { printf( %d n%d n , A[0], A[0]); }   void Work2() { printf( %d n%d %d n%d %d n , A[0] * 2, A[0], A[0], A[0], A[0]); }   void Work3() {     int i, i00, i01, i02, i11, i21, i20, i22, i10, i12;     int sum = 0;     for (i = 0; i < 9; ++i) {       sum += A[i];     }     sum /= 3;     for (i00 = 0; i00 < 9; ++i00) {       swap(A[0], A[i00]);       for (i01 = 1; i01 < 9; ++i01) {         swap(A[1], A[i01]);         for (i02 = 2; i02 < 9; ++i02) {           if (A[0] + A[1] + A[i02] != sum) continue;           swap(A[2], A[i02]);           for (i11 = 3; i11 < 9; ++i11) {             swap(A[3], A[i11]);             for (i21 = 4; i21 < 9; ++i21) {               if (A[1] + A[3] + A[i21] != sum) continue;               swap(A[4], A[i21]);               for (i20 = 5; i20 < 9; ++i20) {                 if (A[2] + A[3] + A[i20] != sum) continue;                 swap(A[5], A[i20]);                 for (i22 = 6; i22 < 9; ++i22) {                   if (A[0] + A[3] + A[i22] != sum) continue;                   if (A[5] + A[4] + A[i22] != sum) continue;                   swap(A[6], A[i22]);                   for (i10 = 7; i10 < 9; ++i10) {                     if (A[0] + A[i10] + A[5] != sum) continue;                     swap(A[7], A[i10]);                     for (i12 = 8; i12 < 9; ++i12) {                       if (A[7] + A[3] + A[i12] != sum) continue;                       if (A[2] + A[i12] + A[6] != sum) continue;                       printf( %d n , sum);                       printf( %d %d %d n , A[0], A[1], A[2]);                       printf( %d %d %d n , A[7], A[3], A[8]);                       printf( %d %d %d n , A[5], A[4], A[6]);                       return;                     }                     swap(A[7], A[i10]);                     break;                   }                   swap(A[6], A[i22]);                   break;                 }                 swap(A[5], A[i20]);                 break;               }               swap(A[4], A[i21]);               break;             }             swap(A[3], A[i11]);           }           swap(A[2], A[i02]);           break;         }         swap(A[1], A[i01]);       }       swap(A[0], A[i00]);     }   }   void Work4() {     int j, i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15;     int sum = 0;     for (j = 0; j < 16; ++j) {       sum += A[j];     }     sum /= 4;     for (i0 = 0; i0 < 16; ++i0) {       swap(A[0], A[i0]);       for (i1 = 1; i1 < 16; ++i1) {         swap(A[1], A[i1]);         for (i2 = 2; i2 < 16; ++i2) {           swap(A[2], A[i2]);           for (i3 = 3; i3 < 16; ++i3) {             if (A[0] + A[1] + A[2] + A[i3] != sum) continue;             swap(A[3], A[i3]);             for (i4 = 4; i4 < 16; ++i4) {               swap(A[4], A[i4]);               for (i5 = 5; i5 < 16; ++i5) {                 swap(A[5], A[i5]);                 for (i6 = 6; i6 < 16; ++i6) {                   if (A[0] + A[4] + A[5] + A[i6] != sum) continue;                   swap(A[6], A[i6]);                   for (i7 = 7; i7 < 16; ++i7) {                     swap(A[7], A[i7]);                     for (i8 = 8; i8 < 16; ++i8) {                       if (A[2] + A[7] + A[5] + A[i8] != sum) continue;                       swap(A[8], A[i8]);                       for (i9 = 9; i9 < 16; ++i9) {                         swap(A[9], A[i9]);                         for (i10 = 10; i10 < 16; ++i10) {                           if (A[1] + A[4] + A[9] + A[i10] != sum) continue;                           swap(A[10], A[i10]);                           for (i11 = 11; i11 < 16; ++i11) {                             if (A[3] + A[7] + A[9] + A[i11] != sum) continue;                             swap(A[11], A[i11]);                             for (i12 = 12; i12 < 16; ++i12) {                               swap(A[12], A[i12]);                               for (i13 = 13; i13 < 16; ++i13) {                                 if (A[0] + A[12] + A[i13] + A[11] != sum)                                   continue;                                 swap(A[13], A[i13]);                                 for (i14 = 14; i14 < 16; ++i14) {                                   if (A[12] + A[4] + A[7] + A[14] != sum)                                     continue;                                   swap(A[14], A[i14]);                                   for (i15 = 15; i15 < 16; ++i15) {                                     if (A[3] + A[14] + A[i15] + A[6] != sum)                                       continue;                                     if (A[13] + A[9] + A[5] + A[i15] != sum)                                       continue;                                     printf( %d n , sum);                                     printf( %d %d %d %d n , A[0], A[1], A[2],                                            A[3]);                                     printf( %d %d %d %d n , A[12], A[4], A[7],                                            A[14]);                                     printf( %d %d %d %d n , A[13], A[9], A[5],                                            A[15]);                                     printf( %d %d %d %d n , A[11], A[10], A[8],                                            A[6]);                                     return;                                   }                                   swap(A[14], A[i14]);                                   break;                                 }                                 swap(A[13], A[i13]);                                 break;                               }                               swap(A[12], A[i12]);                             }                             swap(A[11], A[i11]);                             break;                           }                           swap(A[10], A[i10]);                           break;                         }                         swap(A[9], A[i9]);                       }                       swap(A[8], A[i8]);                       break;                     }                     swap(A[7], A[i7]);                   }                   swap(A[6], A[i6]);                   break;                 }                 swap(A[5], A[i5]);               }               swap(A[4], A[i4]);             }             swap(A[3], A[i3]);             break;           }           swap(A[2], A[i2]);         }         swap(A[1], A[i1]);       }       swap(A[0], A[i0]);     }   }   int main() {     int i;     scanf( %d , &N);     for (i = 0; i < N * N; ++i) {       scanf( %d , &A[i]);     }     if (N == 1)       Work1();     else if (N == 2)       Work2();     else if (N == 3)       Work3();     else if (N == 4)       Work4();     return 0;   }   