#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXN = 400005;
vector<int> G[MAXN], pre[MAXN], suf[MAXN];
int siz[MAXN], cnt[MAXN], maxson[MAXN], ans[MAXN];
int n;
void dfs1(int u, int fa) {
  siz[u] = 1;
  cnt[u] = 0;
  maxson[u] = 0;
  for (int v : G[u]) {
    if (v == fa) continue;
    dfs1(v, u);
    siz[u] += siz[v];
    cnt[u] = max(cnt[v], cnt[u]);
    if (siz[v] > siz[maxson[u]]) maxson[u] = v;
  }
  if (siz[u] <= n / 2) cnt[u] = siz[u];
}
void dfs2(int u, int fa) {
  int fasiz = n - siz[u];
  if (fasiz > siz[maxson[u]]) maxson[u] = fa;
  for (int v : G[u]) {
    if (v == fa) continue;
    dfs2(v, u);
  }
}
void dfs3(int u, int fa) {
  int child = G[u].size();
  pre[u].resize(child);
  suf[u].resize(child);
  for (int i = 0; i < child; i++) pre[u][i] = suf[u][i] = cnt[G[u][i]];
  for (int i = 1; i < child; i++) pre[u][i] = max(pre[u][i - 1], pre[u][i]);
  for (int i = child - 2; i >= 0; i--)
    suf[u][i] = max(suf[u][i + 1], suf[u][i]);
  for (int i = 0; i < child; i++) {
    int v = G[u][i];
    if (v == fa) continue;
    int mmax = 0;
    if (i > 0) mmax = max(pre[u][i - 1], mmax);
    if (i < child - 1) mmax = max(suf[u][i + 1], mmax);
    cnt[u] = (n - siz[v] <= n / 2 ? n - siz[v] : mmax);
    int x = maxson[v];
    if (x == u) {
      ans[v] = (n - siz[v] - cnt[x] <= n / 2 ? 1 : 0);
    } else {
      ans[v] = (siz[x] - cnt[x] <= n / 2 ? 1 : 0);
    }
    dfs3(v, u);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs1(1, 0);
  dfs2(1, 0);
  int x = maxson[1];
  ans[1] = (siz[x] - cnt[x] <= n / 2 ? 1 : 0);
  dfs3(1, 0);
  for (int i = 1; i <= n; i++) printf("%d%c", ans[i], " \n"[i == n]);
}
