#include <bits/stdc++.h>
using namespace std;
const int maxn = 400005;
vector<int> adj[maxn], rem, rup;
int p[maxn], son[maxn], down[maxn], ans[maxn], c[maxn], dsz[maxn], usz[maxn],
    msz[maxn], rt, n;
bool vis[maxn];
multiset<int> second;
void dfs1(int u, int v) {
  vis[u] = 1;
  dsz[u] = 1;
  p[u] = v;
  for (int i : adj[u])
    if (i != v) {
      dfs1(i, u);
      dsz[u] += dsz[i];
    }
}
void dfs2(int u, int v) {
  vis[u] = 1;
  usz[u] = n - dsz[u];
  int sum = dsz[u] - 1, maxi = -1;
  for (int i : adj[u])
    if (i != v) {
      if (maxi == -1)
        maxi = i;
      else if (dsz[maxi] < dsz[i])
        maxi = i;
    }
  for (int i : adj[u])
    if (i != v) dfs2(i, u);
  if (adj[u].size() != 0 && dsz[maxi] > usz[u]) {
    msz[u] = dsz[maxi];
    down[u] = 1;
    son[u] = maxi;
  } else
    msz[u] = usz[u];
  if (msz[u] > n / 2)
    c[u] = 1;
  else
    ans[u] = 1;
}
void dfs3(int u, int v) {
  vis[u] = 1;
  if (down[u] && c[u]) {
    for (int i : adj[u])
      if (i == son[u]) dfs3(i, u);
    int x = *(second.lower_bound(msz[u] - n / 2));
    if (x <= n / 2) ans[u] = 1;
    for (int i : adj[u])
      if (i != son[u] && i != v) dfs3(i, u);
  } else
    for (int i : adj[u])
      if (i != v) dfs3(i, u);
  second.insert(dsz[u]);
}
void dfs4(int u, int v) {
  vis[u] = 1;
  second.insert(usz[u]);
  rup.push_back(usz[u]);
  for (int i : adj[u])
    if (i != v) {
      second.erase(second.find(dsz[i]));
      dfs4(i, u);
      if (!down[u] && c[u])
        rem.push_back(dsz[i]);
      else
        second.insert(dsz[i]);
    }
  int x = *(second.lower_bound(msz[u] - n / 2));
  if (x <= n / 2) ans[u] = 1;
  if (down[u] || !c[u]) {
    for (int i : rem) second.insert(i);
    for (int i : rup) second.erase(second.find(i));
    rem.clear();
    rup.clear();
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  rt = 1;
  dfs1(rt, -1);
  memset(vis, 0, sizeof(vis));
  dfs2(rt, -1);
  memset(vis, 0, sizeof(vis));
  second.insert(1e9);
  dfs3(rt, -1);
  memset(vis, 0, sizeof(vis));
  dfs4(rt, -1);
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  return 0;
}
