import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

alias E = Tuple!(int, "node", int, "w");

void calc(int n, int[][] a) {
    E[][] adj;
    foreach (_; 0..n) adj ~= [[]];
    foreach (e; a) {
        int u = e[0], v = e[1], w = e[2];
        adj[u] ~= E(v, w);
        adj[v] ~= E(u, w);
    }

    auto ans = new int[n];
    void dfs(int node, int prev, int color) {
        ans[node] = color;
        foreach (e; adj[node]) {
            if (e.node == prev) continue; // 逆戻り
            if (e.w % 2 == 0) dfs(e.node, node, color);
            else dfs(e.node, node, color ^ 1);
        }
    }
    dfs(0, -1, 0);

    foreach (c; ans) writeln(c);
}

void main() {
    int n = readint;
    int[][] a;
    for (int i = 0; i < n - 1; i++) {
        auto x = readints;
        a ~= [x[0]-1, x[1]-1, x[2]];
    }
    calc(n, a);
}
