You are given *n* numbers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub>. You can perform at most *k* operations. For each operation you can multiply one of the numbers by *x*. We want to make <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/1faa5be276f646dfb07d2a01bf67449ad72c0ef7.png" style="max-width: 100.0%;max-height: 100.0%;"/> as large as possible, where <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/ddbf6923ea3f08cb83b08ed026f40a80751dff3f.png" style="max-width: 100.0%;max-height: 100.0%;"/> denotes the bitwise OR. 

Find the maximum possible value of <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/1faa5be276f646dfb07d2a01bf67449ad72c0ef7.png" style="max-width: 100.0%;max-height: 100.0%;"/> after performing at most *k* operations optimally.
The first line contains three integers *n*, *k* and *x* (1 ≤ *n* ≤ 200 000, 1 ≤ *k* ≤ 10, 2 ≤ *x* ≤ 8).

The second line contains *n* integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (0 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>).
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F(i, j, k) for(register ll i = j; i <= k; ++i)
#define D(i, j, k) for(register ll i = j; i >= k; --i)
#define random(x) (rand() % (x)) + 1
#define pb push_back
#define fi first
#define se second
#define pp pair<ll, ll>
#define mp make_pair
#define error(x) cerr << #x << "=" << x << endl
//***********var defination*********
const ll maxn = 2e5+5;
ll n, m, x, y, z;
ll a[maxn], can[maxn], vis[maxn];
vector<ll> to[maxn];
//**********Code by Gengchen********
//WA RE TLE MLE 10 pts
//Always look up the code afeter programming
//Keep Calm
//by GengChen================
ll bfs(ll x = 0) {
    queue<ll> q;
    if(x != 1) q.push(1);
    memset(vis, 0, sizeof(vis));
    while(!q.empty()) {
	ll u = q.front();
	q.pop();
	vis[u] = 1;
	for(auto v:to[u]) if(!vis[v] && v != x) {
	    q.push(v);
	}
    }
    ll ret = 0;
    F(i, 1, n) if(vis[i] != can[i]) ret += a[i];
    return ret - a[x];
}
int main() {
#ifdef orz
    freopen("input", "r", stdin);
#endif
    cin >> n >> m;
    F(i, 1, n) cin >> a[i];
    F(i, 1, m) {
	cin >> x >> y;
	to[x].pb(y);
    }
    bfs();
    memcpy(can, vis, sizeof(vis));
    F(i, 1, n) {
	cout << bfs(i) << endl;
    }
    return 0;
}

