#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f7f7f7f;
const int MAXN = 400105;
const double eps = 1e-10;
struct node {
  int en, len, next;
  node(int en = 0, int len = 0, int next = 0) : en(en), len(len), next(next) {}
};
struct node E[MAXN * 2];
int p[MAXN], num;
void init() {
  memset(p, -1, sizeof(p));
  num = 0;
}
void add(int st, int en, int len) {
  E[num] = node(en, len, p[st]);
  p[st] = num++;
}
int max(int x, int y, int z) { return max(x, max(y, z)); }
int du[MAXN], ans[MAXN];
int n, dis1[MAXN], dis2[MAXN], sum[MAXN], id[MAXN];
void dfs(int u, int fa) {
  int i;
  sum[u]++;
  for (i = p[u]; i + 1; i = E[i].next) {
    int v = E[i].en;
    if (v == fa) continue;
    dfs(v, u);
    sum[u] += sum[v];
    if (sum[v] <= n / 2) {
      if (dis1[u] < sum[v]) {
        if (id[u] != v) dis2[u] = dis1[u];
        dis1[u] = sum[v];
        id[u] = v;
      } else if (dis1[u] == sum[v]) {
        if (id[u] != v) dis2[u] = max(dis2[u], dis1[u]);
      } else {
        if (id[u] != v) dis2[u] = max(dis2[u], sum[v]);
      }
    }
    if (dis1[u] < dis1[v]) {
      if (id[u] != v) dis2[u] = dis1[u];
      dis1[u] = dis1[v];
      id[u] = v;
    } else if (dis1[u] == dis1[v]) {
      if (id[u] != v) dis2[u] = max(dis2[u], dis1[u]);
    } else {
      if (id[u] != v) dis2[u] = max(dis2[u], dis1[v]);
    }
  }
}
void DFS(int u, int fa, int leng) {
  ans[u] = 1;
  for (int i = p[u]; i + 1; i = E[i].next) {
    int v = E[i].en;
    if (v != fa) {
      if (sum[v] - dis1[v] > n / 2) {
        ans[u] = 0;
        break;
      }
    } else {
      if (n - sum[u] - leng > n / 2) {
        ans[u] = 0;
        break;
      }
    }
  }
  for (int i = p[u]; i + 1; i = E[i].next) {
    int v = E[i].en;
    if (v == fa) continue;
    if (id[u] != v) {
      DFS(v, u, max(dis1[u], leng, n - sum[u] <= n / 2 ? n - sum[u] : 0));
    } else
      DFS(v, u, max(dis2[u], leng, n - sum[u] <= n / 2 ? n - sum[u] : 0));
  }
}
int main() {
  int i;
  scanf("%d", &n);
  init();
  for (i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(u, v, 0);
    add(v, u, 0);
  }
  for (i = 1; i <= n; i++) {
    dis1[i] = dis2[i] = 0;
    sum[i] = 0;
    id[i] = -1;
    ans[i] = -1;
  }
  dfs(1, -1);
  DFS(1, -1, 0);
  for (i = 1; i <= n; i++) {
    if (ans[i] == -1)
      while (1)
        ;
    printf("%d", ans[i]);
    if (i == n)
      puts("");
    else
      printf(" ");
  }
  return 0;
}
