#include <bits/stdc++.h>
using namespace std;
const int N = 400010;
int n, ans[N], where[N];
long long sz[N];
vector<int> v[N];
bool visit[N];
void init() {
  scanf("%d", &n);
  int a, b;
  for (int i = 0; i < n - 1; ++i) {
    scanf("%d %d", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
  }
}
void dfs(int now) {
  visit[now] = true;
  for (int i = 0; i < v[now].size(); ++i)
    if (!visit[v[now][i]]) {
      dfs(v[now][i]);
      sz[now] += sz[v[now][i]];
    }
  if (sz[now] == 0)
    sz[now] = 1;
  else
    sz[now] += 1;
}
int find_centroid(int now) {
  visit[now] = true;
  for (int i = 0; i < v[now].size(); ++i) {
    if (visit[v[now][i]]) continue;
    if (sz[v[now][i]] > n / 2) return find_centroid(v[now][i]);
  }
  return now;
}
void sv(int now, int value) {
  if (visit[now]) return;
  visit[now] = true;
  where[now] = value;
  for (int i = 0; i < v[now].size(); ++i) sv(v[now][i], value);
}
void dfs2(int now) {
  visit[now] = true;
  for (int i = 0; i < v[now].size(); ++i) sv(v[now][i], i);
}
void solve() {
  dfs(1);
  for (int i = 1; i <= n; ++i) visit[i] = false;
  int centroid = find_centroid(1);
  for (int i = 1; i <= n; ++i) visit[i] = false;
  dfs2(centroid);
  for (int i = 1; i <= n; ++i) {
    visit[i] = false;
    sz[i] = 0;
  }
  dfs(centroid);
  vector<int> tmp;
  for (int i = 0; i < v[centroid].size(); ++i)
    tmp.push_back(sz[v[centroid][i]]);
  int max1 = -1000000006, idx1, max2 = -1000000006, idx2;
  for (int i = 0; i < tmp.size(); ++i)
    if (tmp[i] > max1) {
      max1 = tmp[i];
      idx1 = i;
    }
  if ((n % 2 == 0) && max1 == n / 2)
    max2 = n / 2;
  else {
    for (int i = 0; i < tmp.size(); ++i)
      if (tmp[i] > max2 && i != idx1) {
        max2 = tmp[i];
        idx2 = i;
      }
  }
  for (int i = 1; i <= n; ++i) {
    if (i == centroid)
      ans[i] = 1;
    else if (where[i] == idx1) {
      int tmp = n - sz[i] - max2;
      if (tmp <= n / 2)
        ans[i] = 1;
      else
        ans[i] = 0;
    } else {
      int tmp = n - sz[i] - max1;
      if (tmp <= n / 2)
        ans[i] = 1;
      else
        ans[i] = 0;
    }
  }
  for (int i = 1; i <= n; ++i) printf("%d ", ans[i]);
  printf("\n");
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int __ = 1;
  while (__--) {
    init();
    solve();
  }
}
