#include <bits/stdc++.h>

#define FOR(i, b, e) for (int i = (b); i <= (e); i++)
#define FORD(i, b, e) for (int i = (e); i >= (b); i--)
#define MP make_pair
#define FS first
#define ND second
#define PB push_back
#define ALL(x) x.begin(), x.end()

using namespace std;

using LL = long long;
using LD = long double;
using PII = pair<int,int>;
using PLL = pair<LL,LL>;
using PLD = pair<LD,LD>;
using VI = vector<int>;
using VLL = vector<LL>;
using VLD = vector<LD>;
using VS = vector<string>;
template<class T>
using V = vector<T>;
template<class T1, class T2>
using P = pair<T1,T2>;

template<class T>
int sz(const T& a) { return (int)a.size(); }
template<class T>
void amin(T& a, T b) { a = min(a, b); }
template<class T>
void amax(T& a, T b) { a = max(a, b); }

const int inf = 1e9 + 1;
const LL infl = 1e18 + 1;

const int N = 1e5;
const int K = 20;

int n, k, a[N + 1], ans[N + 1], dp[N + 1][2 * K],
    up[N + 1][2 * K], sum[N + 1][2 * K];
VI g[N + 1];

void dfs1(int u, int p)
{
  FOR(i, 0, 2 * k - 1) dp[u][i] = (i >= k) * a[u];

  for (int v : g[u]) if (v != p) {
    dfs1(v, u);
    FOR(i, 0, 2 * k - 1) dp[u][i] ^= dp[v][(i + 1) % (2 * k)];
  }
}

void dfs2(int u, int p)
{
  ans[u] = up[u][1];

  FOR(i, 0, 2 * k - 1) {
    sum[u][i] = ((i >= k) * a[u]) ^ up[u][(i + 1) % (2 * k)];
  }

  for (int v : g[u]) if (v != p) {
    ans[u] ^= dp[v][1];
    FOR(i, 0, 2 * k - 1) sum[u][i] ^= dp[v][(i + 1) % (2 * k)];
  }

  for (int v : g[u]) if (v != p) {
    FOR(i, 0, 2 * k - 1) up[v][i] = sum[u][i] ^ dp[v][(i + 1) % (2 * k)];
    dfs2(v, u);
  }
}

int main()
{
  scanf("%d %d", &n, &k);

  FOR(i, 1, n - 1) {
    int x, y;
    scanf("%d %d", &x, &y);
    g[x].PB(y);
    g[y].PB(x);
  }

  FOR(i, 1, n) scanf("%d", &a[i]);

  dfs1(1, -1);
  dfs2(1, -1);

  FOR(i, 1, n) printf("%d ", ans[i] != 0);
  putchar('\n');
}

