#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int x = 0;
  while (ch < '0' || '9' < ch) ch = getchar();
  while ('0' <= ch && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}
const int maxn = 400009;
struct edge {
  int v, link;
} e[maxn * 2];
int head[maxn], size[maxn], big[maxn];
int n, u, v, ans[maxn];
inline void addEdge(int k, int u, int v) {
  e[k].v = v;
  e[k].link = head[u];
  head[u] = k;
}
void dfs(int u, int fa) {
  size[u] = 1;
  for (int k = head[u]; k; k = e[k].link)
    if (e[k].v != fa) {
      dfs(e[k].v, u);
      size[u] += size[e[k].v];
      big[u] = max(big[u], big[e[k].v]);
      if (size[e[k].v] - big[e[k].v] > n / 2) ans[u] |= 1;
    }
  if (size[u] <= n / 2) big[u] = max(big[u], size[u]);
}
void dfs(int u, int fa, int best, int tmp) {
  int mx1 = 0, mx2 = 0, a;
  if (n - size[u] - best > n / 2) ans[u] |= 1;
  if (n - size[u] <= n / 2) best = max(best, n - size[u]);
  for (int k = head[u]; k; k = e[k].link)
    if (e[k].v != fa) {
      if (big[e[k].v] >= mx1) {
        mx2 = mx1;
        mx1 = big[e[k].v];
      } else if (big[e[k].v] >= mx2)
        mx2 = big[e[k].v];
    }
  for (int k = head[u]; k; k = e[k].link)
    if (e[k].v != fa) {
      if (big[e[k].v] == mx1)
        a = mx2;
      else
        a = mx1;
      dfs(e[k].v, u, max(best, max(a, tmp)),
          (n - size[e[k].v] > n / 2 ? 0 : n - size[e[k].v]));
    }
}
int main() {
  n = read();
  for (int i = 1; i <= n - 1; i++) {
    u = read();
    v = read();
    addEdge(2 * i - 1, u, v);
    addEdge(2 * i, v, u);
  }
  dfs(1, 0);
  dfs(1, 0, 0, 0);
  for (int i = 1; i <= n; i++) printf("%d ", ans[i] ^ 1);
  return 0;
}
