#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 5;
map<int, int> H;
set<int> s;
int sz[N], T = 1, n, ret[N];
vector<int> adj[N];
void dfs(int x, int p) {
  int maxi = 0, i, u;
  sz[x] = 1;
  for (i = 0; i < adj[x].size(); ++i) {
    u = adj[x][i];
    if (u != p) {
      dfs(u, x);
      sz[x] += sz[u];
      maxi = max(maxi, sz[u]);
    }
  }
  maxi = max(n - sz[x], maxi);
  if (maxi <= n / 2) {
    T = x;
  }
}
void mm(int x) {
  --H[x];
  if (H[x] == 0) s.erase(x);
}
void pp(int x) {
  ++H[x];
  if (H[x] == 1) s.insert(x);
}
set<int>::reverse_iterator it;
void dfs2(int x, int p) {
  int i, u;
  for (i = 0; i < adj[x].size(); ++i) {
    u = adj[x][i];
    if (u != p) pp(sz[u]);
  }
  for (i = 0; i < adj[x].size(); ++i) {
    u = adj[x][i];
    if (u != p) {
      mm(sz[u]);
      if (s.size() > 0) {
        it = s.rbegin();
        if (n - sz[u] - *it <= n / 2) ret[u] = 1;
      }
      if (n - sz[u] <= n / 2) ret[u] = 1;
      if (sz[x] - sz[u] <= n / 2) pp(sz[x] - sz[u]);
      dfs2(u, x);
      pp(sz[u]);
      if (sz[x] - sz[u] <= n / 2) mm(sz[x] - sz[u]);
    }
  }
}
int main() {
  int i, a, b;
  scanf("%d", &n);
  for (i = 0; i < n - 1; ++i) {
    scanf("%d%d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(1, 0);
  ret[T] = 1;
  a = T;
  dfs(a, 0);
  dfs2(a, 0);
  for (i = 1; i <= n; ++i) printf("%d ", ret[i]);
  cout << endl;
}
