// Original C++ solution (slower):
///Bismillahir Rahmanir Rahim

///ALLAHU AKBAR

#include<bits/stdc++.h>

#define flash() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);



#define sc1i(a) scanf("%d",&a)

#define sc2i(a,b) scanf("%d %d",&a,&b)

#define   sc3i(a,b,c)       scanf("%d %d %d",&a, &b, &c)

#define    p1i(a)           printf("%d\n",(a))

#define    p2i(a,b)        printf("%d %d\n",(a), (b))

#define    p3i(a,b,c)      printf("%d %d %d\n",(a), (b), (c))





#define sc1l(a) scanf("%lld",&a)

#define sc2l(a,b) scanf("%lld %lld",&a,&b)

#define   sc3l(a,b,c)       scanf("%lld %lld %lld",&a, &b, &c)

#define    p1l(a)           printf("%lld\n",(a))

#define    p2l(a,b)        printf("%lld %lld\n",(a), (b))

#define    p3l(a,b,c)      printf("%lld %lld %lld\n",(a), (b), (c))





#define c(x)       cout<<x<<endl

#define cy  cout<<"YES"<<endl

#define cn   cout<<"NO"<<endl

#define f1(i,a,b)  for(ll i=a;i<b;i++)

#define f2(i,a,b) 	for(ll i=a;i<=b;i++)

#define fr(i,a,b)   for(ll i=a;i>=b;i--)

#define LCM(a,b)                (a / __gcd(a,b) ) *b

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

#define dist(x1,y1,x2,y2)       sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))

#define distl(x1,y1,x2,y2)      sqrtl((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))



#define geta(a,n)           for(int i=0;i<n;i++) cin>>a[i]

#define puta(a,n)           for(int i=0;i<n;i++) cout<<a[i]<<" "



#define geta1(a,n)           for(int i=1;i<=n;i++) cin>>a[i]

#define puta1(a,n)           for(int i=1;i<=n;i++) cout<<a[i]<<" "





#define getar(a,n)           for(int i=0;i<n;i++) scanf("%lld",&a[i])

#define getar1(a,n)           for(int i=1;i<=n;i++) scanf("%lld",&a[i])

#define putar(a,n)           for(int i=0;i<n;i++) printf("%lld ",a[i])

#define putar1(a,n)           for(int i=1;i<=n;i++) printf("%lld ",a[i])

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

#define lla(A)                  A.rbegin(), A.rend()

#define unique(a)               sort(all(a)),a.erase(unique(all(a)),a.end())

#define pb                      push_back

#define mk                      make_pair

#define ff                      first

#define ss                      second

#define greatersrt(v)  sort(v.begin(),v.end(),greater<ll>())

#define min3(a,b,c)             min(a,min(b,c))

#define min4(a,b,c,d)           min(a,min(b,min(c,d)))

#define max3(a,b,c)             max(a,max(b,c))

#define max4(a,b,c,d)           max(a,max(b,max(c,d)))

#define max5(a,b,c,d,e)         max(max3(a,b,c),max(d,e))

#define min5(a,b,c,d,e)         min(min3(a,b,c),min(d,e))

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

#define see_you                     return 0

#define sorta(a,n)                   sort(a,a+n)

#define SORT(v)                 sort(v.begin(),v.end())

#define REV(v)                  reverse(v.begin(),v.end())

#define gp ' '

#define nl                        printf("\n")

int caseno=0;



#define  printcase             printf("Case %d: ",++caseno)

#define Debug                   cout<<endl<<"AND I AM IRONMAN"<<endl;

#define binleastsigonebit(x)    __builtin_ffs(x)

#define binleadingzeroes(x)     __builtin_clz(x)

#define bintrailingzeroes(x)    __builtin_ctz(x)

#define bintotalones(x)         __builtin_popcount(x)



//Datatypes

#define ll                      long long

#define ULL                     unsigned long long

#define LD                      long double

#define UI                      unsigned int

#define US                      unsigned short

#define pii             pair<int,int>

#define pll             pair<ll,ll>





//Constants

const int MOD = 1000000007; // 998244353

const ll INF = 1e18;

const ll inf = 0xFFFFFFFFFFFFFFFL;

const int maxn = 211111;

const int N = 1111111;

#define PI                      acos(-1.0)

#define EulerGamma              0.57721566490153286060651209





//ll powmod(ll base, ll power) { if (power == 0) return 1; else {ll cur = powmod(base, power / 2); cur = cur * cur; cur = cur % MOD;if (power % 2 == 1) cur = cur * base; cur = cur % MOD; return cur;}





