#include<bits/stdc++.h>
#define maxN 100005
#define P 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;
vector<int> e[maxN];
int n,k;
ll a[maxN];
vector<vector<ll>> dp;
void dfs1(int u,int p)
{
    dp[u][0]=a[u];
    for(auto v:e[u]){
        if(v==p) continue;
        dfs1(v,u);
        for(int i=1;i<k*2;++i) dp[u][i]^=dp[v][i-1];
        dp[u][0]^=dp[v][2*k-1];
    }
}
bool win[maxN];
void dfs2(int u,int p,vector<ll> &f)
{
    vector<ll> final_xor(2*k+5);
    for(int i=0;i<2*k;++i){
        final_xor[i]=dp[u][i]^f[i];
    }
    ll tmp=0;
    for(int i=k;i<2*k;++i) tmp^=final_xor[i];
    win[u]=tmp>0;
    for(auto v:e[u]){
        if(v==p) continue;
        vector<ll> sd=final_xor;
        for(int i=1;i<2*k;++i) sd[i]^=dp[v][i-1];
        sd[0]^=dp[v][2*k-1];
        auto bk=sd[2*k-1];
        for(int i=2*k-1;i>=0;--i) sd[i]=sd[i-1];
        sd[0]=bk;
        dfs2(v,u,sd);
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>k;
    for(int i=0;i<n-1;++i){
        int u,v;cin>>u>>v;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    for(int i=1;i<=n;++i) cin>>a[i];
    dp=vector<vector<ll>>(n+5,vector<ll>(k*2+5));
    dfs1(1,0);
    vector<ll> t(k*2+5);
    dfs2(1,0,t);
    for(int i=1;i<=n;++i) cout<<win[i]<<" \n"[i==n];
}