#include <bits/stdc++.h>
using namespace std;
void err(istringstream &iss) {}
template <typename T, typename... Args>
void err(istringstream &iss, const T &varVal, const Args &...args) {
  string varName;
  iss >> varName;
  if (varName.back() == ',') varName.back() = ' ';
  cout << varName << " = " << varVal << "; ", err(iss, args...);
}
int n, m, K, T, Q, cn;
bitset<400005> notCentroid;
struct info {
  int mx, mxi, mx2, cnt;
} nich[400005];
int upormx[400005];
list<int> adj[400005];
void dfsNich(int u, int par) {
  int mx = -1, mxi = n + 1, mx2 = -1;
  for (auto &v : adj[u])
    if (v != par) {
      dfsNich(v, u), nich[u].cnt += nich[v].cnt;
      if (nich[v].cnt - nich[v].mx > (n >> 1)) notCentroid[u] = 1;
      int os = nich[v].cnt > (n >> 1) ? nich[v].mx : nich[v].cnt;
      if (os > mx)
        mx2 = mx, mx = os, mxi = v;
      else if (os > mx2)
        mx2 = os;
    }
  nich[u] = {max(mx, 0), mxi, max(mx2, 0), nich[u].cnt + 1};
}
void dfsUpor(int u, int par) {
  int siblings = nich[par].mxi == u ? nich[par].mx2 : nich[par].mx,
      uporCnt = n - nich[u].cnt;
  upormx[u] = uporCnt > (n >> 1) ? max(upormx[par], siblings) : uporCnt;
  if (uporCnt - upormx[u] > (n >> 1)) notCentroid[u] = 1;
  for (auto &v : adj[u])
    if (v != par) {
      dfsUpor(v, u);
    }
}
int main() {
  cin.tie(NULL);
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(v), adj[v].push_back(u);
  }
  dfsNich(1, -1), dfsUpor(1, -1);
  for (int i = 1; i <= n; i++) {
    printf("%c", "10"[notCentroid[i]]), printf("%c", " \n"[i == n]);
  }
  return 0;
}
