// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define lli long long int

#define pii pair<int,int>

#define pll pair<lli,lli>

#define vi  vector<int>

#define vii vector<pair<int,int>>

#define vll vector<lli>

#define pb  push_back

#define mp  make_pair

#define ss  second

#define ff  first

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

#define BLACK 0

#define WHITE 1

#define piii pair<int,pii>

const int maxn = 2e5+9;

vector<pii>adj[maxn];

int vis[maxn];

int color[maxn];

void dfs(int curr,int col)

{

    vis[curr]=1;

    color[curr]=col;

    for(pii child:adj[curr])

    {

        if(vis[child.ff]==0)

        {

            int w=child.ss;

            if(w%2==0)dfs(child.ff,col);

            else dfs(child.ff,col^1);

        }

    }

}

void solve()

{

    int n;cin>>n;

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

    {

        int a,b,c;cin>>a>>b>>c;

        adj[a].pb(mp(b,c));

        adj[b].pb(mp(a,c));

    }

    dfs(1,BLACK);

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

    {

        cout<<color[i]<<endl;

    }



}



int main()

{

    solve();

}


// Faster C++ solution for the same problem (measured speedup: 1.8291737321583708x):
// #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

*/