#include <bits/stdc++.h>
using namespace std;
int used[500005], in[400005], out[400005], ar[400005], c[400005];
vector<int> v[400005];
int n;
void dfs1(int x) {
  used[x] = 1;
  c[x] = 1;
  in[x] = 0;
  for (int i = 0; i < v[x].size(); i++) {
    if (used[v[x][i]] == 0) {
      dfs1(v[x][i]);
      c[x] += c[v[x][i]];
      if (c[v[x][i]] + c[v[x][i]] <= n) {
        in[x] = max(in[x], c[v[x][i]]);
      }
      in[x] = max(in[x], in[v[x][i]]);
    }
  }
}
void dfs2(int x, int y) {
  used[x] = 0;
  int fl = 0;
  int q = 0, w = 0;
  for (int i = 0; i < v[x].size(); i++) {
    int z = v[x][i];
    if (used[z] == 1) {
      if (c[z] == in[x] || in[z] == in[x]) {
        q = z;
      }
      if (c[z] - in[z] > n / 2) {
        fl = 1;
      }
    }
  }
  if (fl)
    ar[x] = 0;
  else if (n - c[x] - y > n / 2)
    ar[x] = 0;
  else
    ar[x] = 1;
  for (int i = 0; i < v[x].size(); i++) {
    int z = v[x][i];
    if (used[z] == 1 && z != q) {
      if (c[z] + c[z] <= n && c[z] > w) {
        w = c[z];
      }
      if (in[z] + in[z] <= n && in[z] > w) {
        w = in[z];
      }
    }
  }
  for (int i = 0; i < v[x].size(); i++) {
    int z = v[x][i];
    if (used[z] == 1 && z != q) {
      out[z] = in[x];
      out[z] = max(out[z], y);
      if (n - c[z] + n - c[z] <= n) {
        out[z] = max(out[z], n - c[z]);
      }
    }
  }
  out[q] = max(w, y);
  if (n - c[q] + n - c[q] <= n) {
    out[q] = max(out[q], n - c[q]);
  }
  for (int i = 0; i < v[x].size(); i++) {
    int z = v[x][i];
    if (used[z] == 1) {
      dfs2(z, out[z]);
    }
  }
}
int main() {
  int a, b;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d %d", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
  }
  dfs1(1);
  dfs2(1, 0);
  for (int i = 1; i <= n; i++) {
    printf("%d ", ar[i]);
  }
}
