#include <bits/stdc++.h>
using namespace std;
bool SR(int &_x) { return scanf("%d", &_x) == 1; }
bool SR(long long &_x) { return scanf("%lld", &_x) == 1; }
bool SR(double &_x) { return scanf("%lf", &_x) == 1; }
bool SR(char *_s) { return scanf("%s", _s) == 1; }
bool RI() { return true; }
template <typename I, typename... T>
bool RI(I &_x, T &..._tail) {
  return SR(_x) && RI(_tail...);
}
void SP(const int _x) { printf("%d", _x); }
void SP(const long long _x) { printf("%lld", _x); }
void SP(const double _x) { printf("%.16lf", _x); }
void SP(const char *s) { printf("%s", s); }
void PL() { puts(""); }
template <typename I, typename... T>
void PL(const I _x, const T... _tail) {
  SP(_x);
  if (sizeof...(_tail)) putchar(' ');
  PL(_tail...);
}
const int maxn = 4e5 + 5;
int n;
vector<int> edge[maxn];
void read() {
  RI(n);
  for (int i = 0; i < int(n - 1); i++) {
    int a, b;
    RI(a, b);
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
}
int siz[maxn];
int dfs1(int u, int p) {
  siz[u] = 1;
  for (int v : edge[u])
    if (v != p) siz[u] += dfs1(v, u);
  return siz[u];
}
int root;
void build() {
  dfs1(1, 0);
  vector<int> roots;
  for (int i = (1); i <= int(n); i++) {
    int dp = n - siz[i];
    for (int v : edge[i])
      if (siz[v] < siz[i]) dp = max(dp, siz[v]);
    if (dp <= n / 2) roots.push_back(i);
  }
  assert(1 <= ((int)(roots).size()) && ((int)(roots).size()) <= 2);
  if (((int)(roots).size()) == 2) {
    for (int i = (1); i <= int(n); i++) printf("1%c", " \n"[i == n]);
    exit(0);
  }
  root = roots[0];
}
bitset<maxn> abl;
struct Bit {
  int dat[maxn];
  void init() { memset(dat, 0, sizeof(dat)); }
  void add(int i, int x) {
    for (; i <= n; i += i & -i) dat[i] += x;
  }
  int ask(int i) {
    int ret = 0;
    for (; i >= 1; i -= i & -i) ret += dat[i];
    return ret;
  }
} bit;
void dfs2(int u, int p, int val) {
  bit.add(siz[u], val);
  for (int v : edge[u])
    if (v != p) dfs2(v, u, val);
}
int can[maxn];
void dfs3(int u, int p) {
  can[u] -= bit.ask(n / 2) - bit.ask(n - siz[u] - n / 2 - 1);
  for (int v : edge[u])
    if (v != p) dfs3(v, u);
}
void sol() {
  abl[root] = 1;
  dfs1(root, 0);
  for (int i = (1); i <= int(n); i++)
    if (i != root) bit.add(siz[i], 1);
  for (int i = (1); i <= int(n); i++)
    if (i != root) can[i] = bit.ask(n / 2) - bit.ask(n - siz[i] - n / 2 - 1);
  bit.init();
  for (int u : edge[root]) {
    dfs2(u, root, 1);
    dfs3(u, root);
    dfs2(u, root, -1);
  }
  for (int i = (1); i <= int(n); i++)
    if (i != root) abl[i] = (can[i] > 0);
  for (int i = (1); i <= int(n); i++)
    printf("%d%c", (int)abl[i], " \n"[i == n]);
}
int main() {
  read();
  build();
  sol();
  return 0;
}
