#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 5;
struct Edge {
  int to, nxt;
} e[N * 2];
int n, head[N], cntE, siz[N], f[N][2];
int ans[N], g[N], mxpt[N], pos[N];
inline void add(int u, int v) {
  e[++cntE] = (Edge){v, head[u]};
  head[u] = cntE;
}
void dfs1(int u, int fa) {
  siz[u] = 1;
  for (int i = head[u], v; i; i = e[i].nxt)
    if ((v = e[i].to) != fa) {
      dfs1(v, u);
      siz[u] += siz[v];
      if (siz[v] > siz[mxpt[u]]) mxpt[u] = v;
      int w = siz[v] <= n / 2 ? siz[v] : f[v][0];
      if (f[u][0] < w)
        f[u][1] = f[u][0], f[u][0] = w, pos[u] = v;
      else
        f[u][1] = max(f[u][1], w);
    }
}
void dfs2(int u, int fa) {
  if (siz[mxpt[u]] > n / 2)
    ans[u] = siz[mxpt[u]] - f[mxpt[u]][0] <= n / 2;
  else
    ans[u] = n - siz[u] - g[u] <= n / 2;
  for (int i = head[u], v; i; i = e[i].nxt)
    if ((v = e[i].to) != fa) {
      int w = (n - siz[u] <= n / 2) ? n - siz[u] : g[u];
      g[v] = max(w, f[u][pos[u] == v]);
      dfs2(v, u);
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 1, a, b; i < n; ++i) {
    scanf("%d%d", &a, &b);
    add(a, b);
    add(b, a);
  }
  dfs1(1, 0);
  dfs2(1, 0);
  for (int i = 1; i <= n; ++i) printf("%d ", ans[i]);
  return 0;
}
