#include <bits/stdc++.h>
using namespace std;
const int SIZE = 400000;
int k[SIZE], cen = -1, ans[SIZE], t, num[SIZE], z;
vector<int> g[SIZE];
vector<int> y;
void dfs1(int v, int pr, int n) {
  bool r = true;
  if (pr == t) {
    y.push_back(v);
    z = y.size() - 1;
  }
  num[v] = z;
  for (int u : g[v]) {
    if (u == pr) {
      continue;
    }
    dfs1(u, v, n);
    if ((k[u] + 1) > n / 2) {
      r = false;
    }
    k[v] += k[u] + 1;
  }
  if (r && (k[v] + 1) * 2 >= n) {
    cen = v;
  }
}
int main() {
  for (int i = 0; i < SIZE; i++) {
    k[i] = 0;
  }
  int n, a, b, max1 = 0, max2 = 1;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    g[a - 1].push_back(b - 1);
    g[b - 1].push_back(a - 1);
  }
  dfs1(0, -1, n);
  t = cen;
  for (int i = 0; i < SIZE; i++) {
    k[i] = 0;
  }
  y.resize(0);
  dfs1(cen, -1, n);
  if (k[y[0]] > k[y[1]]) {
    max1 = 0;
    max2 = 1;
  } else {
    max1 = 1;
    max2 = 0;
  }
  for (int i = 2; i < y.size(); i++) {
    int v = y[i];
    if (k[v] > k[y[max1]]) {
      max2 = max1;
      max1 = i;
    } else {
      if (k[v] > k[y[max2]]) {
        max2 = i;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (i == t) {
      ans[i] = 1;
      continue;
    }
    if ((k[y[num[i]]] + 1) == n - n / 2) {
      ans[i] = 1;
    } else {
      if (num[i] == max1) {
        if ((k[i] + 2 + k[y[max2]]) >= n - (n / 2)) {
          ans[i] = 1;
        }
      } else {
        if ((k[i] + 2 + k[y[max1]]) >= n - (n / 2)) {
          ans[i] = 1;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
