#include <bits/stdc++.h>
using namespace std;
vector <vector <int>> mat;
vector <int> root;
long long int MOD = 998244353;
int find( int a )
{
    while( root[a] != a )
        a = root[a];
    return root[a];
} 
void unio( int a, int b )
{
    int x = find(a);
    int y = find(b);
    root[x] = y;
}

int main()
{
    long long int n, k = 0, ans = 1;
    cin>>n>>k;
    for( int i = 0; i < n; i++ )
    {
        vector <int> temp (n);
        for( int j = 0; j < n; j++ )
            cin>>temp[j];
        mat.push_back(temp);
    }

    root.resize(2*n);
    for( int i = 0; i < n; i++ )
    {
        root[i] = i;
        root[i+n] = i+n;
    } 

    for( int i = 0; i < n - 1; i++ )
    {
        for( int j = i + 1; j < n; j++ )
        {
            bool flag = false;
            for( int idx = 0; idx < n; idx++ )
                if( mat[i][idx] + mat[j][idx] > k )
                    flag = true;
            
            if( !flag )
                unio(i,j);
        }
    }

    for( int i = 0; i < n - 1; i++ )
    {
        for( int j = i + 1; j < n; j++ )
        {
            bool flag = false;
            for( int idx = 0; idx < n; idx++ )
                if( mat[idx][i] + mat[idx][j] > k )
                    flag = true;
            
            if( !flag )
                unio(i+n,j+n);
        }
    }

    unordered_map <int, int> hash;
    for( int i = 0; i <2*n; i++ )
        hash[find(i)]++;

    vector <long long int> fact (55, 1);
    for( int i = 2; i < 55; i++ )
        fact[i] = ( fact[i-1]*i )%MOD;

    for( auto it: hash )
        ans = ( (ans*fact[it.second])%MOD);
    cout<<ans%MOD<<endl;
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

const ll mo=1000000007;
const int MAT=101;
struct Mat { ll v[MAT][MAT]; Mat(){ZERO(v);};};

ll modpow(ll a, ll n = mo-2) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}


Mat mulmat(Mat& a,Mat& b,int n=MAT) {
	ll mo2=4*mo*mo;
	int x,y,z; Mat r;
	FOR(x,n) FOR(y,n) r.v[x][y]=0;
	FOR(x,n) FOR(z,n) FOR(y,n) {
		r.v[x][y] += a.v[x][z]*b.v[z][y];
		if(r.v[x][y]>mo2) r.v[x][y] -= mo2;
	}
	FOR(x,n) FOR(y,n) r.v[x][y]%=mo;
	return r;
}

Mat powmat(ll p,Mat a,int n=MAT) {
	int i,x,y; Mat r;
	FOR(x,n) FOR(y,n) r.v[x][y]=0;
	FOR(i,n) r.v[i][i]=1;
	while(p) {
		if(p%2) r=mulmat(r,a,n);
		a=mulmat(a,a,n);
		p>>=1;
	}
	return r;
}

int N,M,K;
int A[101];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>K;
	Mat X;
	FOR(i,N) {
		X.v[i][i]=1;
		cin>>A[i];
	}
	FOR(i,M) {
		cin>>x>>y;
		x--,y--;
		(X.v[x][x]+=mo-modpow(2*M))%=mo;
		(X.v[y][y]+=mo-modpow(2*M))%=mo;
		(X.v[x][y]+=modpow(2*M))%=mo;
		(X.v[y][x]+=modpow(2*M))%=mo;
	}
	X=powmat(K,X,N);
	
	ll R[101]={};
	FOR(y,N) FOR(x,N) (R[y]+=A[x]*X.v[y][x])%=mo;
	FOR(i,N) cout<<R[i]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
