#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

typedef long long ll;
using std::swap;
using std::reverse;
using std::priority_queue;
using std::nth_element;
using std::next_permutation;
using std::upper_bound;
using std::lower_bound;
using std::unique;
using std::sort;
using std::max;
using std::min;
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::bitset;
using std::set;
using std::map;
using std::vector;
using std::queue;
using std::stack;
using std::pair;
using std::make_pair;
using std::complex;
using std::deque;
using std::list;

ll read() {
	register ll x = 0, f = 0, ch = getchar();
	for (; !isdigit(ch); f = (ch == 45), ch = getchar()) ;
	for (; isdigit(ch); x = x * 10 + ch - 48, ch = getchar()) ;
	return f ? -x : x;
}

void write(int x) {
	if (x < 0) putchar(45), x = -x;
	static int sta[35];
	int top = 0;
	do {
		sta[top++] = x % 10, x /= 10;
	} while (x);
	while (top) putchar(sta[--top] + 48);
}

const int maxn = 2e5 + 9, maxm = 2e5 + 9, inf = 0x3f3f3f3f;

ll t, n, m;
ll a[maxn], b[maxn], res;

std::pair<ll, int> c[maxn];

ll myabs(ll x) { return x > 0 ? x : -x; }

int main() {
	// freopen(".in", "r", stdin);
	// freopen(".out", "w", stdout);
	t = read(), n = read(), m = read();
	for (int i = 1; i <= t; ++i)
		a[i] = read(), b[i] = a[i] * m / n, res += b[i],
		c[i] = std::make_pair(myabs(a[i] * m - (b[i] + 1) * n) - myabs(a[i] * m - b[i] * n), i);
	res = m - res;
	std::sort(c + 1, c + t + 1);
	for (int i = 1; res && i <= n; ++i) b[c[i].second]++, res--;
	for (int i = 1; i <= t; ++i) printf("%lld ", b[i]);
	puts("");
	return 0;
}
#include<bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


#define pb push_back
#define fi first
#define se second
#define ll long long
#define tp top()
#define fr front()
#define vi vector<int>
#define sz size()
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define mem(a,  b) memset(a,  (b),  sizeof(a))
#define clr(a) memset(a,  0,  sizeof(a))
#define sqr(x) ( (x) * (x) )
#define all(v) v.begin(),  v.end()

typedef pair<int, int> pii;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;



void base(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}


#define N 100020
vector<int> adj[N];
int a[100020];
int par[100020];

vector<int> ans;

void dfs(int cur, int pa){
	if (par[a[cur]] == -1) {
		par[a[cur]] = cur;
		ans.pb(cur);
	}
	
	for(int to : adj[cur]){
		if (pa == to) continue;
		dfs(to,cur);
	}
	
	if (par[a[cur]] == cur) {
		par[a[cur]] = -1;
	}
}


void solve(){
	mem(par,-1);
	int n; cin>>n;
	rep(i,1,n+1) cin>>a[i];
	rep(i,0,n-1){
		int u,v; cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	dfs(1,1);
	sort(all(ans));
	for(int x : ans) cout<<x<<"\n";
	
}

int main()
{
	base();
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}




