#include <bits/stdc++.h>
using namespace std;
bool fl[400010], f[400010], ok;
int n, i, j, k, a, b, c, ma, mb, mc, mai, ro;
int to[400010 << 1], ne[400010 << 1], he[400010], s[400010 << 1],
    sj = 1, C[400010], w[400010];
queue<int> A, B;
void init() {
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d%d", &a, &b);
    to[++sj] = b, ne[sj] = he[a], he[a] = sj;
    to[++sj] = a, ne[sj] = he[b], he[b] = sj;
    w[i] = 1;
  }
  w[n] = 1, c = n / 2;
}
void work() {
  for (i = he[1]; i; i = ne[i]) A.push(i);
  f[1] = 1;
  while (!A.empty()) {
    a = A.front(), A.pop();
    f[to[a]] = 1, C[++C[0]] = a;
    for (i = he[to[a]]; i; i = ne[i])
      if (!f[to[i]]) A.push(i);
  }
  memset(f, 0, sizeof(f));
  while (C[0]) {
    a = C[C[0]], C[0]--;
    s[a] = w[to[a]], s[a ^ 1] = n - w[to[a]];
    w[to[a ^ 1]] += w[to[a]];
  }
  for (i = 1; i <= n; i++) {
    for (ok = 1, j = he[i]; j; j = ne[j])
      if (s[j] > c) {
        ok = 0;
        break;
      }
    if (ok) {
      ro = i;
      break;
    }
  }
  for (ma = 0, i = he[ro]; i; i = ne[i])
    if (s[i] >= ma)
      mb = ma, ma = s[i], mai = i;
    else if (s[i] > mb)
      mb = s[i];
  if (n - ma <= c && n - ma > mb) mb = n - ma;
  for (f[ro] = fl[ro] = 1, i = he[ro]; i; i = ne[i]) {
    A.push(to[i]);
    if (mai == i)
      mc = mb, B.push(1);
    else
      mc = ma, B.push(0);
    if (s[i ^ 1] - mc <= c) fl[to[i]] = 1;
  }
  while (!A.empty()) {
    a = A.front(), A.pop();
    b = B.front(), B.pop();
    for (f[a] = 1, i = he[a]; i; i = ne[i])
      if (!f[to[i]]) {
        A.push(to[i]), B.push(b);
        mc = b ? mb : ma;
        if (s[i ^ 1] - mc <= c) fl[to[i]] = 1;
      }
  }
  for (i = 1; i < n; i++) printf("%d ", fl[i]);
  printf("%d\n", fl[n]);
}
int main() {
  init();
  work();
  return 0;
}
