var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0]);
    lines.shift();

    var cost = Array(N).fill(Infinity).map(i => i = Array(N + 1).fill(Infinity));

    for (var i = 0; i < N - 1; i++) {
        var t = lines[i].split(" ")
        var u = Number(t[0]); var v = Number(t[1]); var w = Number(t[2]);
        cost[u - 1][0] = u; cost[v - 1][0] = v;
        cost[u - 1][v] = w; cost[v - 1][u] = w;
    }

    // 2頂点間の距離をみて 偶数: 同じ色　　奇数:異なる色で塗る
    // "0"は白　，"1"は黒
    // 頂点0は白とする

    var color = Array(N+1).fill(-1); color[1] = 0;


    while (cost.length) {

        var t = cost.shift(); var j = t[0];
        
        for (var i = 1; i < t.length; i++) {
            if (t[i] === Infinity) { continue; }
            if (color[j] === -1) { cost.push(t) }
            else {
                if (t[i] % 2 === 0) { color[i] = color[j] }
                else { color[i] = 1 - color[j] }
            }
        }
    }
    for (var i = 1; i <= N; i++) { console.log(color[i]); }
});

