#include <bits/stdc++.h>
#define debug(x) cout << #x << ":\t" << (x) << endl;
using namespace std;
#define ll long long
#define ull unsigned ll
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const ll inv2 = (mod + 1) / 2;
int n, k;
vector<int>G[N];
int a[N];
int dp[N][50];
void dfs(int u, int _fa) {
	dp[u][0] = a[u];
	for (int v : G[u]) {
		if (v == _fa)continue;
		dfs(v, u);
		for (int i = 1; i < 2 * k; i++) {
			dp[u][i] ^= dp[v][i - 1];
		}
		dp[u][0] ^= dp[v][2 * k - 1];
	}
}
int ans[N], tmp[N][50];
void dfs2(int u, int _fa) {
	if (u == 1) {
		for (int i = 0; i < 2 * k; i++)tmp[u][i] = dp[u][i];
	}
	else {
		for (int i = 0; i < 2 * k; i++)tmp[u][i] = tmp[_fa][i];
		for (int i = 1; i < 2 * k; i++) {
			tmp[u][i] ^= dp[u][i - 1];
		}
		tmp[u][0] ^= dp[u][2 * k - 1];
		int t = tmp[u][2 * k - 1];
		for (int i = 2 * k - 1; i >= 1; i--) {
			tmp[u][i] = tmp[u][i - 1];
		}
		tmp[u][0] = t;
		for (int i = 0; i < 2 * k; i++) {
			tmp[u][i] ^= dp[u][i];
		}
	}
	for (int i = k; i < 2 * k; i++) {
		ans[u] ^= tmp[u][i];
	}
	for (int v : G[u]) {
		if (v == _fa)continue;
		dfs2(v, u);
	}
}
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i < n; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for (int i = 1; i <= n; i++)scanf("%d", &a[i]);
	dfs(1, 0);
	dfs2(1, 0);
	for (int i = 1; i <= n; i++)printf("%d%c", ans[i] != 0, " \n"[i == n]);
	return 0;
}