program matrix;


const
  SIZE = 30;

type TMatrix = array[0..SIZE-1, 0..SIZE-1] of integer;

procedure mkmatrix( rows, cols : integer; var mx : TMatrix);
var 
  R, C, count : integer;
begin
  Dec(rows); Dec(cols);
  count:=1;
  for R:=0 to rows do
    for C:=0 to cols do begin
      mx[R, C] := count;
      Inc(count);
    end;
end;

procedure mmult(rows, cols: integer; const m1, m2: TMatrix; var mm: TMatrix);
var
  i, j, k, val: integer;
begin
  Dec(rows); Dec(cols);
  for i:=0 to rows do
    for j:=0 to cols do begin
      val:=0;
      for k:=0 to cols do
        Inc(val, m1[i,k]*m2[k,j]);
      mm[i,j] := val;
    end;
end;

var NUM, code, i: integer;
    M1, M2, MM: TMatrix;
begin
  NUM:=1;
  if ParamCount=1 then Val(ParamStr(1),NUM,code);

  mkmatrix(SIZE, SIZE, M1);
  mkmatrix(SIZE, SIZE, M2);
  for i:=0 to NUM do
    mmult(size, size, M1, M2, MM);
  WriteLn( MM[0, 0],' ',MM[2, 3],' ',MM[3, 2],' ',MM[4, 4]);
end.