// $Id: matrix.csharp,v 1.0 2002/05/09 12:45:00 dada Exp $
// http://dada.perl.it/shootout/

using System;

class App {

    static int SIZE = 30;

    public static int[,] mkmatrix (int rows, int cols) {
        int count = 1;
        int[,] m = new int[rows,cols];
        for (int i=0; i<rows; i++) {
            for (int j=0; j<cols; j++) {
            m[i,j] = count++;
            }
        }
        return(m);
    }

    public static void mmult (int rows, int cols, 
                          int[,] m1, int[,] m2, int[,] m3) {
        for (int i=0; i<rows; i++) {
            for (int j=0; j<cols; j++) {
                int val = 0;
                for (int k=0; k<cols; k++) {
                    val += m1[i,k] * m2[k,j];
                }
                m3[i,j] = val;
            }
        }
    }

    public static int Main(String[] args) {        
        int n;
        int[,] m1 = mkmatrix(SIZE, SIZE);
        int[,] m2 = mkmatrix(SIZE, SIZE);
        int[,] mm = new int[SIZE,SIZE];
        
        n = System.Convert.ToInt32(args[0]);
        if(n < 1) n = 1;
        
        for (int i=0; i<n; i++) {
            mmult(SIZE, SIZE, m1, m2, mm);
        }
        
        Console.WriteLine(
            mm[0,0].ToString() + " " + mm[2,3].ToString() + " " +
            mm[3,2].ToString() + " " + mm[4,4].ToString());
        return(0);
    }
}