"use strict";
const stringToIntDecimal = s => parseInt(s);

const readEdgeDataLine = line => {
  const numberArray = line.split(" ").map(stringToIntDecimal);

  return {
    vertexNumberA: numberArray[0],
    vertexNumberB: numberArray[1],
    distance: numberArray[2]
  };
};

const readData = input => {
  const lines = input.split("\n");

  return {
    n: parseInt(lines[0]),
    edges: lines.slice(1).map(readEdgeDataLine)
  };
};

const getVertices = data => {
  const n = data.n;
  const edges = data.edges;
  const vertices = new Array(n + 1);
  for (let i = 1; i <= n; i += 1)
    vertices[i] = {
      color: 0,
      adjacentVertices: []
    };
  const edgeCount = n - 1;

  for (let i = 0; i < edgeCount; i += 1) {
    const edge = edges[i];
    vertices[edge.vertexNumberA].adjacentVertices.push({
      vertex: vertices[edge.vertexNumberB],
      distance: edge.distance
    });
    vertices[edge.vertexNumberB].adjacentVertices.push({
      vertex: vertices[edge.vertexNumberA],
      distance: edge.distance
    });
  }

  return vertices;
};

function colorVertex(vertex, excludingVertex) {
  const neighbors = vertex.adjacentVertices;
  const len = neighbors.length;

  for (let i = 0; i < len; i += 1) {
    const neighbor = neighbors[i];
    const neighborVertex = neighbor.vertex;
    if (neighborVertex === excludingVertex) continue;
    neighborVertex.color = neighbor.distance % 2;
    colorVertex(neighborVertex, vertex);
  }
}

function Main(input) {
  const data = readData(input);
  const vertices = getVertices(data);
  colorVertex(vertices[1]);
  const n = data.n;
  for (let i = 1; i <= n; i += 1) console.log(vertices[i].color);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));