#include <bits/stdc++.h>
#define pi pair<int, int>
#define pb push_back
#define l first
#define r second

using namespace std;

const int maxn = 1e5 + 1;

int n, k, t;
vector<int> g[maxn];
int d[maxn], a[maxn], p[maxn];
int cnt[maxn][40], fuck[maxn][40];

void calc(int x, int p = -1) {
    fuck[x][0] = a[x];
    for (auto to : g[x]) {
        if (to == p)
            continue;
        calc(to, x);
        fuck[x][0] ^= fuck[to][t - 1];
        for (int i = 0; i < t - 1; i++)
            fuck[x][i + 1] ^= fuck[to][i];
    }
}

void dfs(int x, int pr = -1) {
    p[x] = pr;
    if (pr != -1) {
        cnt[x][0] ^= cnt[pr][t - 1];
        for (int i = 0; i < t - 1; i++)
            cnt[x][i + 1] ^= cnt[pr][i];
        for (int i = 0; i < t; i++)
            cnt[x][(i + 2) % t] ^= fuck[pr][(i + 1) % t] ^ fuck[x][i];
    }
    for (auto to : g[x])
        if (to != pr)
            dfs(to, x);
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> k;
    t = 2 * k;
    for (int i = 0; i < n - 1; i++) {
        int u, v; cin >> u >> v;
        --u; --v; g[u].pb(v); g[v].pb(u);
    }
    for (int i = 0; i < n; i++)
        cin >> a[i];
    calc(0);
    dfs(0);
    for (int i = 0; i < n; i++) {
        uint32_t ans = 0;
        for (int j = k; j < t; j++)
            ans ^= (cnt[i][j] ^ fuck[i][j]);
        cout << (ans > 0) << ' ';
    }
    return 0;
}
