import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;

  auto c = new int[][][](n);
  
  foreach (i; 0..n-1) {
    auto t = readln.chomp.split.to!(int[]);
    auto cost = t[2] % 2 ? 1 : 2;
    auto a = new int[](2);
    a[0] = t[1] - 1;
    a[1] = cost;
    c[t[0]-1] ~= a;
    auto b = new int[](2);
    b[0] = t[0] - 1;
    b[1] = cost;
    c[t[1]-1] ~= b;
  }

  auto res = new int[](n);
  auto f = new bool[](n);

  void solve(int index, int cost) {
    if (f[index]) {
      return;
    }
    f[index] = true;
    res[index] = cost;
    foreach (e; c[index]) {
      solve(e[0], cost + e[1]);
    }
  }

  solve(0, 0);

  writeln("0");
  foreach (i; 1..n) {
    writeln(res[i] % 2);
  }
}
