#include <bits/stdc++.h>
using namespace std;
void read_file(bool outToFile = true) {}
int n;
vector<vector<int> > G;
int root;
int nc[400000 + 9];
bool ans[400000 + 9];
int arr[2];
int maxV;
void DFS1(int u, int p = -1) {
  nc[u] = 1;
  for (int i = 0, sz = G[u].size(); i < sz; i++) {
    int v = G[u][i];
    if (v == p) continue;
    DFS1(v, u);
    nc[u] += nc[v];
  }
}
int count_centroids(int u, int p = -1) {
  bool isCentroid = 1;
  int ret = 0;
  for (int i = 0, sz = G[u].size(); i < sz; i++) {
    int v = G[u][i];
    if (v == p) continue;
    ret += count_centroids(v, u);
    if (nc[v] > n / 2) isCentroid = 0;
  }
  if (p != -1) isCentroid &= n - nc[u] <= n / 2;
  if (isCentroid) root = u;
  ret += isCentroid;
  return ret;
}
void print() {
  for (int i = 0; i < n; i++) printf("%d%c", ans[i], " \n"[i == n - 1]);
}
void build() {
  int mx = -1;
  int u = root;
  for (int i = 0, sz = G[u].size(); i < sz; i++) {
    int v = G[u][i];
    if (mx == -1 || nc[mx] < nc[v]) mx = v;
  }
  assert(mx != -1);
  arr[0] = nc[mx];
  int smx = -1;
  for (int i = 0, sz = G[u].size(); i < sz; i++) {
    int v = G[u][i];
    if (v == mx) continue;
    if (smx == -1 || nc[smx] < nc[v]) smx = v;
  }
  assert(smx != -1);
  arr[1] = nc[smx];
  maxV = mx;
}
void DFS(int u, int p = -1, bool fromMax = 0) {
  if (p == -1) {
    ans[u] = 1;
    for (int i = 0, sz = G[u].size(); i < sz; i++) {
      int v = G[u][i];
      DFS(v, u, v == maxV);
    }
    return;
  }
  ans[u] = n - nc[u] - arr[fromMax] <= n / 2;
  for (int i = 0, sz = G[u].size(); i < sz; i++) {
    int v = G[u][i];
    if (v == p) continue;
    DFS(v, u, fromMax);
  }
}
int main() {
  read_file();
  while (scanf("%d", &n) != EOF) {
    G.assign(n, vector<int>());
    for (int i = 0; i < n - 1; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      u--, v--;
      G[u].push_back(v);
      G[v].push_back(u);
    }
    DFS1(0);
    int nCentroid = count_centroids(0);
    if (nCentroid >= 2) {
      for (int i = 0; i < n; i++) ans[i] = 1;
      print();
      continue;
    }
    assert(nCentroid == 1);
    DFS1(root);
    build();
    DFS(root);
    print();
  }
}
