#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

template <typename T>
inline T read() {
  T x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + (c & 15), c = getchar();
  return x * f;
}

constexpr int N = 100000 + 5;
constexpr int K = 20 + 5;

using VI = vector<int>;
using VVI = vector<vector<int> >;

VVI dp(N, VI(K << 1));
VI a(N);
vector<bool> win(N);
int n, k, k2;

void dfs(VVI &adj, int node, int prev) {
  dp[node][0] = a[node];
  for (auto neigh : adj[node]) {
    if (neigh == prev) continue;
    dfs(adj, neigh, node);

    for (int rem = 1; rem < k2; ++rem) dp[node][rem] ^= dp[neigh][rem - 1];
    dp[node][0] ^= dp[neigh][k2 - 1];
  }
}

void dfs2(const VVI &adj, const int node, const int prev, const VI &my_xors) {
  VI final_xors(k2);
  for (int i = 0; i < k2; ++i) final_xors[i] = my_xors[i] ^ dp[node][i];
  int odd_layer_xor = 0;
  for (int i = k; i < k2; ++i) odd_layer_xor ^= final_xors[i];
  win[node] = odd_layer_xor > 0;
  for (auto neigh : adj[node]) {
    if (neigh == prev) continue;
    auto xor_send = final_xors;

    for (int i = 1; i < k2; ++i) xor_send[i] ^= dp[neigh][i - 1];

    xor_send[0] ^= dp[neigh][k2 - 1];

    int last = xor_send.back();
    for (int i = k2 - 1; i > 0; i--) xor_send[i] = xor_send[i - 1];

    xor_send[0] = last;
    dfs2(adj, neigh, node, xor_send);
  }
}

int main() {
  n = read<int>(), k = read<int>();
  k2 = k << 1;
  VVI adj(n + 1);
  for (int i = 1; i < n; ++i) {
    int x = read<int>(), y = read<int>();
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  for (int i = 1; i <= n; ++i) a[i] = read<int>();
  dfs(adj, 1, 0);
  dfs2(adj, 1, 0, VI(k2));

  for (int i = 1; i <= n; ++i)
    printf("%d%c", win[i] ? 1 : 0, i == n ? '\n' : ' ');
  return 0;
}