#include <iostream>
#include <vector>
using namespace std;

const int MAX_N = 1E5 + 100;
const int MAX_K = 20 + 7;

int n, k;
vector<int> G[MAX_N];
int a[MAX_N];
int w[MAX_N][MAX_K << 1];
int ans[MAX_N];

void dfs1(int u, int fat) {
    w[u][0] ^= a[u];
    for (int v : G[u]) {
        if (fat == v)
            continue;

        dfs1(v, u);
        for (int i = 1; i < 2 * k; ++i) {
            w[u][i] ^= w[v][i - 1];
        }
        w[u][0] ^= w[v][2 * k - 1];
    }
}

int tmpw[MAX_K << 1];
void dfs2(int u, int fat) {
    if (0 != fat) {
        for (int i = 1; i < 2 * k; ++i) {
            tmpw[i] = w[fat][i] ^ w[u][i - 1];
        }
        tmpw[0] = w[fat][0] ^ w[u][2 * k - 1];
        for (int i = 1; i < 2 * k; ++i) {
            w[u][i] ^= tmpw[i - 1];
        }
        w[u][0] ^= tmpw[2 * k - 1];
    }

    for (int i = k; i < 2 * k; ++i) {
        ans[u] ^= w[u][i];
    }
    for (int v : G[u]) {
        if (fat == v)
            continue;

        dfs2(v, u);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> k;
    for (int i = 1; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    //init

    dfs1(1, 0);
    dfs2(1, 0);
    for (int i = 1; i <= n; ++i) {
        if (ans[i])
            cout << "1 ";
        else
            cout << "0 ";
    }
    cout << endl;

    return 0;
}
