#include <bits/stdc++.h>
using namespace std;
void err() { cout << endl; }
template <class T, class... Ts>
void err(const T &arg, const Ts &...args) {
  cout << arg << ' ';
  err(args...);
}
const int maxn = 4e5 + 7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
set<int> G[maxn];
int n;
int sz[maxn], f[maxn];
void dp(int u, int fa) {
  sz[u] = 1;
  for (int v : G[u]) {
    if (v == fa) continue;
    dp(v, u);
    sz[u] += sz[v];
    f[u] = max(f[u], f[v]);
  }
  if (sz[u] <= n / 2) {
    f[u] = sz[u];
  }
}
int ok[maxn];
void dfs(int u) {
  ok[u] = 1;
  for (int v : G[u]) {
    if (sz[v] > n / 2) {
      if (sz[v] - f[v] <= n / 2) {
        ok[u] = 1;
      } else {
        ok[u] = 0;
      }
      break;
    }
  }
  vector<int> son;
  son.push_back(0);
  for (int v : G[u]) {
    son.push_back(v);
  }
  int k = G[u].size();
  vector<int> pre, suf;
  pre.resize(son.size() + 1, 0);
  suf.resize(son.size() + 1, 0);
  for (int i = 1; i <= k; i++) {
    int v = son[i];
    pre[i] = max(pre[i - 1], f[v]);
  }
  for (int i = k; i >= 1; i--) {
    int v = son[i];
    suf[i] = max(suf[i + 1], f[v]);
  }
  for (int i = 1; i <= k; i++) {
    int v = son[i];
    if (ok[v] != -1) continue;
    int sav[4] = {sz[u], sz[v], f[u], f[v]};
    G[u].erase(v);
    G[v].insert(u);
    sz[u] -= sz[v];
    sz[v] += sz[u];
    f[u] = max(pre[i - 1], suf[i + 1]);
    if (sz[u] <= n / 2) f[u] = sz[u];
    f[v] = max(f[v], f[u]);
    if (sz[v] <= n / 2) f[v] = sz[v];
    dfs(v);
    sz[u] = sav[0];
    sz[v] = sav[1];
    f[u] = sav[2];
    f[v] = sav[3];
    G[u].insert(v);
    G[v].erase(u);
  }
}
void run() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].insert(v);
    G[v].insert(u);
  }
  dp(1, 0);
  memset(ok, -1, sizeof(ok));
  dfs(1);
  for (int i = 1; i <= n; i++) {
    printf("%d%c", ok[i], i == n ? '\n' : ' ');
  }
}
int main() {
  int T = 1;
  while (T--) {
    run();
  }
  return 0;
}
