#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
int n, child[N], ans[N];
vector<int> adj[N];
void dfs(int u, int pa) {
  child[u] = 1;
  for (int v : adj[u])
    if (v != pa) dfs(v, u), child[u] += child[v];
}
int find_cen(int u, int pa, int sz) {
  for (int v : adj[u])
    if (v != pa && child[v] > sz / 2) return find_cen(v, u, sz);
  return u;
}
void solve(int u, int pa, int sz) {
  if ((n - child[u] - sz) * 2 > n)
    ans[u] = 0;
  else
    ans[u] = 1;
  for (int v : adj[u])
    if (v != pa) solve(v, u, sz);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1, 1);
  int cen = find_cen(1, 1, child[1]), Max1 = 0, Max2 = 0;
  dfs(cen, cen);
  ans[cen] = 1;
  for (int v : adj[cen]) {
    if (child[v] > Max1)
      Max2 = Max1, Max1 = child[v];
    else if (child[v] > Max2)
      Max2 = child[v];
  }
  for (int u : adj[cen])
    if (child[u] * 2 == n)
      solve(u, cen, n / 2);
    else if (child[u] == Max1)
      solve(u, cen, Max2);
    else
      solve(u, cen, Max1);
  for (int i = 1; i <= n; ++i) cout << ans[i] << ' ';
}
