/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
3
1 2 2
2 3 1
---+/
/+---test
5
2 5 2
2 3 10
1 3 8
3 4 2
---+/

void main(string[] args) {
  const N = readln.chomp.to!long;

  auto edges = new long[][](N, N);
  foreach (i; 0..N-1) {
    long u, v, w;
    readf(" %d %d %d ", &u, &v, &w);
    --u; --v;

    edges[u][v] = w;
    edges[v][u] = w;
  }

  auto inv = new bool[](N);
  auto ans = new bool[](N);
  bool F(long i, long parent) {
    bool decided;
    bool col;
    foreach (c; 0..N) {
      if (c == parent || edges[i][c] == 0) continue;
      const pcol = F(c, i);

      if (col != pcol && decided) {
        assert(!inv[c]);
        inv[c] = true;
      }
      decided = true;
      col     = pcol ^ !!(edges[i][c]%2);
    }
    ans[i] = col;
    return col;
  }
  F(0, -1);

  void G(long i, long parent, bool inverse) {
    ans[i] = ans[i] ^ inverse;
    foreach (c; 0..N) {
      if (c == parent || edges[i][c] == 0) continue;
      G(c, i, inverse ^ inv[c]);
    }
  }
  G(0, -1, inv[0]);

  ans.map!(to!int).each!writeln;
}
