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, n);
  foreach (i; 0..n) {
    c[i][] = int.max/2 - 1;
  }
  
  foreach (i; 0..n-1) {
    auto t = readln.chomp.split.to!(int[]);
    auto cost = t[2] % 2 ? 1 : 2;
    c[t[0]-1][t[1]-1] = cost;
    c[t[1]-1][t[0]-1] = cost;
  }
  
  foreach (k; 0..n) {
    foreach (i; 0..n) {
      foreach (j; 0..n) {
        if (i == j) continue;
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    } 
  }

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