#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

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

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
ll powmod(ll a,ll b) {ll res=1; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a;a=a*a;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int n,k,u,v;
vector<vi> g,d;
vi a;

void dfs(int v,int p,int depth) {
    d[v][k] = a[v];
    trav(u,g[v])
        if(u!=p) {
            dfs(u,v,depth+1);
            F0R(i,2*k) d[v][(i+1)%(2*k)] ^= d[u][i];
        }
}

void Dfs(int v,int p) {
    if(v!=p) {
        vi N(2*k);
        F0R(i,2*k) N[(i+2)%(2*k)] ^= d[v][i]^d[v][(i+2)%(2*k)];
        F0R(i,2*k) d[v][(i+1)%(2*k)] = d[p][i]^N[(i+1)%(2*k)];
    }
    trav(u,g[v]) if(u!=p) Dfs(u,v);
}

void solve() {
    cin >> n >> k; 
    g.resize(n); a.resize(n); d.resize(n); 
    for(int i=1;i<n;++i) {
        cin >> u >> v; --u;--v;
        g[u].pb(v); g[v].pb(u);
    }
    for(int i=0;i<n;++i) {
        cin >> a[i];
        d[i].resize(2*k);
    }
    dfs(0,0,0);
    Dfs(0,0);
    F0R(i,n) {
        int ans = 0;
        F0R(j,k)  ans^=d[i][j];
        if(ans)ans=1;
        cout<<ans<<" \n"[i==n-1];
    }
}


int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); 
    solve();
    return 0;
}