#include <bits/stdc++.h>
using namespace std;
int n, cent, ans[400003], subsz[400003];
vector<int> graph[400003];
int dfs(int node, int p) {
  int sum = 1, m = 0;
  for (auto &nxt : graph[node]) {
    if (nxt == p) continue;
    int subsz = dfs(nxt, node);
    sum += subsz;
    m = max(m, subsz);
  }
  if (2 * sum > n && 2 * m <= n) cent = node;
  return sum;
}
int dfs2(int node, int p) {
  subsz[node] = 1;
  for (auto &nxt : graph[node]) {
    if (nxt == p) continue;
    subsz[node] += dfs2(nxt, node);
  }
  return subsz[node];
}
void dfs3(int node, int p) {
  ans[node] = 1;
  for (auto &nxt : graph[node]) {
    if (nxt == p) continue;
    dfs3(nxt, node);
  }
}
void dfs4(int node, int p, int sub) {
  if (2 * (n - subsz[node] - sub) <= n) ans[node] = 1;
  for (auto &nxt : graph[node]) {
    if (nxt == p) continue;
    dfs4(nxt, node, sub);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  dfs(1, 0);
  dfs2(cent, 0);
  vector<int> szs;
  ans[cent] = 1;
  for (auto &nxt : graph[cent]) {
    szs.push_back(subsz[nxt]);
  }
  sort(szs.begin(), szs.end(), greater<int>());
  for (auto &nxt : graph[cent]) {
    if (subsz[nxt] * 2 == n)
      dfs3(nxt, cent);
    else {
      if (subsz[nxt] == szs[0])
        dfs4(nxt, cent, szs[1]);
      else
        dfs4(nxt, cent, szs[0]);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (i > 1) putchar(' ');
    printf("%d", ans[i]);
  }
  return 0;
}
