#include <bits/stdc++.h>
using namespace std;
const int N = 1000001;
struct edge {
  int next, to;
} e[N];
int g[N], n, M, cn, c[2], fir, sec, color[N], s[N];
inline void addedge(int x, int y) {
  e[++M] = (edge){g[x], y};
  g[x] = M;
}
inline void dfs1(int h, int fa) {
  bool flag = true;
  for (int i = g[h]; i; i = e[i].next) {
    if (e[i].to == fa) continue;
    dfs1(e[i].to, h);
    if (s[e[i].to] > n / 2) flag = false;
  }
  if (n - s[h] <= n / 2 && flag == true) {
    c[cn++] = h;
  }
}
inline void dfs2(int h, int fa) {
  s[h] = 1;
  for (int i = g[h]; i; i = e[i].next) {
    if (fa == e[i].to || e[i].to == c[0]) continue;
    dfs2(e[i].to, h);
    s[h] += s[e[i].to];
  }
}
inline void dfs3(int h, int fa) {
  for (int i = g[h]; i; i = e[i].next) {
    if (fa == e[i].to || e[i].to == c[0]) continue;
    color[e[i].to] = 1;
    dfs3(e[i].to, h);
  }
}
inline void predo() {
  dfs2(1, 0);
  dfs1(1, 0);
}
int main() {
  scanf("%d", &n);
  for (int i = 1, x, y; i < n; i++) {
    scanf("%d%d", &x, &y);
    addedge(x, y);
    addedge(y, x);
  }
  predo();
  if (cn == 2) {
    for (int i = 1; i <= n; i++) printf("1 ");
    return 0;
  }
  dfs2(c[0], 0);
  for (int j = g[c[0]]; j; j = e[j].next) {
    if (e[j].to == c[0] || e[j].to == c[1]) continue;
    if (s[e[j].to] > s[fir]) {
      sec = fir;
      fir = e[j].to;
    } else if (s[e[j].to] > s[sec]) {
      sec = e[j].to;
    }
  }
  color[fir] = 1;
  dfs3(fir, 0);
  for (int i = 1; i <= n; i++) {
    if (i == c[0]) {
      printf("1 ");
      continue;
    }
    if (color[i]) {
      if (n - s[sec] - s[i] <= n / 2) {
        printf("1 ");
      } else
        printf("0 ");
    } else {
      if (n - s[fir] - s[i] <= n / 2) {
        printf("1 ");
      } else {
        printf("0 ");
      }
    }
  }
  return 0;
}
