#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

string to_string(const string& str) {
  return str;
}

template<typename T>
string to_string(const set<T>& mys) {
  if(mys.empty()) return "{}";
  string ret = "{";
  for(auto el: mys) ret += to_string(el) + ", ";
  ret.pop_back(), ret.pop_back(); // Remove last space and comma
  ret += "}";
  return ret;
}

template<typename T>
string to_string(const pair<T, T>& pr) {
  return "(" + to_string(pr.fi) + "," + to_string(pr.se) + ")";
}

template<typename T>
string to_string(const vector<T>& vc, int w) {
  if(vc.empty()) return "";
  if(w + 1 == vc.size()) return to_string(vc[w]);
  return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
  return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 43;

int n, k, dp[maxN][bs], tmp[bs];
vector<int> adj[maxN];

void apply(int* toad, int* used) {
  for(int i = 0; i < k; i++)
    toad[(i + 1) % k] ^= used[i];
}

void botUp(int nd, int an) {
  for(auto sn: adj[nd]) {
    if(sn == an) continue;
    botUp(sn, nd);
    apply(dp[nd], dp[sn]);
  }
}

void topDown(int nd, int an) {
  for(auto sn: adj[nd]) {
    if(sn == an) continue;
    memcpy(tmp, dp[sn], sizeof tmp);
    apply(dp[nd], tmp);
    apply(dp[sn], dp[nd]);
    apply(dp[nd], tmp);
    topDown(sn, nd);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  #ifdef DEBUG
  freopen("input.txt", "r", stdin);
  #endif

  cin >> n >> k;
  k *= 2;
  for(int i = 1, u, v; i < n; i++) {
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for(int i = 0; i < n; i++) cin >> dp[i][0];
  botUp(0, -1);
  topDown(0, -1);
  for(int i = 0; i < n; i++) {
    int rsp = 0;
    for(int j = k / 2; j < k; j++) rsp ^= dp[i][j];
    cout << (rsp? 1: 0) << ' '; 
  }
  cout << '\n';
}

