import java.util.*;

public class matmult {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		double[][] mat = new double[n][n];

		for (int i=0; i<n; i++)
			for (int j=0; j<n; j++)
				mat[i][j] = stdin.nextDouble();

		double[][] res = matExpo(mat, 1000000000000L);
		for (int i=0; i<n; i++) {
			for (int j=0; j<n; j++)
				System.out.print(res[i][j]+" ");
			System.out.println();
		}
	}

	public static double[][] matExpo(double[][] m, long exp) {

		if (exp == 0L) return identity(m.length);

		if (exp%2 == 0) {
			double[][] res = matExpo(m, exp/2);
			return mult(res, res);
		}

		return mult(m, matExpo(m, exp-1));
	}

	public static double[][] identity(int n) {
		double[][] mat = new double[n][n];
		for (int i=0; i<n; i++)
			mat[i][i] = 1;
		return mat;
	}

	public static double[][] mult(double[][] a, double[][] b) {
		double[][] c = new double[a.length][a.length];

		for (int i=0; i<a.length; i++)
			for (int j=0; j<a.length; j++)
				for (int k=0; k<a.length; k++)
					c[i][j] += (a[i][k]*b[k][j]);
		return c;
	}
}