#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 10;
struct Edge {
  int to, nxt;
} e[N << 1];
int h[N], idx;
void Ins(int a, int b) {
  e[++idx].to = b;
  e[idx].nxt = h[a];
  h[a] = idx;
}
int bas, f[N], g[N], to[N], n, siz[N], Mx[N], mk[N], sec[N];
void dfs(int u, int fa) {
  siz[u] = 1;
  for (int i = h[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (v == fa) continue;
    dfs(v, u);
    siz[u] += siz[v];
    if (Mx[u] < siz[v]) Mx[u] = siz[v], to[u] = v;
    if (siz[v] <= bas) {
      if (g[u] < siz[v]) {
        sec[u] = g[u];
        g[u] = siz[v];
        mk[u] = v;
      } else if (sec[u] < siz[v]) {
        sec[u] = siz[v];
      }
    } else {
      if (g[v] > g[u]) {
        sec[u] = g[u];
        g[u] = g[v];
        mk[u] = v;
      } else if (g[v] > sec[u])
        sec[u] = g[v];
    }
  }
  if (Mx[u] < n - siz[u]) {
    Mx[u] = n - siz[u];
    to[u] = fa;
  }
}
void dfs2(int u, int fa) {
  if (Mx[u] <= bas)
    f[u] = 1;
  else if (to[u] != fa)
    f[u] = (Mx[u] - g[to[u]]) <= bas;
  else {
    if (mk[fa] == u) {
      f[u] = (Mx[u] - sec[fa]) <= bas;
    } else
      f[u] = (Mx[u] - g[fa]) <= bas;
  }
  if (mk[fa] == u) {
    if (sec[fa] > g[u]) {
      sec[u] = g[u];
      g[u] = sec[fa];
      mk[u] = fa;
    } else if (sec[fa] > sec[u]) {
      sec[u] = sec[fa];
    }
    int w = n - siz[u];
    if (w <= bas) {
      if (w > g[u]) {
        sec[u] = g[u];
        g[u] = w;
        mk[u] = fa;
      } else if (w > sec[u]) {
        sec[u] = w;
      }
    }
  } else {
    if (g[fa] > g[u]) {
      sec[u] = g[u];
      g[u] = g[fa];
      mk[u] = fa;
    } else if (g[fa] > sec[u])
      sec[u] = g[fa];
    int w = n - siz[u];
    if (w <= bas) {
      if (w > g[u]) {
        sec[u] = g[u];
        g[u] = w;
        mk[u] = fa;
      } else if (w > sec[u]) {
        sec[u] = w;
      }
    }
  }
  for (int i = h[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (v == fa) continue;
    dfs2(v, u);
  }
}
int main() {
  scanf("%d", &n);
  bas = n >> 1;
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    Ins(a, b);
    Ins(b, a);
  }
  dfs(1, 0);
  dfs2(1, 0);
  for (int i = 1; i <= n; i++) printf("%d ", f[i]);
  return 0;
}
