#include <bits/stdc++.h>
using namespace std;
const int N = 400001;
vector<int> adj[N];
int sz[N];
void dfs(int u, int p = -1) {
  sz[u] = 1;
  for (auto el : adj[u]) {
    if (el != p) {
      dfs(el, u);
      sz[u] += sz[el];
    }
  }
}
int n;
int centroid(int u, int p = -1) {
  for (auto el : adj[u]) {
    if (el != p && sz[el] > n / 2) {
      return centroid(el, u);
    }
  }
  return u;
}
void root_at(int u) {
  memset(sz, 0, sizeof(sz));
  dfs(u);
}
int mxs[3];
int can[N];
void solve(int u, int sub, int p) {
  int rem = (sub == mxs[2] ? mxs[1] : mxs[2]);
  can[u] = (n - sz[u] - rem <= n / 2 || n - sub <= n / 2);
  for (auto el : adj[u]) {
    if (el != p) solve(el, sub, u);
  }
}
int main(int argc, char** argv) {
  cin >> n;
  int u, v;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d %d", &u, &v);
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(0);
  int root = centroid(0);
  root_at(root);
  can[root] = 1;
  for (auto el : adj[root]) {
    mxs[0] = sz[el];
    sort(mxs, mxs + 3);
  }
  for (auto el : adj[root]) {
    solve(el, sz[el], root);
  }
  for (int i = 0; i < n; i++) {
    printf("%d ", can[i]);
  }
  return 0;
}
