#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char c = getchar();
  int s = 0;
  while (c < '0' or c > '9') c = getchar();
  while (c >= '0' and c <= '9') {
    s = s * 10 + c - '0';
    c = getchar();
  }
  return s;
}
const int N = 4e5 + 888;
struct node {
  int next, to;
} a[N * 2];
int head[N], cnt;
void add(int e, int r) {
  a[++cnt].next = head[e];
  a[cnt].to = r;
  head[e] = cnt;
}
int n, x, y;
int siz[N], maxx[N], mixx[N], son[N], ans[N], jx[N];
void dfs(int u, int fa) {
  siz[u] = 1;
  for (int i = head[u]; i; i = a[i].next) {
    if (a[i].to == fa) continue;
    dfs(a[i].to, u);
    siz[u] += siz[a[i].to];
    if (siz[a[i].to] > siz[son[u]]) son[u] = a[i].to;
    int val = (siz[a[i].to] > n / 2 ? maxx[a[i].to] : siz[a[i].to]);
    if (val > maxx[u]) {
      mixx[u] = maxx[u];
      maxx[u] = val;
    } else if (val > mixx[u]) {
      mixx[u] = val;
    }
  }
}
void dfs1(int u, int fa) {
  int uu = siz[u];
  int um = maxx[u];
  int ui = mixx[u];
  if (siz[fa] > siz[son[u]]) {
    son[u] = fa;
  }
  int val = (siz[fa] > n / 2 ? jx[fa] : siz[fa]);
  if (val > maxx[u]) {
    mixx[u] = maxx[u];
    maxx[u] = val;
  } else if (val > mixx[u]) {
    mixx[u] = val;
  }
  if (siz[son[u]] <= n / 2) {
    ans[u] = 1;
  } else {
    if (son[u] == fa) {
      if (siz[son[u]] - jx[fa] <= n / 2) {
        ans[u] = 1;
      }
    } else if (siz[son[u]] - maxx[son[u]] <= n / 2) {
      ans[u] = 1;
    }
  }
  for (int i = head[u]; i; i = a[i].next) {
    if (a[i].to == fa) continue;
    int val = (siz[a[i].to] > n / 2 ? maxx[a[i].to] : siz[a[i].to]);
    if (val == maxx[u]) {
      jx[u] = mixx[u];
    } else
      jx[u] = maxx[u];
    siz[u] = n - siz[a[i].to];
    dfs1(a[i].to, u);
  }
  siz[u] = uu;
  maxx[u] = um;
  mixx[u] = ui;
}
int main() {
  n = read();
  for (int i = 1; i < n; i++) {
    x = read();
    y = read();
    add(x, y);
    add(y, x);
  }
  dfs(1, 0);
  dfs1(1, 0);
  for (int i = 1; i <= n; i++) {
    printf("%d ", ans[i]);
  }
}