/*------------------------------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

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

///ceil(x/y)==(x+y-1)/y





using namespace std;

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

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



//from a loser

//ll a[maxn];

vector< pair<ll,ll> > g[maxn];

ll vis[maxn];



ll color[maxn];



void dfs(ll u)

{

    vis[u]=1;



    for(ll i=0;i<g[u].size();i++)

    {

        ll v=g[u][i].first;  ///connecting node



        ll cost=g[u][i].second; /// length

        if(vis[v]) continue;

        if(cost%2==0)

        {

            color[v]=color[u];

        }

        else

        {

            if(color[u]==0) color[v]=1;

            else color[v]=0;

        }

        dfs(v);

    }

}







int main()

{

    flash()

    ll i,j,t,cas=0;

    ll n;cin>>n;

    f1(i,0,n-1)

    {

        ll u,v,w;

        cin>>u>>v>>w;

        g[u].push_back({v,w});

        g[v].push_back({u,w});

    }

    color[1]=0;

    dfs(1);



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









    see_you;

}






// Optimized solution to the same problem (faster):
// #pragma GCC optimize("Ofast,O3,unroll-loops")

// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")



#include <vector>

#include <list>

#include <map>

#include <set>

#include <deque>

#include <queue>

#include <stack>

#include <bitset>

#include <algorithm>

#include <functional>

#include <numeric>

#include <utility>

#include <iostream>

#include <sstream>

#include <iomanip>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <cctype>

#include <string>

#include <cstring>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <ctime>

#include <climits>

#include <complex>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>



using namespace __gnu_pbds;

using namespace std;



#define endl '\n'

#define hoise cerr<<"hoise - "<<__LINE__<<"\n"

#define tham getchar()

#define set0(ar) memset(ar, 0, sizeof ar)

#define setinf(ar) memset(ar, 126, sizeof ar)

#define vsort(v) sort(v.begin(), v.end())

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

#define FASTIO ios::sync_with_stdio(false);cin.tie(nullptr);



using ll = long long;

using pii = pair <int, int>;

using pll = pair <ll, ll>;

using vi = vector <int>;

using vl = vector <ll>;

using vpii = vector < pii >;

using vpll = vector < pll >;



const int MXN = (int)1e5+6;

const double PI = acos(-1.0);

const ll MOD = 1e9 + 7;

const int INF = 1e9;

const double EPS = 1e-6;

const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};



#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}

template<typename T, typename... Args>

void err(istream_iterator<string> it, T a, Args... args) {

    cerr << *it << " = " << a << endl;

    err(++it, args...);

}



int flipBit (int mask, int k) { return mask = mask ^ (1 << k); }

bool checkBit (int mask, int k) { return (mask >> k) & 1; }

int setBit (int mask, int k) { return mask = mask | (1 << k); }

int resetBit (int mask, int k) { if (checkBit (mask, k)) { mask = flipBit (mask, k); } return mask; }



inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }

inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a * b) % MOD; }

inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a + b) % MOD; }

inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }

inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }

inline ll modInverse(ll a) { return modPow(a, MOD - 2); }

inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }



template <typename T> using orderedSet = tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T> using orderedSet1 = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



bool approximatelyEqual(float a, float b, float epsilon) {

    return fabs(a - b) <= ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);

}

bool essentiallyEqual(float a, float b, float epsilon) {

    return fabs(a - b) <= ( (fabs(a) > fabs(b) ? fabs(b) : fabs(a)) * epsilon);

}

bool definitelyGreaterThan(float a, float b, float epsilon) {

    return (a - b) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);

}

bool definitelyLessThan(float a, float b, float epsilon) {

    return (b - a) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);

}



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



vpii adj[MXN];

int color[MXN];

bool vis[MXN];



void dfs (int s) {

	

	vis[s] = true;

	

	for (auto& u : adj[s]) {

		if (!vis[u.first]) {

			if (u.second % 2 == 0) {

				color[u.first] = color[s];

			}

			else {

				color[u.first] = color[s] ^ 1;

			}

			dfs (u.first);

		}

	}

}



void solve () {

	

	int n;

	cin >> n;

	

	for (int i = 1; i < n; ++i) {

		int x, y, w;

		cin >> x >> y >> w;

		adj[x].push_back ({y, w});

		adj[y].push_back ({x, w});

	}

	color[1] = 0;

	dfs (1);

	

	for (int i = 1; i <= n; ++i) {

		cout << color[i] << endl;

	}

	

}



int main(){

	// FASTIO

	

	int t;

	// cin >> t;

	t = 1;

	

	while (t--) {

		solve ();

	}

	

    return 0;

}



/*

 * be careful before submitting in Lightoj, SPOJ, UVA

*/


// Fastest known solution for this problem: