#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void rread(T& num) {
  num = 0;
  T f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') num = num * 10 + ch - '0', ch = getchar();
  num *= f;
}
const int inf = 2e9, mod = 1e9 + 7;
const int maxn = 4e5 + 10;
const long double PI = acos(-1.0);
long long gcd(long long a, long long b) { return (a ? gcd(b % a, a) : b); }
void exgcd(long long a, long long b, long long& d, long long& x, long long& y) {
  if (!b) {
    d = a;
    x = 1;
    y = 0;
  } else {
    exgcd(b, a % b, d, y, x);
    y -= x * (a / b);
  }
}
long long power(long long a, long long n) {
  long long p = 1;
  while (n > 0) {
    if (n % 2) {
      p = p * a;
    }
    n >>= 1;
    a *= a;
  }
  return p;
}
long long power(long long a, long long n, long long mod) {
  long long p = 1;
  while (n > 0) {
    if (n % 2) {
      p = p * a;
      p %= mod;
    }
    n >>= 1;
    a *= a;
    a %= mod;
  }
  return p % mod;
}
int n, m;
vector<int> nex[maxn];
int sz[maxn], nel[maxn], a[maxn];
void dfs1(int x, int be) {
  int maxx = 0;
  sz[x] = 1;
  for (int i = 0; i < nex[x].size(); i++)
    if (nex[x][i] != be) {
      dfs1(nex[x][i], x);
      maxx = max(maxx, nel[nex[x][i]]);
      sz[x] += sz[nex[x][i]];
    }
  if (sz[x] <= n / 2)
    nel[x] = sz[x];
  else
    nel[x] = maxx;
}
void dfs2(int x, int be, int fa) {
  int maxx = 0;
  int id = 0;
  int maxx1 = 0, maxx2 = 0, id1 = 0, id2 = 0;
  if (n - sz[x] > maxx) maxx = n - sz[x], id = 0;
  if (fa > maxx1) maxx1 = fa, id1 = be;
  for (int i = 0; i < nex[x].size(); i++)
    if (nex[x][i] != be) {
      if (sz[nex[x][i]] > maxx) maxx = sz[nex[x][i]], id = nex[x][i];
      if (nel[nex[x][i]] > maxx1) {
        maxx2 = maxx1;
        id2 = id1;
        maxx1 = nel[nex[x][i]];
        id1 = nex[x][i];
      } else if (nel[nex[x][i]] > maxx2)
        maxx2 = nel[nex[x][i]], id2 = nex[x][i];
    }
  if (id == 0) {
    if (n - sz[x] - fa <= n / 2)
      a[x] = 1;
    else
      a[x] = 0;
  } else {
    if (sz[id] - nel[id] <= n / 2)
      a[x] = 1;
    else
      a[x] = 0;
  }
  for (int i = 0; i < nex[x].size(); i++)
    if (nex[x][i] != be) {
      int gg = 0;
      if (id1 == nex[x][i]) {
        if (n - sz[nex[x][i]] <= n / 2)
          gg = n - sz[nex[x][i]];
        else
          gg = maxx2;
      } else {
        if (n - sz[nex[x][i]] <= n / 2)
          gg = n - sz[nex[x][i]];
        else
          gg = maxx1;
      }
      dfs2(nex[x][i], x, gg);
    }
}
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) nex[i].clear();
    memset(nel, 0, sizeof nel);
    for (int i = 1; i < n; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      nex[u].push_back(v);
      nex[v].push_back(u);
    }
    dfs1(1, 0);
    dfs2(1, 0, 0);
    for (int i = 1; i <= n; i++) printf("%d ", a[i]);
    printf("\n");
  }
  return 0;
}
