#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;

struct much
{
    int x,v;
};

vector <much> G[100001];
int f[100001],d[100001];

void dfs(int i,int k)
{
    f[i]=1;
    d[i]=k;
    for(auto it : G[i])
        if(!f[it.x])
            dfs(it.x,k+it.v);
}

int main()
{
    int i,n,x,y,u;
    scanf("%d",&n);
    for(i=1; i<n; i++)
    {
        scanf("%d%d%d",&x,&y,&u);
        G[x].push_back({y,u%2});
        G[y].push_back({x,u%2});
    }
    dfs(1,0);
    for(i=1; i<=n; i++)
    printf("%d\n",d[i]%2);

    return 0;
}
