#include <bits/stdc++.h>
using namespace std;

#define fr(i,n) for(int i = 0; i<n; i++)
#define sz(v) (int)(v.size())
#define prin(a) cout << #a << " = " << a << endl
#define prinv(v) cout << #v << " = "; for(auto it : v) cout << it << ", "; cout << endl
#define all(v) (v).begin(),(v).end()

typedef long long ll;

#define rmin(a,b) a = min<ll>(a,b)
#define rmax(a,b) a = max<ll>(a,b)

#define fi first
#define se second

const int N = 1e5+10;

int val[N];

vector<int> g[N];
vector<int> dp[N][42];
int dpsub[N][42];
int pai[N], id_do_pai[N], id_q_sou[N];

int n, k, k2;

void dfsp(int no, int from, int id_from){
	pai[no] = from;
	id_q_sou[no] = id_from;
	int ii = -1;
	for(auto &it : g[no]){
		ii++;
		if(it==from){
			id_do_pai[no] = ii;
			continue;
		}
		dfsp(it,no,ii);
	}
}

int rec(int no, int ki, int id_it);

int recsub(int no, int ki){
	int &ans = dpsub[no][ki];
	if(ans!=-1) return ans;
	ans = 0;
	int ii = -1;
	for(auto &it : g[no]){
		ii++;
		if(it==pai[no]) continue;
		ans^=rec(no,ki,ii);
	}
	return ans;
}

int rec(int no, int ki, int id_it){
	int &ans = dp[no][ki][id_it];
	if(ans!=-1) return ans;
	int it = g[no][id_it];
	int pk = (ki+1)%k2;
	ans = recsub(it,pk);
	if(ki>=k-1 and ki<=2*k-2) ans^=val[it];
	if(it==pai[no]){
		ans^=rec(it,pk,id_q_sou[no]);
		if(pai[it]!=-1) ans^=rec(it,pk,id_do_pai[it]);
	}
	return ans;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> k;
	k2 = 2*k;
	fr(i,n-1){
		int a, b; cin >> a >> b; a--,b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	fr(i,n) cin >> val[i];
	fr(i,n) sort(all(g[i]));
	
	dfsp(0,-1,-1);
	
	fr(i,n) fr(j,2*k) dp[i][j].resize(sz(g[i]),-1), dpsub[i][j] = -1;
	
	fr(no,n){
		int cur = 0;
		fr(i,sz(g[no])) cur^=rec(no,0,i);
		if(no) cout << " ";
		if(cur) cout << 1;
		else cout << 0;
	}
	cout << "\n";
}
