#include <bits/stdc++.h>
using namespace std;
vector<int> g[400010];
int sz[400010], f[400010], ans[400010], n;
int mx1, mx2;
void ae(int x, int y) { g[x].push_back(y); }
void dfs(int u, int fa) {
  sz[u] = 1;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v == fa) continue;
    dfs(v, u);
    sz[u] += sz[v];
    f[u] = max(f[u], sz[v]);
  }
  f[u] = max(f[u], n - sz[u]);
}
void work(int u, int fa, int S) {
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v == fa) continue;
    if (!fa)
      work(v, u, sz[v]);
    else
      work(v, u, S);
  }
  if (S != mx1) {
    if (max(n - sz[u] - mx1, mx1) <= n / 2) ans[u] = 1;
  } else {
    if (max(n - sz[u] - mx2, mx2) <= n / 2) ans[u] = 1;
  }
  if (S * 2 == n) ans[u] = 1;
}
int main() {
  scanf("%d", &n);
  int x, y;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    ae(x, y);
    ae(y, x);
  }
  dfs(1, 0);
  int c = 1;
  for (int i = 1; i <= n; i++)
    if (f[i] < f[c]) c = i;
  dfs(c, 0);
  for (int i = 0; i < g[c].size(); i++) {
    int v = g[c][i];
    if (sz[v] >= mx1)
      mx2 = mx1, mx1 = sz[v];
    else if (sz[v] > mx2)
      mx2 = sz[v];
  }
  ans[c] = 1;
  work(c, 0, 0);
  for (int i = 1; i <= n; i++) printf("%d%c", ans[i], (i < n) ? ' ' : '\n');
  return 0;
}
