#include <bits/stdc++.h>
#define forn(i,s,t) for(register int i=(s);i<=(t);++i)
using namespace std;
typedef long long LL;
const int N = 1e5 + 3, M = 24;
struct List {int dir, nxt;} E[N<<1];
int G[N], cnt;
inline void Add(int u, int v) {
	E[++cnt].dir = v, E[cnt].nxt = G[u], G[u] = cnt;
}
int n, k; LL a[N], F[N][M][2], Ans[N];
void F_dfs(int u, int fa) {
	F[u][0][0] = a[u];
	for(register int i=G[u];i;i=E[i].nxt) {
		int v = E[i].dir;
		if(v == fa) continue ;
		F_dfs(v, u);
		forn(j,0,k - 2) {
			F[u][j + 1][0] ^= F[v][j][0];
			F[u][j + 1][1] ^= F[v][j][1];
		}
		F[u][0][0] ^= F[v][k - 1][1];
		F[u][0][1] ^= F[v][k - 1][0];
	}
}
inline void Opt(int u, int v) {
	forn(j,0,k - 2) {
		F[u][j + 1][0] ^= F[v][j][0];
		F[u][j + 1][1] ^= F[v][j][1];
	}
	F[u][0][0] ^= F[v][k - 1][1];
	F[u][0][1] ^= F[v][k - 1][0];
}
void S_dfs(int u, int fa) {
	(u != 1) && (Opt(u, fa), 0);
	forn(i,0,k - 1) Ans[u] ^= F[u][i][1];
	for(register int i=G[u];i;i=E[i].nxt) {
		int v = E[i].dir;
		if(v == fa) continue ;
		Opt(u, v), S_dfs(v, u);
		Opt(u, v);
	}
	(u != 1) && (Opt(u, fa), 0);
}
int main() {
	scanf("%d%d", &n, &k);
	forn(i,2,n) {
		static int u, v;
		scanf("%d%d", &u, &v);
		Add(u, v), Add(v, u);
	}
	forn(i,1,n) scanf("%lld", a + i);
	F_dfs(1, -1), S_dfs(1, -1);
	forn(i,1,n) printf("%d%c", (!!Ans[i]), " \n"[i == n]);
	return 0;
}// OJ:: LG