#include <bits/stdc++.h>
using namespace std;
int mult(int x, int y) {
  long long int ans, x1 = (long long int)x, y1 = (long long int)y;
  ans = (x1 * y1) % 1000000007;
  return (int)ans;
}
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
long long int pow1(long long int a, long long int b) {
  long long int ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return ans;
}
int mina(int arr[], int n) {
  int x = arr[0], i, pos = 0;
  for (i = 1; i < n; i++) {
    if (arr[i] < x) {
      x = arr[i];
      pos = i;
    }
  }
  return x;
}
int maxa(int arr[], int n) {
  int x = arr[0], i, pos = 0;
  for (i = 1; i < n; i++) {
    if (arr[i] > x) {
      x = arr[i];
      pos = i;
    }
  }
  return x;
}
vector<vector<int> > v;
int n, centroid, mx1, mx2, ans[400005], child[400005], level[400005],
    immchild[400005];
void dfs(int root, int u, int par, int imm) {
  child[u] = 1;
  if (u == root) level[u] = 0;
  for (vector<int>::iterator itr = v[u].begin(); itr != v[u].end(); itr++) {
    int v1 = *itr;
    if (v1 != par) {
      level[v1] = level[u] + 1;
      if (level[v1] == 1)
        dfs(root, v1, u, v1);
      else
        dfs(root, v1, u, imm);
      if (level[v1] == 1)
        immchild[v1] = v1;
      else
        immchild[v1] = imm;
      child[u] += child[v1];
    }
  }
}
void dfs1(int u, int par) {
  if (u == centroid) {
    int cnt = 0;
    for (vector<int>::iterator itr = v[u].begin(); itr != v[u].end(); itr++) {
      int v1 = *itr;
      if (v1 != par) mx1 = max(child[v1] + 1, mx1);
    }
    if (mx1 <= n / 2) ans[u] = 1;
    for (vector<int>::iterator itr = v[u].begin(); itr != v[u].end(); itr++) {
      int v1 = *itr;
      if (v1 != par) {
        if (child[v1] + 1 == mx1) cnt++;
        if (child[v1] + 1 >= mx2 && child[v1] + 1 < mx1) mx2 = 1 + child[v1];
      }
      if (cnt > 1) mx2 = mx1;
    }
  }
  for (vector<int>::iterator itr = v[u].begin(); itr != v[u].end(); itr++) {
    int v1 = *itr;
    if (v1 != par) {
      int mx = 0;
      mx = max(mx, child[immchild[v1]] - child[v1]);
      mx = max(mx, child[centroid] - child[immchild[v1]]);
      if (mx <= (n / 2)) ans[v1] = 1;
      if (v[centroid].size() > 1 && mx1 != child[immchild[v1]] + 1) {
        mx = mx1;
        mx = max(mx, child[centroid] - mx1 - child[v1]);
      } else if (v[centroid].size() > 1) {
        mx = mx2;
        mx = max(mx, child[centroid] - mx2 - child[v1]);
      }
      if (mx <= (n / 2)) ans[v1] = 1;
      dfs1(v1, u);
    }
  }
}
int main() {
  int x, y, i, j;
  scanf("%d", &n);
  v.resize(n + 5);
  for (i = 0; i < n - 1; i++) {
    scanf("%d", &x);
    scanf("%d", &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1, 1, -1, -1);
  for (i = 1; i < n + 1; i++) child[i] -= 1;
  int curr = 1, mx = n, mxind = 1, par = 1;
  while (mx > (n / 2)) {
    mx = 0;
    curr = mxind;
    for (vector<int>::iterator itr = v[curr].begin(); itr != v[curr].end();
         itr++) {
      int v1 = *itr;
      if (v1 != par && child[v1] + 1 > mx) {
        mx = child[v1] + 1;
        mxind = v1;
      }
    }
    par = curr;
  }
  centroid = curr;
  for (i = 1; i < n + 1; i++) child[i] = 0, level[i] = 0, immchild[i] = -1;
  dfs(centroid, centroid, -1, -1);
  for (i = 1; i < n + 1; i++) child[i] -= 1;
  dfs1(centroid, -1);
  for (i = 1; i < n + 1; i++) cout << ans[i] << " ";
  cout << endl;
  ;
  return 0;
}
