#include <bits/stdc++.h>
using namespace std;
const int N = 3e6 + 99;
int n, x, y, cnt = -1, as[N], at[N], ad[N], centroid[N], sub[N], k = 20, p,
             mark1[N], u, mark2[N], ans, w, mark3[N];
vector<int> g[N], quer[N];
map<pair<int, int>, int> maap;
void solve_queries_ofline() {
  for (int i = 0; i < n; i++) {
    u = sub[ad[i]];
    p = 0;
    if (u <= n / 2) {
      for (int j = k - 1; j >= 0; j--) {
        if (u >= (1 << j)) {
          u -= (1 << j);
          p += (1 << j);
          mark1[p]++;
        }
      }
    }
    for (int j = 0; j < quer[i].size(); j++) {
      p = (1 << k);
      u = (1 << k) - quer[i][j];
      ans = 0;
      for (int l = k - 1; l >= 0; l--) {
        if (u >= (1 << l)) {
          u -= (1 << l);
          p -= (1 << l);
          ans += mark1[p];
        }
      }
      maap[make_pair(i, quer[i][j])] = ans;
    }
  }
}
void dfs_data(int x, int par) {
  sub[x] = 1;
  as[x] = ++cnt;
  ad[cnt] = x;
  for (int i = 0; i < g[x].size(); i++)
    if (g[x][i] != par) {
      dfs_data(g[x][i], x);
      sub[x] += sub[g[x][i]];
    }
  at[x] = cnt;
}
void add_query(int x, int par) {
  for (int i = 0; i < g[x].size(); i++) {
    if (g[x][i] != par && sub[g[x][i]] > n / 2) {
      quer[at[x]].push_back(sub[g[x][i]] - n / 2);
      quer[as[x]].push_back(sub[g[x][i]] - n / 2);
    }
  }
}
void ad_query(int x, int par) {
  quer[n - 1].push_back(n - sub[x] - n / 2);
  quer[at[x]].push_back(n - sub[x] - n / 2);
  quer[as[x] - 1].push_back(n - sub[x] - n / 2);
}
void dfs_query(int x, int par) {
  for (int i = 0; i < g[x].size(); i++)
    if (g[x][i] != par) dfs_query(g[x][i], x);
  if (sub[x] > n / 2)
    add_query(x, par);
  else
    ad_query(x, par);
}
void dfs_solve(int x, int par) {
  p = (1 << k);
  u = (1 << k) - (n - sub[x] - n / 2);
  w = 0;
  for (int i = k - 1; i >= 0; i--) {
    if (u >= (1 << i)) {
      u -= (1 << i);
      p -= (1 << i);
      w += mark3[p];
    }
  }
  p = 0;
  u = sub[x];
  if (u <= n / 2) {
    for (int i = k - 1; i >= 0; i--) {
      if (u >= (1 << i)) {
        u -= (1 << i);
        p += (1 << i);
        mark3[p]++;
      }
    }
  }
  if (sub[x] < n / 2 + (n % 2)) {
    int y = (1 << k) - (n - sub[x] - n / 2);
    p = (1 << k);
    for (int i = k - 1; i >= 0; i--) {
      if (y >= (1 << i)) {
        y -= (1 << i);
        p -= (1 << i);
        centroid[x] += mark2[p];
      }
    }
    if (maap[make_pair(n - 1, (n - sub[x] - n / 2))] -
        (maap[make_pair(at[x], (n - sub[x] - n / 2))] -
         maap[make_pair(as[x] - 1, (n - sub[x] - n / 2))]) -
        w)
      centroid[x] = 1;
  } else {
    centroid[x] = 1;
    for (int i = 0; i < g[x].size(); i++) {
      if (sub[g[x][i]] < sub[x] && sub[g[x][i]] > n / 2) {
        if (maap[make_pair(at[x], sub[g[x][i]] - n / 2)] ==
            maap[make_pair(as[x], sub[g[x][i]] - n / 2)])
          centroid[x] = 0;
      }
    }
  }
  for (int i = 0; i < g[x].size(); i++) {
    if (g[x][i] != par) {
      y = n - sub[g[x][i]];
      p = 0;
      if (y <= n / 2) {
        for (int j = k - 1; j >= 0; j--) {
          if (y >= (1 << j)) {
            y -= (1 << j);
            p += (1 << j);
            mark2[p]++;
          }
        }
      }
      dfs_solve(g[x][i], x);
      y = n - sub[g[x][i]];
      p = 0;
      if (y <= n / 2) {
        for (int j = k - 1; j >= 0; j--) {
          if (y >= (1 << j)) {
            y -= (1 << j);
            p += (1 << j);
            mark2[p]--;
          }
        }
      }
    }
  }
  p = 0;
  u = sub[x];
  if (u <= n / 2) {
    for (int i = k - 1; i >= 0; i--) {
      if (u >= (1 << i)) {
        u -= (1 << i);
        p += (1 << i);
        mark3[p]--;
      }
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    ;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs_data(1, 0);
  dfs_query(1, 0);
  solve_queries_ofline();
  dfs_solve(1, 0);
  for (int i = 1; i < n + 1; i++) cout << (centroid[i] > 0) << " ";
}
