#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#define jie 1000000007
using namespace std;
//n<=100, k<=10^12, |矩陣元素|<=1000
//////////////////////////
long long n,k;
int ans[1010];
int f[110][110];
//////////////////////////
int qpow(int a,long long b)
{
int r=1,base=a;
while(b!=0)
{
if(b%2)
r=(r*base)%jie;
base=(base*base)%jie;
b/=2;
}
return r%jie;
}
//////////////////////////
int main()
{
freopen("qpow.in","r",stdin);
cin>>n>>k;
memset(ans,-1,sizeof(ans));
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
{
scanf("%d",&f[i][j]);
if(ans[f[i][j]]!=-1)
f[i][j]=ans[f[i][j]];
else
{
ans[f[i][j]]=qpow(f[i][j],k);
f[i][j]=ans[f[i][j]];
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
cout<<f[i][j]<<' ';
cout<<endl;
}
}
本作品採用《CC 協議》,轉載必須註明作者和本文連結