#include <bits/stdc++.h>
#define fi first
#define se second
#define gc getchar() //(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define IT iterator
#define V vector
#define TP template <class o>
#define TPP template <typename t1, typename t2>
#define SZ(a) ((int)a.size())
#define all(a) a.begin(), a.end()
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define REP(i, a, b) for (int i = b; i >= a; i--)
#define FOR(i, n) rep(i, 1, n)
#define debug(x) cerr << #x << ' ' << '=' << ' ' << x << endl
using namespace std;
typedef unsigned ui;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;

// char buf[1 << 20],*p1=buf,*p2=buf;
TP void qr(o& x) {
    char c = gc;
    x = 0;
    int f = 1;
    while (!isdigit(c)) {
        if (c == '-')
            f = -1;
        c = gc;
    }
    while (isdigit(c))
        x = x * 10 + c - '0', c = gc;
    x *= f;
}
template <class o, class... O> void qr(o& x, O&... y) {
    qr(x);
    qr(y...);
}
TP void qw(o x) {
    if (x / 10)
        qw(x / 10);
    putchar(x % 10 + '0');
}
TP void pr1(o x) {
    if (x < 0)
        x = -x, putchar('-');
    qw(x);
    putchar(' ');
}
template <class o, class... O> void pr1(o x, O... y) {
    pr1(x);
    pr1(y...);
}
TP void pr2(o x) {
    if (x < 0)
        x = -x, putchar('-');
    qw(x);
    putchar(10);
}
template <class o, class... O> void pr2(o x, O... y) {
    pr2(x);
    pr2(y...);
}

TP void cmax(o& x, o y) {
    if (x < y)
        x = y;
}
TP void cmin(o& x, o y) {
    if (x > y)
        x = y;
}

const int mod = 998244353;
TPP void ad(t1& x, t2 y) {
    x += y;
    if (x >= mod)
        x -= mod;
}
TPP void dl(t1& x, t2 y) {
    x -= y;
    if (x < 0)
        x += mod;
}

const int N = 1e5 + 10, inf = 2e9;
const ll INF = 1e15;
int n, k, t, a[N], dep[N], f[N][44];

V<int> e[N];

// void dfs(int x, int fa) {
//     for (int y : e[x])
//         if (y ^ fa)
//             dep[y] = dep[x] + 1, dfs(y, x);
// }

void dfs(int x, int fa) {
    f[x][0] ^= a[x];
    for (int y : e[x])
        if (y ^ fa) {
            dfs(y, x);
            rep(i, 0, t - 1) f[x][(i + 1) % t] ^= f[y][i];
        }
}

int tmp[44];
void DFS(int x, int fa) {
    for (int y : e[x])
        if (y ^ fa) {
            memcpy(tmp, f[x], sizeof tmp);
            rep(i, 0, t - 1) tmp[(i + 1) % t] ^= f[y][i];
            REP(i, 0, t - 1)
            f[y][(i + 1) % t] ^= tmp[i];
            DFS(y, x);
        }
}

void solve() {
    qr(n, k);
    t = k << 1;
    FOR(i, n - 1) {
        int x, y;
        qr(x, y);
        e[x].pb(y);
        e[y].pb(x);
    }
    FOR(i, n) qr(a[i]);
    // FOR(i, n) {
    //     dep[i] = 0;
    //     dfs(i, 0);
    //     int ans = 0;
    //     FOR(j, n) {
    //         int d = dep[j] / k;
    //         if (d & 1)
    //             ans ^= a[j];
    //     }
    //     pr1(!!ans);
    // }
    dfs(1, 0);
    DFS(1, 0);
    FOR(i, n) {
        int ans = 0;
        rep(j, k, t - 1) ans ^= f[i][j];
        pr1(!!ans);
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
    clock_t start_time = clock();
#endif
    int T = 1;
    // qr(T);
    while (T--)
        solve();
#ifndef ONLINE_JUDGE
    cerr << 1.0 * (clock() - start_time) / CLOCKS_PER_SEC << ' ' << 's' << endl;
#endif
    return 0;
}