function Stack() {
    this.__a = new Array();
}

Stack.prototype.push = function (o) {
    this.__a.push(o);
}

Stack.prototype.pop = function () {
    if (this.__a.length > 0) {
        return this.__a.pop();
    }
    return null;
}

Stack.prototype.size = function () {
    return this.__a.length;
}

Stack.prototype.toString = function () {
    return '[' + this.__a.join(',') + ']';
}

function main(input) {
    var inputs = input.split("\n")
    var N = parseInt(inputs[0])
    var values = []

    for (var i = 1; i < inputs.length; i++) {
        values.push(inputs[i].split(" ").map(a => parseInt(a)))
    }

    values = values.filter(n => n.length == 3)
    var nodes = []
    for (var n = 1; n < N + 1; n++) {
        nodes.push({
            value: n,
            friends: []
        })
    }

    for (var n = 1; n < N + 1; n++) {
        var node = nodes[n - 1]
        values.map(v => {
            if (v[1] === node.value || v[0] === node.value) {
                if (v[0] < v[1]) {
                    nodes[v[0] - 1].friends.push({ node: nodes[v[1] - 1], dist: v[2] })
                } else {
                    nodes[v[1] - 1].friends.push({ node: nodes[v[0] - 1], dist: v[2] })
                }
            }
        })
    }

    var stack = new Stack();
    nodes[0].friends.map(n => stack.push(n));
    var nakamas = [];

    var current = stack.pop();

    while (stack.length !== 0) {
        if (current == null) {
            break
        }
        if (current.dist % 2 === 0) {
            nakamas.push(current.node.value)
        }

        current.node.friends.map(fr => {
            stack.push({
                node: fr.node,
                dist: fr.dist + current.dist
            })
        })
        current = stack.pop();
    }

    console.log("0")
    for (var n = 1; n < N; n++) {
        var nodeValue = nodes[n].value;

        if (nakamas.indexOf(nodeValue) !== -1) {
            console.log("0");
        } else {
            console.log("1");
        }
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));