#include<bits/stdc++.h>

    ///--------------------------------------------------------------------------------
    #define     T()                 ll t;    cin>>t;        while(t--)
    #define        ll                  long long
    #define        vi                     vector<ll>
    #define     pii                 pair<ll,ll>
    #define     vpair                 vector< pii >
    #define     fast                 ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    #define     repp(i,a,n)         for(ll i= a ; i < n ; ++i)
    #define     rep(i,n)            for(ll i= 0 ; i < n ; ++i)
    #define     p_b                     push_back
    #define     p_f                 push_front
    #define     pop_b                 pop_back()
    #define     pop_f                 pop_front()
    #define     m_p                 make_pair
    #define      sumv(v)              accumulate(v.begin(),v.endd(),0);
    #define     sortv(v)             sort(v.begin(),v.endd())
    #define     sort_dec(v)         sort(v.begin(),v.endd(),greater<ll>() )
    #define     l_b(v,l)               lower_bound (v.begin(), v.endd(), l)
    #define     u_b(v,l)               upper_bound (v.begin(), v.endd(), l)
    #define     pq                     priority_queue
    #define     ff                     first
    #define     ss                     second
    #define     len                 length()
    #define     all(v)              v.begin(),v.endd()
    #define     mset(a,b)           memset(a,b,sizeof(a));

    ///==========INPUT=============///
    #define     sc(a)           cin>>a;
    #define     sc2(a,b)        cin>>a>>b;
    #define     sc3(a,b,c)      cin>>a>>b>>c;
    #define     sc4(a,b,c,d)    cin>>a>>b>>c>>d;
    ///==========PRINTING=============///
    #define     prarr(arr)      rep(i,sizeof(arr)/sizeof(ll)) cout<<arr[i]<<" "; nl
    #define     prvec(v)        rep(i,v.size()) cout<<v[i]<<" "; nl
    #define     pr(x)           cout<<x<<"\n";
    #define     pr2(x, y)       cout<<x<<" "<<y<<"\n";
    #define     pr3(x, y, z)    cout<<x<<" "<<y<<" "<<z<<"\n";

    ///==========DEBUGGING=============///
    #define     debug(a)             cout<<"*"<<a<<enddl;
    #define     debug2(a,b)         cout<<"$"<<a<<" "<<b<<enddl;
    #define     debug3(a,b,c)         cout<<"$"<<a<<" "<<b<<" "<<c<<enddl;
    #define     bug                 cout<<"#"<<enddl;
    #define     nl                     cout<<'\n';
    #define     enddl                '\n'

    ///==========CONSTANTS=============///
    #define     max6     1000005
    #define     max5     100004
    #define     max4     10003
    #define     mod       1000000007
    #define     inf      1e9
    ll powermod(ll _a,ll _b,ll _m)    {ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}

    using namespace std;
    ll vis[max5];
    vpair v[max5];
    ll ans[max5],dis[max5];
    void dfs(ll i,ll d)
    {
        vis[i]=1;
        dis[i]=d;
        if(d%2==1)
            ans[i]=1;
        for(ll j=0;j<v[i].size();j++)
        {
            if(vis[v[i][j].ff]==0)
            {
                dfs(v[i][j].ff,d+v[i][j].ss);
            }
        }
    }
    int main()
    {
        fast
        ll n,a,b,c;
        sc(n)
        rep(i,n-1)
        {
            sc3(a,b,c)
            a--;b--;
            v[a].p_b(m_p(b,c));
            v[b].p_b(m_p(a,c));
        }
        dfs(0,0);
        rep(i,n)
        cout<<ans[i]<<endl;
    }


Measured memory_bytes: 11648