#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 105;
int n, k, a[N][N], c[N][N];
void multiply ()
{
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
for(int k = 1; k <= n; k++)
c[i][j] += a[i][k] * a[k][j];
}
void matrixPower (int power)
{
if(power <= 0)return;
multiply ();
if(power % 2 == 1) multiply ();
matrixPower (power / 2);
matrixPower (power / 2);
}
signed main()
{
cin >> n >> k;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
cin >> a[i][j], c[i][j] = a[i][j];
matrixPower (k - 1);
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= n; j++)
cout << c[i][j] << " ";
cout << "\n";
}
return 0;
}
评测记录T_T