/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}
//
//struct Edge{
//        int src;
//        int weight;
//    };

class Graph
{
    int V;    // No. of vertices

    // Pointer to an array containing
    // adjacency lists
    vector<pii> *adj;

    // A recursive function used by DFS
    void DFSUtil(int v, bool visited[],bool color[]);
public:
    Graph(int V);   // Constructor

    // function to add an edge to graph
    void addEdge(int v, int w,int we);

    // DFS traversal of the vertices
    // reachable from v
    void DFS(int v);
};

Graph::Graph(int V)
{
    this->V = V;
    adj = new vector<pii>[V];
}

void Graph::addEdge(int v, int w,int we)
{
    adj[v].emplace_back(w,we); // Add w to v’s list.
}

void Graph::DFSUtil(int v, bool visited[],bool color[])
{
    visited[v] = true;

    // Recur for all the vertices adjacent
    // to this vertex
    for (auto i = adj[v].begin(); i != adj[v].end(); ++i)
        if (!visited[(*i).first])
        {
            color[i->first] = (i->second & 1 )^color[v];
            DFSUtil(i->first, visited,color);
        }
}

// DFS traversal of the vertices reachable from v.
// It uses recursive DFSUtil()
void Graph::DFS(int v)
{
    // Mark all the vertices as not visited
    bool *visited = new bool[V];
    bool *color = new bool[V];
    for (int i = 0; i < V; i++)
        visited[i] = color[i]= false;


    // Call the recursive helper function
    // to print DFS traversal
    DFSUtil(v, visited, color);
    _for(i,V)cout << color[i] <<endl;
}

//#define int ll

class DEvenRelation {
public:
    vector<pii> G[101010];
    bool visited[101010];
    bool color[101001];
    void dfs(int s){
        if(visited[s])return ;
        visited[s] = 1;
        tr(G[s],it){
            int e = it->first;
            int w = it->second;
            if(!visited[e]){
                color[e] = color[s] ^ (w&1);
                dfs(e);
            }
        }
    }
void solve(std::istream& cin, std::ostream& cout) {

    int N;
    cin >> N;
    _for(i,N){
        int u,v,w;
        cin >> u >> v >> w;
        G[u].emplace_back(v,w);
        G[v].emplace_back(u,w);
    }
    dfs(1);
    rep(i,1,N+1)cout << color[i] << endl;

}
};


#undef int
int main() {
	DEvenRelation solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 7296