#include <bits/stdc++.h>
using namespace std;
struct node {
  int next, to;
} e[800005];
struct centroid {
  bool bo;
  int siz, l, r;
} c[3][3];
int head[400005], siz[400005], dfn[400005], ans[400005], b[3], cnt, now, g, n;
int read() {
  int A;
  bool K;
  char C;
  C = A = K = 0;
  while (C < '0' || C > '9') K |= C == '-', C = getchar();
  while (C > '/' && C < ':') A = (A << 3) + (A << 1) + (C ^ 48), C = getchar();
  return (K ? -A : A);
}
inline void add(int u, int v) {
  e[++g].to = v;
  e[g].next = head[u];
  head[u] = g;
}
void dfs(int u, int fa) {
  int i, v;
  bool rem = 0;
  siz[u] = 1;
  dfn[u] = ++now;
  for (i = head[u]; i; i = e[i].next) {
    v = e[i].to;
    if (v == fa) continue;
    dfs(v, u);
    siz[u] += siz[v];
    if (siz[v] > n >> 1) rem = 1;
  }
  if (n - siz[u] <= n >> 1 && !rem) {
    b[++cnt] = dfn[u];
    for (i = head[u]; i; i = e[i].next) {
      v = e[i].to;
      if (v == fa)
        if (n - siz[u] > c[cnt][1].siz) {
          c[cnt][2] = c[cnt][1];
          c[cnt][1].siz = n - siz[u];
          c[cnt][1].l = dfn[u];
          c[cnt][1].r = dfn[u] + siz[u] - 1;
          c[cnt][1].bo = 1;
        } else if (n - siz[u] > c[cnt][2].siz) {
          c[cnt][2].siz = n - siz[u];
          c[cnt][2].l = dfn[u];
          c[cnt][2].r = dfn[u] + siz[u] - 1;
          c[cnt][2].bo = 1;
        } else
          ;
      else if (siz[v] > c[cnt][1].siz) {
        c[cnt][2] = c[cnt][1];
        c[cnt][1].siz = siz[v];
        c[cnt][1].l = dfn[v];
        c[cnt][1].r = dfn[v] + siz[v] - 1;
        c[cnt][1].bo = 0;
      } else if (siz[v] > c[cnt][2].siz) {
        c[cnt][2].siz = siz[v];
        c[cnt][2].l = dfn[v];
        c[cnt][2].r = dfn[v] + siz[v] - 1;
        c[cnt][2].bo = 0;
      }
    }
  }
}
void calc(int u, int fa) {
  int i, j, k, v, mx = 0;
  for (j = 1; j <= (cnt); j++)
    for (k = 1; k <= (2); k++)
      if (!c[j][k].bo && (dfn[u] < c[j][k].l || dfn[u] > c[j][k].r) ||
          c[j][k].bo && dfn[u] >= c[j][k].l && dfn[u] <= c[j][k].r)
        mx = ((mx) > (c[j][k].siz) ? mx : c[j][k].siz);
  for (i = head[u]; i; i = e[i].next) {
    v = e[i].to;
    if (v != fa) {
      calc(v, u);
      if (siz[v] <= n >> 1) continue;
      if (siz[v] - mx > n >> 1) break;
    } else {
      if (n - siz[u] <= n >> 1) continue;
      if (n - siz[u] - mx > n >> 1) break;
    }
  }
  ans[u] = !i;
}
void write(int X) {
  if (X < 0) putchar('-'), X = -X;
  if (X > 9) write(X / 10);
  putchar(X % 10 | 48);
}
int main() {
  int i, u, v;
  n = read();
  for (i = 1; i <= (n - 1); i++) {
    u = read(), v = read();
    add(u, v), add(v, u);
  }
  dfs(1, 0);
  calc(1, 0);
  for (i = 1; i <= (n); i++) write(ans[i]), putchar(' ');
  return 0;
}
