#include <bits/stdc++.h>
using namespace std;
double inff = 1.0 / 0.0;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
long long int x, y, n, i, z, j, k, w, u, q, m, d, t, g;
long long int isCentroid[400010], siz[400010], ans[400010];
long long int centroid, min_til;
vector<pair<long long int, long long int> > subtree;
vector<long long int> adj[400010];
void dfs(long long int src, long long int p) {
  siz[src] = 1;
  long long int mx = 0;
  for (auto a : adj[src]) {
    if (a != p) {
      dfs(a, src);
      siz[src] += siz[a];
      mx = max(mx, siz[a]);
    }
  }
  mx = max(n - siz[src], mx);
  if (mx < min_til) {
    min_til = mx;
    centroid = src;
  }
}
void dfs1(long long int cap, long long int src, long long int head,
          long long int p) {
  if (cap <= n / 2) {
    ans[src] = 1;
    goto hell;
  }
  for (int i = 0; i < min(2ll, (long long int)subtree.size()); i++) {
    if (subtree[i].second != head and
        n - siz[subtree[i].second] - siz[src] <= n / 2)
      ans[src] = 1;
  }
hell:
  for (auto a : adj[src]) {
    if (a != p) {
      dfs1(cap, a, head, src);
    }
  }
}
void solve() {
  cin >> n;
  for (i = (long long int)0; i < (long long int)n - 1; i++) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  min_til = 1e18;
  dfs(1, -1);
  ans[centroid] = true;
  dfs(centroid, centroid);
  for (auto a : adj[centroid]) {
    subtree.push_back({siz[a], a});
  }
  sort(subtree.begin(), subtree.end());
  reverse(subtree.begin(), subtree.end());
  for (i = (long long int)0; i < (long long int)(long long int)subtree.size();
       i++) {
    dfs1(n - subtree[i].first, subtree[i].second, subtree[i].second, centroid);
  }
  for (i = (long long int)1; i < (long long int)n + 1; i++) {
    cout << ans[i] << " ";
  }
  cout << "\n";
}
int main() {
  int TESTS = 1;
  ios::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  ;
  while (TESTS--) {
    solve();
  }
}
