#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 10;
struct Node {
  int siz;
  int p[4], x[4];
  Node() { siz = 0; }
  void push(int _x, int _p) {
    p[siz] = _x;
    x[siz] = _p;
    siz++;
    for (int i = siz - 1; i > 0; i--) {
      if (x[i] > x[i - 1]) swap(x[i], x[i - 1]), swap(p[i], p[i - 1]);
    }
    siz = min(siz, 2);
  }
  int top(int o) {
    for (int i = 0; i < siz; i++)
      if (p[i] != o) {
        return x[i];
      }
    return 0;
  }
};
vector<int> edg[N];
int siz[N];
int n;
int max_siz[N];
int up[N];
int fa[N];
int ans[N];
void dfs_1(int u) {
  siz[u] = 1;
  max_siz[u] = 0;
  for (int i = 0; i < edg[u].size(); i++) {
    int v = edg[u][i];
    if (fa[u] == v) continue;
    fa[v] = u;
    dfs_1(v);
    siz[u] += siz[v];
    max_siz[u] = max(max_siz[u], max_siz[v]);
  }
  if (siz[u] <= n / 2) max_siz[u] = max(max_siz[u], siz[u]);
}
void dfs_2(int u) {
  int cnt = 0, s = 0;
  Node son = Node();
  up[u] = max(up[u], up[fa[u]]);
  if (n - siz[u] <= n / 2) up[u] = max(up[u], n - siz[u]);
  for (int i = 0; i < edg[u].size(); i++) {
    int v = edg[u][i];
    if (fa[u] == v) continue;
    if (siz[v] > n / 2) cnt++, s = v;
    son.push(v, max_siz[v]);
  }
  for (int i = 0; i < edg[u].size(); i++) {
    int v = edg[u][i];
    if (fa[u] == v) continue;
    up[v] = max(up[v], son.top(v));
  }
  if (n - siz[u] > n / 2) cnt++, s = u;
  if (cnt >= 2)
    ans[u] = 0;
  else if (cnt == 0)
    ans[u] = 1;
  else {
    ans[u] = 0;
    if (s == u) ans[u] = ((n - siz[u]) - up[u] <= n / 2) ? 1 : 0;
    if (s != u) ans[u] = (siz[s] - max_siz[s] <= n / 2) ? 1 : 0;
  }
  for (int i = 0; i < edg[u].size(); i++) {
    int v = edg[u][i];
    if (fa[u] == v) continue;
    dfs_2(v);
  }
}
void init() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    edg[u].push_back(v);
    edg[v].push_back(u);
  }
  fa[1] = 0;
  dfs_1(1);
  memset(ans, 0, sizeof(ans));
}
void work() {
  dfs_2(1);
  for (int i = 1; i <= n; i++) {
    printf("%d%c", ans[i], i == n ? '\n' : ' ');
  }
}
int main() {
  init();
  work();
  return 0;
}
