#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > tab(400001);
int ij[400001], a, b, n, ji[400001], i, v[400001];
int s[400001], is = 0, par[400001], sson[2][400001], son[400001], mxson[400001],
               ss[400001];
int main() {
  scanf("%d", &n);
  for (int z = 1; z < n; z++)
    scanf("%d %d", &a, &b), tab[a].push_back(b), tab[b].push_back(a), ij[a]++,
        ij[b]++;
  for (int z = 0; z <= n; z++) ji[z] = ij[z];
  s[0] = 1, is = 1;
  while (is > 0) {
    a = s[is - 1];
    if (ji[a] > 0 && par[a] == tab[a][ji[a] - 1]) ji[a]--;
    if (ji[a] > 0)
      b = s[is] = tab[a][ji[a] - 1], par[b] = a, ji[a]--, is++;
    else {
      son[a]++, son[par[a]] += son[a];
      if (son[a] > son[mxson[par[a]]]) mxson[par[a]] = a;
      if (son[a] <= n / 2 && sson[0][par[a]] < son[a])
        sson[1][par[a]] = sson[0][par[a]], sson[0][par[a]] = son[a],
        ss[par[a]] = a;
      else if (son[a] <= n / 2 && sson[1][par[a]] < son[a])
        sson[1][par[a]] = son[a];
      if (sson[0][par[a]] < sson[0][a])
        sson[1][par[a]] = sson[0][par[a]], sson[0][par[a]] = sson[0][a],
        ss[par[a]] = a;
      else if (sson[1][par[a]] < sson[0][a] && ss[par[a]] != a)
        sson[1][par[a]] = sson[0][a];
      is--;
    }
  }
  for (int z = 0; z <= n; z++) ji[z] = ij[z];
  if (son[mxson[1]] - sson[0][mxson[1]] <= n / 2)
    v[1] = 1;
  else
    v[1] = 0;
  son[0] = 0, s[0] = 1, is = 1;
  while (is > 0) {
    a = s[is - 1];
    if (ji[a] > 0 && par[a] == tab[a][ji[a] - 1]) ji[a]--;
    if (ji[a] > 0) {
      b = s[is] = tab[a][ji[a] - 1];
      if (n - son[b] <= n / 2 && sson[0][b] < n - son[b])
        sson[0][b] = n - son[b], ss[b] = -1;
      else if (n - son[b] <= n / 2 && sson[1][b] < n - son[b])
        sson[1][b] = n - son[b];
      if (ss[a] != b && sson[0][a] >= sson[0][b])
        sson[0][b] = sson[0][a], ss[b] = -1;
      else if (sson[1][a] >= sson[0][b])
        sson[0][b] = sson[1][a], ss[b] = -1;
      else if (sson[1][a] > sson[1][b])
        sson[1][b] = sson[1][a];
      if (son[b] >= n / 2) {
        if (son[mxson[b]] - sson[0][mxson[b]] <= n / 2)
          v[b] = 1;
        else
          v[b] = 0;
      } else {
        if (ss[a] != b && n - son[b] - sson[0][a] <= n / 2)
          v[b] = 1;
        else if (n - son[b] - sson[1][a] <= n / 2)
          v[b] = 1;
        else
          v[b] = 0;
      }
      ji[a]--, is++;
    } else
      is--;
  }
  for (int z = 1; z <= n; z++) printf("%d ", v[z]);
  return 0;
}
