// Slower C++ solution:


//#pragma GCC optimize("03,unroll-loops")

//#pragma GCC target("avx,avx2,fma")



#include<bits/stdc++.h>

typedef long long ll;

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>

#define pb           push_back

#define ff           first

#define ss           second

#define gcd(a, b)    __gcd(a, b)

#define lcm(a, b)    ((a)*((b)/gcd(a,b)))

#define all(v)       v.begin(),v.end()

#define lllim        2147483648

#define Pi           2*acos(0.0)

#define sci(n)	     scanf("%d",&n)

#define scii(n,m)    scanf("%d%d",&n,&m)

#define scl(n)       scanf("%lld",&n)

#define scll(n,m)    scanf("%lld%lld",&n,&m)

#define pii          pair<int,int>

#define pll 	     pair<ll,ll>

#define mem(a,b)     memset(a, b, sizeof(a))

#define fill_(a,b)   fill(a,a+n,b);

#define mod          1000000007ll

#define fast_cin     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define filein       freopen("input.txt","r", stdin)

#define D(x)         cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'

#define case		 int t,cas=1;cin>>t;while(t--)

#define rep(i,a,n)   for(int i=a;i<n;i++)

#define rev(i,n,a)   for(int i=n;i>=a;i--)



/*------------------------------Graph Moves----------------------------*/

//const int fx[]= {+1,-1,+0,+0};

//const int fy[]= {+0,+0,+1,-1};

//const int fx[]= {+0,+0,+1,-1,-1,+1,-1,+1};  // Kings Move

//const int fy[]= {-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move

//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move

//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move

/*---------------------------------------------------------------------*/



template<class T> void ckmin(T& a, const T& b) {

    a= b < a? b:a;

}

template<class T> void ckmax(T& a, const T& b) {

    a= b > a? b:a;

}



template<class T> void read(T& a) {

    std::cin>>a;

}



template<class T> void read(T& a, T& b) {

    std::cin>>a>>b;

}

template<class T> void read(T& a,T& b, T& c) {

    std::cin>>a>>b>>c;

}



template<class T> void read(T& ara, int sidx,  int eidx) {

    for(int i=sidx; i<eidx; i++)

        std::cin>>ara[i];

}









using namespace std;

using namespace __gnu_pbds;



const int maxn=100005;



///............................Number theory , si(), bigmod...................///

vector<int>pr;

ll bigmod(ll a, ll b, ll m);

void si();

///.................................Number theory end.........................///



vector<pii>adj[maxn];

int col[maxn];







void dfs(int u, int c, int p)

{

	col[u]=c;

	for(auto x: adj[u])

	{

		if(x.ff!=p)

		{

			int val=x.ss%2;

			if(val==0)

			{

				dfs(x.ff,c,u);

			}

			else

			{

				dfs(x.ff,1-c,u);

			}

		}

	}

}





void solve()

{

	

	int n;read(n);

	

	for(int i=0;i<n-1;i++)

	{

		int p,q,w;

		read(p,q);

		read(w);

		adj[p].pb({q,w});

		adj[q].pb({p,w});

	}	

	mem(col,-1);

	

	dfs(1,0,0);

	

	

	rep(i,1,n+1)

	{

		cout<<col[i]<<endl;

	}

	

	

	

}





int main()

{

    fast_cin;

    // si();



    //while(scanf("%d",&n)!=EOF)

//case

    {

        //cout<<""<<cas++<<""<<endl;

        solve();

    }



    return 0;

}















///............................Number theory , si(), bigmod...................///



bool mark[maxn];



void si()

{

    mem(mark,0);

    for(int i=4; i<maxn; i+=2) mark[i]=1;

    for(int i=3; i*i<maxn; i+=2)

    {

        if(!mark[i])

            for(int j=i*i; j<maxn; j+=2*i)

                mark[j]=1;

    }



    pr.pb(2);

    for(int i=3; i<maxn; i+=2)

        if(!mark[i])

            pr.pb(i);

}





ll bigmod(ll a, ll b, ll m)

