#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> adj[400400];
int sm[400400];
void dfs(int nd, int p) {
  sm[nd] = 1;
  for (int i = 0; i < adj[nd].size(); i++) {
    int ch = adj[nd][i];
    if (ch == p) continue;
    dfs(ch, nd);
    sm[nd] += sm[ch];
  }
}
int cen(int nd, int p) {
  for (int i = 0; i < adj[nd].size(); i++) {
    int ch = adj[nd][i];
    if (ch == p) continue;
    if (sm[ch] * 2 > n) {
      return cen(ch, nd);
    }
  }
  return nd;
}
int ans[400400];
int bst[400400];
int bst2[400400];
void solv(int nd, int p) {
  if (sm[nd] * 2 <= n) {
    bst[nd] = sm[nd];
  } else {
    bst[nd] = 0;
  }
  for (int i = 0; i < adj[nd].size(); i++) {
    int ch = adj[nd][i];
    if (ch == p) continue;
    solv(ch, nd);
    bst[nd] = max(bst[nd], bst[ch]);
    bst2[nd] = max(bst2[nd], bst[ch]);
  }
}
void gett(int nd, int p, int bb) {
  if (nd != p) {
    int bbb = bb;
    int ss = n - sm[nd];
    if ((ss - bbb) * 2 <= n) {
      ans[nd] = 1;
    } else {
      ans[nd] = 0;
    }
  }
  int mx = -1, mx2 = -1, ind;
  for (int i = 0; i < adj[nd].size(); i++) {
    int ch = adj[nd][i];
    if (ch == p) continue;
    if (bst[ch] > mx2) {
      mx2 = bst[ch];
      if (mx2 > mx) {
        swap(mx2, mx);
        ind = ch;
      }
    }
  }
  for (int i = 0; i < adj[nd].size(); i++) {
    int ch = adj[nd][i];
    if (ch == p) continue;
    int hh = 0;
    if ((n - sm[ch]) * 2 <= n) {
      hh = n / 2;
    }
    if (ch == ind) {
      gett(ch, nd, max(hh, max(bb, mx2)));
    } else {
      gett(ch, nd, max(hh, max(bb, mx)));
    }
  }
}
int main() {
  cin.sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(1, 1);
  int h = cen(1, 1);
  ans[h] = 1;
  dfs(h, h);
  solv(h, h);
  gett(h, h, 0);
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
}
