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 uvw = lines.map(i => i.split(" ").map(i => Number(i)))
    var cost = Array(N).fill(Infinity).map(i => i = Array(N).fill(Infinity))

    var d = Array(N).fill("")
    var used = Array(N).fill(false);

    for (var i = 0; i < N; i++) {
        if (i === N - 1) { cost[i][i] = 0 }
        else {
            var u = uvw[i][0]; var v = uvw[i][1]; var w = uvw[i][2]
            cost[u - 1][v - 1] = w;
            cost[v - 1][u - 1] = w;
            cost[i][i] = 0
        }
    }

    var start = 0;
    d[start] = "0";

    while (1) {
        var v = -1;
        for (var i = 0; i < N; i++) {
            if (!used[i] && d[i] !== "") { v = i; break; }
        }
        if (v === -1) { break; }
        used[i] = true;

        for (var i = 0; i < N; i++) {
            if (cost[v][i] % 2 === 0) { d[i] = d[v] }
            if (cost[v][i] % 2 === 1) { d[i] = (d[v] === "0" ? "1" : "0") }
        }
    }
    for (var i = 0; i < d.length; i++){
        console.log(d[i]);
    }
});