#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<cctype>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<queue>
#define fs(i,x,y) for(int i=(x),_=(y);i<=_;++i)
#define fn(i,x,y) for(int i=(x),_=(y);i>=_;--i)
#define tor(i,v,x) for(int i=head[x],v=to[i];i;i=nxt[i],v=to[i])
#define ls(x) ch[x][0]
#define rs(x) ch[x][1]
#define mpi(x,y) make_pair(x,y)
#define pi pair<int,int>
#define DEBUG printf("%s %d\n",__FUNCTION__,__LINE__)
using namespace std;
typedef long long ll;
typedef double db;
template<typename T>
void read(T &x){
	x=0;char ch=getchar();bool f=0;
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	x=f?-x:x;
}

const int N=1e5+7,M=2e5+7,K=22;
int n,k,kk;
int a[N];
int head[N],to[M],nxt[M],tot;
int dp[N][K<<1];
bool ans[N];

void adde(int u,int v){
	to[++tot]=v;nxt[tot]=head[u];head[u]=tot;
}
void df(int u,int fa){
	dp[u][0]=a[u];
	tor(i,v,u){
		if(v^fa){
			df(v,u);
			fs(j,0,kk-1){
				dp[u][(j+1)%kk]^=dp[v][j];
			}
		}
	}
}
void dfs(int u,int fa){
	int tp=0;fs(j,k,kk-1)tp^=dp[u][j];
	if(tp)ans[u]=true;
	tor(i,v,u){
		if(v^fa){
			fs(j,0,kk-1){
				dp[u][(j+1)%kk]^=dp[v][j];
			}
			fs(j,0,kk-1){
				dp[v][(j+1)%kk]^=dp[u][j];
			}
			dfs(v,u);
			fs(j,0,kk-1){
				dp[v][(j+1)%kk]^=dp[u][j];
			}
			fs(j,0,kk-1){
				dp[u][(j+1)%kk]^=dp[v][j];
			}
		}
	}
}
signed main(){
	read(n);read(k);kk=k<<1;
	fs(i,1,n-1){
		int x,y;read(x);read(y);adde(x,y);adde(y,x);
	}fs(i,1,n)read(a[i]);
	df(1,0);dfs(1,0);
	fs(i,1,n)cout<<ans[i]<<' ';
	return 0;
}