#include <bits/stdc++.h>

using namespace std;

#define ll int64_t

void solve()
{

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    vector<vector<int>> g(n);
    for (int i = 0; i < n - 1; i++)
    {
        int u, v;

        cin >> u >> v;
        u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for (int i = 0; i < n; i++)
        cin >> a[i];
    vector<vector<vector<int>>> dp(n, vector<vector<int>>(k, vector<int>(2)));
    function<void(int, int, int)> dfs1 = [&](int x, int fa, int dep) {
        dp[x][0][0] = a[x];
        for (int to : g[x])
        {
            if (to == fa)
                continue;
            dfs1(to, x, dep + 1);
            for (int j = 0; j < k; j++)
            {
                for (int t = 0; t < 2; t++)
                {
                    dp[x][(j + 1) % k][t ^ ((j + 1) / k)] ^= dp[to][j][t];
                }
            }
        }
    };
    function<void(int, int, int)> dfs2 = [&](int x, int fa, int dep) {
        for (int to : g[x])
        {
            if (to == fa)
                continue;

            auto tmp = dp[x];
            for (int j = 0; j < k; j++)
            {
                for (int t = 0; t < 2; t++)
                {
                    tmp[(j + 1) % k][t ^ ((j + 1) / k)] ^= dp[to][j][t];
                }
            }
            for (int j = 0; j < k; j++)
            {
                for (int t = 0; t < 2; t++)
                {
                    dp[to][(j + 1) % k][t ^ ((j + 1) / k)] ^= tmp[j][t];
                }
            }
            dfs2(to, x, dep + 1);
        }
    };
    dfs1(0, -1, 0);
    dfs2(0, -1, 0);
    for (int i = 0; i < n; i++)
    {
        int res = 0;
        for (int j = 0; j < k; j++)
            res ^= dp[i][j][1];
        cout << (res == 0 ? 0 : 1) << " ";
    }
    cout << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    // cin >> T;
    while (T--)
    {
        solve();
    }
}