import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    long[long][long] V; // V[min(u,v)][max(u,v)] = w
    auto T = new long[][](N);
    foreach (_; 0 .. N - 1)
    {
        long u, v, w;
        scan(u, v, w);
        u--;
        v--;
        T[u] ~= v;
        T[v] ~= u;
        V[min(u, v)][max(u, v)] = w;
    }
    auto ans = new long[](N);
    ans[] = -1;

    PQueue!(Tuple!(long, long), "b<a") Q;
    Q.insert(Tuple!(long, long)(0, 0)); // dist, id
    while (!Q.empty)
    {
        auto u = Q.front;
        Q.removeFront();

        ans[u[1]] = u[0] & 1;

        foreach (v; T[u[1]])
        {
            if (ans[v] == -1)
            {
                Q.insert(Tuple!(long, long)(u[0] + V[min(u[1], v)][max(u[1], v)], v));
            }
        }
    }
    ans.map!(text).join('\n').writeln();
}
