/*
                                                  
  _|_|                              _|  _|    _|  
_|    _|  _|  _|_|  _|_|_|_|        _|  _|  _|    
_|    _|  _|_|          _|          _|  _|_|      
_|    _|  _|          _|      _|    _|  _|  _|    
  _|_|    _|        _|_|_|_|    _|_|    _|    _|  
                                                                                                    
*/ 
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
//#define ls (rt<<1)
//#define rs (rt<<1|1)
#define vi vector<int>
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++)
#define fi first
#define se second
typedef long long ll;
using namespace std;
const int maxn=1e5+1000;
int dp[maxn][40];
int a[maxn];
int now[40],trans[40],tmp[maxn];//now[i]��������(���%2*k)=i�ĵ��xor�� 
int n,k;
int ans[maxn];
int JK[maxn][40];
vi side[maxn];
void dfs1(int u,int fa){
	dp[u][0]=a[u];
	rep(i,0,side[u].size()-1){
		int v=side[u][i];if(v==fa)continue;
		dfs1(v,u);
		rep(i,0,2*k-1){
			int nxt=(i+1)%(2*k);
			dp[u][nxt]^=dp[v][i];
		}
	}
}
void dfs2(int u,int fa){
	int tot=0;
	rep(i,k,2*k-1)tot^=now[i];
	if(tot)ans[u]=1;
	
	rep(i,0,side[u].size()-1){
		int v=side[u][i];if(v==fa)continue;
		rep(j,0,2*k-1)trans[j]=now[j];//memcpy(trans,now,sizeof(trans));
		rep(j,0,2*k-1){//��ȥv��Ӱ�� 
			int nxt=(j+1)%(2*k);
			trans[nxt]^=dp[v][j];
		}
		rep(j,0,2*k-1)tmp[j]=0;//memset(tmp,0,sizeof(tmp));
		rep(j,0,2*k-1){//ʣ�µ�����1�ľ��� 
			int nxt=(j+1)%(2*k);
			tmp[nxt]^=trans[j];
		}
		rep(j,0,2*k-1){//����v��Ӱ�� 
			tmp[j]^=dp[v][j];
		}
		
		rep(j,0,2*k-1)JK[u][j]=now[j];//memcpy(JK[u],now,sizeof(JK[u]));//����now
		rep(j,0,2*k-1)now[j]=tmp[j];//memcpy(now,tmp,sizeof(tmp));
		dfs2(v,u);
		rep(j,0,2*k-1)now[j]=JK[u][j];//memcpy(now,JK[u],sizeof(JK[u])); 
	}
}
//int ans[maxn];
int main(){
	ios::sync_with_stdio(0);cin>>n>>k;
	rep(i,1,n-1){
		int u,v;cin>>u>>v;
		side[u].pb(v);side[v].pb(u);
	}
	rep(i,1,n)cin>>a[i];
	dfs1(1,0);memcpy(now,dp[1],sizeof(now));
	dfs2(1,0);
	rep(i,1,n)cout<<ans[i]<<' ';
	return 0;
}
