#include <bits/stdc++.h>
namespace IO {
char buf[1000000], *p1, *p2;
inline char getc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <typename tp>
inline void r(tp &n) {
  n = 0;
  char c = getc();
  while (!isdigit(c)) c = getc();
  while (isdigit(c)) n = n * 10 + c - 48, c = getc();
}
template <typename tp, typename... Args>
inline void r(tp &n, Args &...args) {
  r(n);
  r(args...);
}
template <typename tp>
inline void write(tp n) {
  if (n / 10) write(n / 10);
  putchar(n % 10 + 48);
}
template <typename tp>
inline void w(tp n, char c = '\n') {
  write(n);
  putchar(c);
}
};  // namespace IO
using namespace IO;
const int N = 4e5 + 5;
using namespace std;
int n, rt, Minsub = N;
int size[N], isrt[N], Max[N][2];
vector<int> G[N];
void Getrt(int p, int fa) {
  size[p] = 1;
  int Max = 0;
  for (auto u : G[p])
    if (u ^ fa) {
      Getrt(u, p);
      size[p] += size[u];
      Max = max(Max, size[u]);
    }
  Max = max(Max, n - size[p]);
  if (Max < Minsub) Minsub = Max, rt = p;
}
void DFS1(int p, int fa) {
  size[p] = 1;
  for (auto u : G[p])
    if (u ^ fa) {
      DFS1(u, p);
      size[p] += size[u];
      int cur = size[u] > n / 2 ? Max[u][0] : size[u];
      if (cur > Max[p][0])
        Max[p][1] = Max[p][0], Max[p][0] = cur;
      else if (cur > Max[p][1])
        Max[p][1] = cur;
    }
}
void DFS2(int p, int rt) {
  size[rt] -= size[p];
  int cur = Max[rt][0] == size[p] ? Max[rt][1] : Max[rt][0];
  isrt[p] = (size[rt] - cur) <= n / 2;
  size[p] += size[rt];
  cur = size[rt] <= n / 2 ? max(cur, size[rt]) : cur;
  if (cur > Max[p][0])
    Max[p][1] = Max[p][0], Max[p][0] = cur;
  else if (cur > Max[p][1])
    Max[p][1] = cur;
  for (auto u : G[p])
    if (u ^ rt) DFS2(u, p);
  size[p] -= size[rt];
  size[rt] += size[p];
}
int main() {
  r(n);
  for (int i = 1, x, y; i <= n - 1; ++i)
    r(x, y), G[x].push_back(y), G[y].push_back(x);
  Getrt(1, 0);
  DFS1(rt, 0);
  isrt[rt] = 1;
  for (auto u : G[rt]) DFS2(u, rt);
  for (int i = 1; i <= n; ++i) w(isrt[i], ' ');
  return 0;
}
