#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define debug(x) cerr << #x << " " << x << "\n"
#define debug_with_space(x) cerr << #x << " " << x << " "

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair <ll, ll> pii;
typedef pair <long double, pii> muchie;
typedef tree <ll, null_type, less_equal <ll>, rb_tree_tag, tree_order_statistics_node_update> OST;

const ll NMAX = 300001;
const ll INF = (1LL << 60);
const ll MOD = 998244353;
const ll BLOCK = 225;
const ll base = 31;
const ll nr_of_bits = 21;

vector <int> v[NMAX];
int sz[NMAX];
int total, sol[NMAX];
pii maxim;
int n, w;

void getsize(int node, int p) {
    sz[node] = 1;
    for(auto x : v[node]) {
        if(x == p)
            continue;
        getsize(x, node);
        sz[node] += sz[x];
    }
    total = sz[node];
}

int centroid(int node, int p) {
    for(auto x : v[node]) {
        if(x == p)
            continue;
        if(sz[x] > total / 2) {
            return centroid(x, node);
        }
    }
    return node;
}

void solve(int node, int p, int ancestor) {
    int maxi = 0;
    if(maxim.first != ancestor) {
        maxi = sz[maxim.first];
    } else {
        maxi = sz[maxim.second];
    }
    if(sz[node] - sz[ancestor] <= n / 2 && sz[ancestor] - sz[node] <= n / 2){
        sol[node] = 1;
    }else if(sz[w] - maxi - sz[node] <= n / 2){
        sol[node] = 1;
    }
    for(auto x : v[node]) {
        if(x == p)
            continue;
        solve(x, node, ancestor);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i = 2; i <= n; i++) {
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    getsize(1, 0);
     w = centroid(1, 0);
    getsize(w, 0);
    sol[w] = 1;
    for(auto x : v[w]) {
        if(sz[x] > sz[maxim.first]) {
            swap(maxim.first, maxim.second);
            maxim.first = x;
        } else if(sz[x] > sz[maxim.second]) {
            maxim.second = x;
        }
    }
    for(auto x : v[w]) {
        solve(x, w, x);
    }
    for(int i = 1; i <= n; i++)
        cout << sol[i] << " ";
    return 0;
}
