矩阵
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#define p 1000000007
#define For(i,a,b) for(register long long i=a;i<=b;i++)
using namespace std;
void in(long long &x)
{
long long y=1;
char c=getchar();x=0;
while(c<'0'||c>'9')
{
if(c=='-')
y=-1;
c=getchar();
}
while(c<='9'&&c>='0')x=x*10+c-'0',c=getchar();
x*=y;
}
void out(long long x)
{
if(x<0)
{
putchar('-');
x=-x;
}
if(x>9)
out(x/10);
putchar(x%10+'0');
}
long long a[110][110];
long long b[110][110];
long long c[110][110];
long long n,k;
int main()
{
in(n),in(k);
For(i,1,n)
For(j,1,n)
in(a[i][j]),b[i][j]=a[i][j];
For(xjb,2,k)
{
For(i,1,n)
For(j,1,n)
For(kk,1,n)
c[i][j]+=a[i][kk]*b[kk][j]%p;
For(i,1,n)
For(j,1,n)
a[i][j]=c[i][j];
For(i,1,n)
For(j,1,n)
c[i][j]=0;
}
For(i,1,n)
{
For(j,1,n)
out(c[i][j]),putchar(' ');
putchar('\n');
}
return 0;
}