#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.1415926535897932384626433832795;
template <typename S, typename T>
ostream& operator<<(ostream& out, pair<S, T> const& p) {
  out << '(' << p.first << ", " << p.second << ')';
  return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> const& v) {
  int l = v.size();
  for (int i = 0; i < l - 1; i++) out << v[i] << ' ';
  if (l > 0) out << v[l - 1];
  return out;
}
void tr() { cout << endl; }
template <typename S, typename... Strings>
void tr(S x, const Strings&... rest) {
  cout << x << ' ';
  tr(rest...);
}
const int N = 400100;
int n;
vector<int> g[N];
int sz[N], par[N];
int res[N];
void dfs(int x, int p) {
  sz[x] = 1;
  par[x] = p;
  for (auto it = (g[x]).begin(); it != (g[x]).end(); ++it) {
    if (*it == p) continue;
    dfs(*it, x);
    sz[x] += sz[*it];
  }
}
void dfs2(int x, int p, int mx) {
  if (n - sz[x] - mx <= n / 2) res[x] = 1;
  for (auto it = (g[x]).begin(); it != (g[x]).end(); ++it) {
    if (*it == p) continue;
    dfs2(*it, x, (n - sz[*it] <= n / 2) ? max(n - sz[*it], mx) : mx);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, -1);
  int c = -1;
  for (int i = 1; i <= n; i++) {
    int mx = n - sz[i];
    for (auto it = (g[i]).begin(); it != (g[i]).end(); ++it) {
      if (*it == par[i]) continue;
      mx = max(mx, sz[*it]);
    }
    if (mx <= n / 2) {
      c = i;
      break;
    }
  }
  res[c] = 1;
  for (int i = 1; i <= n; i++) sz[i] = 0;
  dfs(c, -1);
  int mx = 0, smx = 0, id;
  for (auto it = (g[c]).begin(); it != (g[c]).end(); ++it) {
    if (mx < sz[*it]) {
      smx = mx;
      mx = sz[*it];
      id = *it;
    } else if (smx < sz[*it]) {
      smx = sz[*it];
    }
  }
  for (auto it = (g[c]).begin(); it != (g[c]).end(); ++it) {
    if (*it != id)
      dfs2(*it, c, (n - sz[*it] <= n / 2) ? max(mx, n - sz[*it]) : mx);
    else
      dfs2(*it, c, (n - sz[*it] <= n / 2) ? max(smx, n - sz[*it]) : smx);
  }
  for (int i = 1; i <= n; i++) {
    printf("%d ", res[i]);
  }
  puts("");
  return 0;
}
