// In the name of Allah.
// We're nothing and you're everything.
// Ya Ali!

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int MAX_N = 1e5 + 14, MAX_K = 40;
int n, k;

struct XorKeeper {
    int a[MAX_K]{};

    XorKeeper operator^(const XorKeeper &o) {
        XorKeeper ret;
        for (int i = 0; i < 2 * k; ++i) {
            ret.a[i] = a[i] ^ o.a[i];
        }
        return ret;
    }

    XorKeeper &operator^=(const XorKeeper &o) {
        return *this = *this ^ o;
    }

    XorKeeper next() const {
        XorKeeper ret = *this;
        rotate(ret.a, ret.a + 2 * k - 1, ret.a + 2 * k);
        return ret;
    }

    int get_ans() {
        return accumulate(a + k, a + 2 * k, 0, [](int x, int y) { return x ^ y; });
    }
} down[MAX_N], up[MAX_N];

vector<int> g[MAX_N];
int a[MAX_N];

void dfs_down(int v = 0, int p = -1) {
    down[v].a[0] = a[v];
    for (auto u : g[v])
        if (u != p) {
            dfs_down(u, v);
            down[v] ^= down[u].next();
        }
}

void dfs_up(int v = 0, int p = -1) {
    for (auto u : g[v])
        if (u != p) {
            up[u] = (up[v] ^ down[v] ^ down[u].next()).next();
            dfs_up(u, v);
        }
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n - 1; ++i) {
        int v, u;
        cin >> v >> u;
        v--, u--;
        g[v].push_back(u);
        g[u].push_back(v);
    }
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    dfs_down();
    dfs_up();
    for (int i = 0; i < n; ++i) {
        cout << bool(down[i].get_ans() ^ up[i].get_ans()) << ' ';
    }
    cout << '\n';
}