#include <bits/stdc++.h>
const int MAXN = 4E5 + 5;
int color[MAXN]{};
std::vector<int> graph[MAXN]{};
int subtr[MAXN]{};
int upper[MAXN]{};
int N, Nh, R = 0;
int big[2];
void dfs(const int& cur) {
  for (auto& nxt : graph[cur])
    if (!upper[nxt]) {
      upper[nxt] = cur;
      dfs(nxt);
      subtr[cur] += subtr[nxt];
    }
  ++subtr[cur];
}
void dfsC(const int& cur, int prev) {
  int subsm = 0;
  bool good = (prev <= Nh);
  for (auto& nxt : graph[cur])
    if (nxt != upper[cur]) {
      if (subtr[nxt] > Nh) good = false;
      subsm += subtr[nxt];
    }
  if (good) R = cur;
  for (auto& nxt : graph[cur])
    if (nxt != upper[cur]) {
      if (good) return;
      dfsC(nxt, prev + subsm - subtr[nxt]);
    }
}
void dfs2(const int& cur, const int& flag) {
  color[cur] = flag;
  for (auto& nxt : graph[cur])
    if (nxt != upper[cur]) dfs2(nxt, flag);
}
int main() {
  scanf("%d", &N);
  Nh = N >> 1;
  for (int i = 1; i < N; ++i) {
    int u, v;
    scanf(" %d%d", &u, &v);
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  upper[1] = 1;
  dfs(1);
  dfsC(1, 0);
  for (int i = 1; i <= N; ++i) subtr[i] = upper[i] = 0;
  upper[R] = R;
  dfs(R);
  for (auto& nxt : graph[R]) dfs2(nxt, nxt);
  big[0] = big[1] = 0;
  for (auto& nxt : graph[R]) {
    if (subtr[nxt] >= subtr[big[0]]) {
      big[1] = big[0];
      big[0] = nxt;
    } else if (subtr[nxt] >= subtr[big[1]])
      big[1] = nxt;
  }
  for (int i = 1; i <= N; ++i)
    if (i != R) {
      int sze = subtr[big[0]];
      if (color[i] == big[0]) sze = subtr[big[1]];
      if ((N - subtr[i] - sze <= Nh) || (N - subtr[color[i]] <= Nh))
        printf("1 ");
      else
        printf("0 ");
    } else
      printf("1 ");
  putchar('\n');
  return 0;
}