{

    if(b==0) return 1;

    if(b==1) return a;



    if(b%2)

    {

        ll res=bigmod(a,b/2,m)%m;

        return ((((res%m)*(res%m))%m)*(a))%m;

    }

    else

    {

        ll res=bigmod(a,b/2,m)%m;

        return (((res%m)*(res%m))%m);

    }

}



///.................................Number theory end.........................///




// Faster C++ solution for the same problem (measured speedup: 1.119832089393384x):
//bad_bat

#include<bits/stdc++.h>

using namespace std;



#define Fast           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)

#define FO             freopen("in.txt", "r", stdin)

#define FC             freopen("out.txt", "w", stdout)

#define aise           cout<<"aise"<<endl

#define pb             push_back

#define pf             push_front

#define ppb            pop_back

#define ppf            pop_front

#define mp             make_pair

#define ll             long long

#define all(x)         x.begin(), x.end()

#define mset(v, a)     memset(v, a, sizeof(v))

#define pll            pair< ll, ll >

#define pd             pair< double, double >

#define ff             first

#define ss             second

#define pi             acos(-1.0)

#define mxN            2010

#define inf            1e14

#define mod            1000000007

#define tc             ll tc;scanf("%lld",&tc);while(tc--)



//NCR iterative

/*voidcomb_table(intN)

{

    for(inti=0; i<=N; ++i)

    {

        for(intj=0; j<=i; ++j)

        {

            if(j==0or j==i)

            {

                C[i][j]=1LL;

            }

            else

            {

                C[i][j]=(C[i-1][j-1]+C[i-1][j]);

            }

        }

    }

}*/





//NCR recursive

/*ll dp[55][55];



ll NCR(ll n,ll r)

{



    if(n==r)

        return dp[n][r]=1;

    if(r==0)

        return dp[n][r]= 1;

    if(r==1)

        return dp[n][r]=n ;

    if(dp[n][r] != -1)

        return dp[n][r];

    return dp[n][r] = NCR(n-1,r)+NCR(n-1,r-1);

}*/



//Sieve:

/*bool Flag[1000010];

vector<ll> Prime;



void sieve()

{



    ll val=sqrt(1000010);

    for(ll i=4;i<=1000005; i+=2) Flag[i]=1;

    for(ll i=3;i <= val;i+=2)

    {



        if(Flag[i]==0)

        {



            for(ll j=i*i;j<=1000005;j+=i) Flag[j]=1;

        }

    }

    Flag[1]=1;

    for(ll i=1;i<=1000000;i++)

        if(Flag[i]==0) Prime.pb(i);

}*/





//Conversion

/*string bin(ll x)

{



    string ret;

    while(x)

    {



        ll t=x%2;

        char c;

        if(t==1)

            c='1';

        else

            c='0';

        ret.pb(c);

        x/=2;

    }

    reverse(all(ret));

    return ret;

}*/



/*ll lcm(ll x, ll y)

{



    ll ret=__gcd(x,y);

    return (x*y)/ret;

}*/



/*ll dx[]= {0,0,1,-1};

ll dy[]= {1,-1,0,0};*/



ll col[100010];

vector<pll> adj[100010];

bool vis[100010];



void dfs(ll nd, ll cl)

{



    vis[nd]=1;

    col[nd]=cl;

    ll rev;

    if(cl==1) rev=0;

    else rev=1;

    for(ll i=0;i<adj[nd].size();i++)

    {



        ll v=adj[nd][i].ff;

        ll dis=adj[nd][i].ss;

        if(vis[v]) continue;

        if(dis%2) dfs(v,rev);

        else dfs(v,cl);

    }

}



int main()

{



    ll n;

    cin >> n;

    for(ll i=1;i<n;i++)

    {



        ll x,y,w;

        cin >> x >> y >> w;

        adj[x].pb(mp(y,w));

        adj[y].pb(mp(x,w));

    }

    dfs(1,0);

    for(ll i=1;i<=n;i++) cout << col[i] << endl;

}