#include <bits/stdc++.h>
#define i64 long long
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define per(i, a, b) for (int i = (b) - 1; i >= (a); --i)
using namespace std;

const int N = 1e5, Nk = 20;
int n, k, a[N], d[N];
int f[N][Nk][2], g[N][Nk][2];
bool win[N];
vector<int> G[N];

void Count(int u, int fa = -1) {
	f[u][0][0] ^= a[u];
	for (const int &v : G[u]) {
		if (v == fa) {
			continue;
		}
		d[v] = d[u] + 1, Count(v, u);
		rep(i, 0, k) {
			rep(x, 0, 2) {
				f[u][(i + 1) % k][(i + 1
				 >= k) ^ x] ^= f[v][i][x];
			}
		}
	}
}

void Moveroot(int u, int fa = -1) {
	int F = 0;
	rep(i, 0, k) {
		F ^= g[u][i][1];
	}
	win[u] = F;
	for (const int &v : G[u]) {
		if (v == fa) {
			continue;
		}
		rep(i, 0, k) {
			rep(x, 0, 2) {
				g[v][(i + 1) % k][(i + 1
				 >= k) ^ x] ^= g[u][i][x];
				g[v][i][x] ^= f[v][i][x];
				g[v][(i + 2) % k][((i + 2) / k
				 & 1) ^ x] ^= f[v][i][x];
			}
		}
		Moveroot(v, u);
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n >> k;
	rep(i, 0, n - 1) {
		int u, v;
		cin >> u >> v, --u, --v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	rep(u, 0, n) {
		cin >> a[u];
	}
	Count(0);
	rep(i, 0, k) {
		g[0][i][0] = f[0][i][0];
		g[0][i][1] = f[0][i][1];
	}
	Moveroot(0);
	rep(u, 0, n) {
		cout << win[u] << ' ';
	}
	cout << '\n';
	return 0;
}