#include <bits/stdc++.h>
const long long LL_INF = (long long)2e18 + 5;
using namespace std;
const long long N = 400010;
long long n;
vector<long long> adj[N], par(N), child(N), ans(N);
void dfs(long long v, long long par) {
  child[v] = 1;
  for (auto u : adj[v]) {
    if (u == par) continue;
    dfs(u, v);
    child[v] += child[u];
  }
}
long long centroid(long long v, long long p) {
  for (auto u : adj[v]) {
    if (u == p) continue;
    if (child[u] <= n / 2) continue;
    return centroid(u, v);
  }
  return v;
}
void dfs_for_cent(long long v, long long p) {
  child[v] = 1;
  if (p != -1) {
    if (par[p] == -1)
      par[v] = v;
    else
      par[v] = par[p];
  }
  for (auto u : adj[v]) {
    if (u == p) continue;
    dfs_for_cent(u, v);
    child[v] += child[u];
  }
}
void solve() {
  cin >> n;
  for (long long i = (long long)(0); i < (long long)(n - 1); i++) {
    long long u, v;
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v), adj[v].push_back(u);
  }
  dfs(0, -1);
  long long cent = centroid(0, -1);
  par[cent] = -1;
  dfs_for_cent(cent, -1);
  fill(ans.begin(), ans.end(), 0);
  long long mx_1 = -1, mx_2 = -1, mx_ind = -1;
  for (long long i = (long long)(0); i < (long long)(n); i++) {
    if (par[i] == i) {
      if (child[i] >= mx_1) {
        if (child[i] == mx_1) {
          if (mx_ind == -1)
            mx_ind = i;
          else
            mx_ind = -2;
        } else {
          mx_ind = i;
        }
        mx_2 = mx_1, mx_1 = child[i];
      } else if (child[i] >= mx_2)
        mx_2 = child[i];
    }
  }
  for (long long i = (long long)(0); i < (long long)(n); i++) {
    if (i == cent) {
      ans[i] = 1;
      continue;
    }
    long long pr = par[i];
    long long remain = 0;
    if (pr == mx_ind) {
      remain = max(child[pr] - child[i], mx_2);
    } else
      remain = mx_1;
    long long sz = n - child[i] - remain;
    if (sz <= n / 2)
      ans[i] = 1;
    else
      ans[i] = 0;
  }
  for (long long i = (long long)(0); i < (long long)(n); i++)
    cout << ans[i] << ' ';
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}
