#include<bits/stdc++.h>
using namespace std;
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')';}
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) {os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
template<typename T> void dbg_a(const T *a,int l,int r){cerr<<" {";for(int i = l;i<r;i++) cerr<<a[i]<<", ";cerr<<a[r]<<"}"<<endl;}
typedef long long ll;
#define int ll
inline int read(){
    int f(1),r(0);char c(getchar());
    while(c<'0'||c>'9'){if(c == '-') f = -1; c = getchar();}
    while(c>='0'&&c<='9'){ r = (r<<1) + (r<<3) + c - '0';c = getchar();}
    return f*r;
}
void read(int &x){ x = read();}
template<class Head, class... Tail> void read(Head &head, Tail &... tail) { read(head); read(tail...); }
typedef pair<int,int> PII;
#define fi first
#define se second
#define mst(a,b) memset(a,b,sizeof(a))
#define For(i,a,b) for(int i = a;i<=b;i++)
#define For_(i,a,b) for(int i = a;i>=b;i--)
#define _for(i,a) for(int i = 0;i<a;i++)
#define Sum(a,l,r) accumulate(a + l,a + r + 1,0)
#define All(x) x.begin(),x.end()

//    For(i,1,n) For(j,1,m) printf("f[%lld][%lld] = %lld\n",i,j,f[i][j]);
const ll INF = 0x3f3f3f3f3f3f3f3f;
//const int INF = 0x3f3f3f3f;
const int N = 100 + 6,M = N*2 + 6;
const int mod = 1e9+7;
struct Mat{
    int val[105][105]; //自行设置大小
    int height,width;
    void clear(){
        memset(val,0,sizeof(val));
    }
    Mat() {}
    Mat(int height,int width) : height(height),width(width) { //用于初始化
        clear();
    }
    Mat operator *(const Mat &B){ // A * B
        Mat ret(this->height,B.width);
        for(int i = 1;i <= this->height;i++){
            for(int k = 1;k<=this->width;++k){
                if(this->val[i][k] == 0) continue;
                for(int j = 1;j<=B.width;j++){
                    ret.val[i][j] = (ret.val[i][j] + this->val[i][k]*B.val[k][j]%mod)%mod;//注意需不需要取模
                }
            }
        }
        return ret;
    }
    Mat pow(int n){
        Mat ret(this->height,this->width),base = (*this);
        for(int i = 1;i<=height;i++){
            ret.val[i][i] = 1;
        }
        while(n){
            if(n & 1) ret = ret * base;
            base = base * base;
            n >>= 1;
        }
        return ret;
    }
    void resize(int he,int wi){//不太好用
        this->width = wi;
        this->height = he;
    }
    static Mat I(int siz){//单位矩阵I
        Mat ret(siz,siz);
        for(int i = 1;i<=siz;i++){
            ret.val[i][i] = 1;
        }
        return ret;
    }
};
int mpow(int x,int k){
    int res = 1;
    while(k){
        if(k & 1) res = (ll)res * x % mod;
        x = (ll)x * x%mod;
        k >>=1;
    }
    return res;
}
int n,m,k;
PII edge[N*N];
int deg[N];
void solve(){
    read(n,m,k);
    Mat a(n,n),ans(1,n);
    For(i,1,n) ans.val[1][i] = read();
    For(i,1,m){
        int x = read(),y = read();
        edge[i] = {x,y};
        deg[x]++,deg[y]++;
    }
    int inv2m = mpow(2*m,mod-2);
    For(i,1,m){
        auto [x,y] = edge[i];
        a.val[x][y] = inv2m;
        a.val[y][x] = inv2m;
    }
    For(i,1,n){
        a.val[i][i] = (2*m - deg[i])*inv2m%mod;
    }
    a = a.pow(k);
    // For(i,1,n) {cout<<"\n";For(j,1,n) cout<<a.val[i][j]<<" ";}
    // cout<<"\n";
    ans = ans*a;
    For(i,1,n){
        cout<<ans.val[1][i]<<"\n";
    }
}
signed main(){
    int T = 1;
    //T = read();
    while(T--) solve();
    return 0;
}
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front priority_queue


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::vector<ll> vi;
typedef pair<ll, ll> pi;
#define ull unsigned long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define boht_tez ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MAXN ll(1e5 + 123)
#define MAXINP ll (1e3 + 123)
#define MAX_SIZE 100000000
#define    DOD(i)  cout<<setprecision(i)<<fixed<<
#define MOD 1000000007ll
#define pi 3.1415926536

int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.tx
	freopen("input1.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output1.txt", "w", stdout);
#endif
	ll t = 1 ;
	//cin >> t;
	while (t--) {

		ll  x, y;
		cin >> x >> y;
		//cout << x << " " << y;
		if (x == 1 && y == 2 ) {
			cout << 0;
		}
		if (y == 1 && x == 2) {
			cout << 0;
		}
		if (x == 1 && y == 0) {
			cout << 2;
		}
		if (y == 1 && x == 0) {
			cout << 2;
		}
		if ( x == 0 && y == 2 ) {
			cout << 1;
		}
		if (y == 0 && x == 2) {
			cout << 1;
		}
		if (x == y) {
			cout << x;
		}

	}
}