// Original C++ solution (slower):
#include <iostream>

#include <vector>

#include <algorithm>

#include <cmath>

#include <queue>

#include <string>

#include <map>

#include <set>

#include <tuple>

#include <deque>

#include <numeric>

#include <bitset>

#include <iomanip>

#include <cassert>

#include <chrono>

#include <random>

#include <limits>

#include <iterator>

#include <functional>

#include <sstream>

using namespace std;



typedef long long ll;

typedef pair<int, int> P;

typedef pair<int, double> Pid;

typedef pair<double, int> Pdi;

typedef pair<ll, int> Pl;

typedef pair<int, pair<int, int>> PP;

const double PI = 3.1415926535897932;   // acos(-1)

const double EPS = 1e-15;

const int INF = 1001001001;

const int mod = 1e+9 + 7;



#define chmax(x, y) x = max(x, y)

#define chmin(x, y) x = min(x, y)

#define chadd(x, y) x = (x + y) % mod



struct edge{

    int v;

    ll cost;

    edge() = default;

    edge(int v, ll cost) : v(v), cost(cost) {}

};

vector<edge> graph[100005];

vector<int> coloring(100005, -1);



void dfs(int u, int color = 0, int parent = -1){

    coloring[u] = color;



    for(int i = 0; i < graph[u].size(); ++i){

        int v = graph[u][i].v;

        if(v == parent) continue;

        ll cost = graph[u][i].cost;

        if(cost % 2 == 0)   dfs(v, color, u);

        else    dfs(v, color ^ 1, u);

    }

}



int main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);



    int n;

    cin >> n;

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

        int u, v;

        ll w;

        cin >> u >> v >> w;

        --u, --v;

        graph[u].push_back(edge(v, w));

        graph[v].push_back(edge(u, w));

    }

    dfs(0);

    for(int i = 0; i < n; ++i)  cout << coloring[i] << "\n";

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <vector>

#include <algorithm>

#include <cmath>

#include <queue>

#include <string>

#include <map>

#include <set>

#include <stack>

#include <tuple>

#include <deque>

#include <numeric>

#include <bitset>

#include <iomanip>

#include <cassert>

#include <chrono>

#include <random>

#include <limits>

#include <iterator>

#include <functional>

#include <sstream>

#include <complex>

using namespace std;



typedef long long ll;

typedef uint64_t ull;

typedef pair<int, int> P;

constexpr double EPS = 1e-9;

constexpr int INF = 1001001001;

constexpr int mod = 1000000007;

// constexpr int mod = 998244353;



#define chmax(x, y) x = max(x, y)

#define chmin(x, y) x = min(x, y)



int main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);



    int n;

    cin >> n;

    vector<vector<P>> graph(n);

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

        int u, v, w;

        cin >> u >> v >> w;

        --u, --v;

        graph[u].emplace_back(v, w);

        graph[v].emplace_back(u, w);

    }

    vector<int> coloring(n, -1);

    coloring[0] = 0;

    queue<int> que;

    que.push(0);

    while(!que.empty()){

        int from = que.front();

        que.pop();

        int c = coloring[from];

        for(auto e : graph[from]){

            int to = e.first, cost = e.second;

            if(coloring[to] != -1)  continue;

            if(cost % 2 == 0)   coloring[to] = c;

            else    coloring[to] = c ^ 1;

            que.push(to);

        }

    }

    for(int x : coloring)   cout << x << '\n';

}

// Fastest known solution for this problem: