using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;

namespace Sample
{
    public class Program
    {
        public static void Main(string[] args)
        {
            using (var sc = new SetConsole()) { Solve(); }
        }

        public static void Solve()
        {
            int n = GetString().ToInt();
            // 親、子、距離
            var tree = new Dictionary<int, Dictionary<int, int>>();
                        
            for (int i = 0; i < n - 1; i++)
            {
                var input = GetArray<int>();
                if (tree.ContainsKey(input[0]))
                {
                    tree[input[0]].Add(input[1], input[2]);
                }
                else
                {
                    tree.Add(input[0], new Dictionary<int, int>());
                    tree[input[0]].Add(input[1], input[2]);
                }
                if (tree.ContainsKey(input[1]))
                {
                    tree[input[1]].Add(input[0], input[2]);
                }
                else
                {
                    tree.Add(input[1], new Dictionary<int, int>());
                    tree[input[1]].Add(input[0], input[2]);
                }
            }
            BFS(tree);
        }

        public static void BFS( Dictionary<int, Dictionary<int, int>> tree)
        {
            var colors = new Dictionary<int, int>();
            
            var que = new Queue<int[]>();
            var startNodeIndex = tree.Keys.Min();
            colors.Add(startNodeIndex, 0);
            que.Enqueue(new int[] { startNodeIndex, 0 });
            while (que.Any())
            {
                var tmp = que.Dequeue();
                var keys = tree[tmp[0]].Keys.ToArray();
                foreach (var key in keys)
                {
                    if (colors.ContainsKey(key)) { continue; }
                    tree[tmp[0]][key] += tmp[1];

                    if (tree[tmp[0]][key] % 2 == 0)
                    {
                        colors.Add(key, 0);
                    }
                    else
                    {
                        colors.Add(key, 1);
                    }
                    que.Enqueue(new int[] { key, tree[tmp[0]][key] });
                }
            }
            foreach (var key in colors.Keys.OrderBy(o => o))
            {
                CWrite(colors[key]);
            }
        }

        static void CWrite<T>(T str) => Console.WriteLine(str);
        static string GetString() => Console.ReadLine();
        static T[] GetArray<T>()
        {
            var t = typeof(T);
            var str = Console.ReadLine();

            if (t == typeof(string))
            {
                return (T[])(object)str.Split();
            }
            if (t == typeof(int))
            {
                return (T[])(object)str.ToNumArray<T>();
            }
            if (t == typeof(long))
            {
                return (T[])(object)str.ToNumArray<T>();
            }
            if (t == typeof(double))
            {
                return (T[])(object)str.ToNumArray<T>();
            }
            throw new NotSupportedException($"{t} is not supported.");
        }
    }



    class SetConsole : IDisposable
    {
        readonly StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());
        public SetConsole()
        {
            sw.AutoFlush = false;
            Console.SetOut(sw);
        }
        public void Dispose()
        {
            Console.Out.Flush();
            sw.AutoFlush = true;
            Console.SetOut(sw);
        }
    }

    static class ExtentionsLibrary
    {
        public static T[] CopyArray<T>(this T[] array)
        {
            var newArray = new T[array.Length];
            Array.Copy(array, newArray, array.Length);
            return newArray;
        }
        public static T[,] CopyArray<T>(this T[,] array)
        {
            var firstDimentionLength = array.GetLength(0);
            var secondDimentionLength = array.GetLength(1);
            var newDArray = new T[firstDimentionLength, secondDimentionLength];
            Array.Copy(array, newDArray, firstDimentionLength * secondDimentionLength);
            return newDArray;
        }
        public static T[] ToNumArray<T>(this string str)
        {
            var t = typeof(T);
            if (t == typeof(int))
            {
                return (T[])(object)str.Split().Select(int.Parse).ToArray();
            }
            if (t == typeof(long))
            {
                return (T[])(object)str.Split().Select(long.Parse).ToArray();
            }
            if (t == typeof(double))
            {
                return (T[])(object)str.Split().Select(double.Parse).ToArray();
            }
            throw new NotSupportedException();
        }
        public static int ToInt(this string str) => int.Parse(str);
        public static int ToInt(this char chr) => int.Parse(chr.ToString());
        public static long ToLong(this string str) => long.Parse(str);
        public static DateTime ToDateTime(this string str) => DateTime.Parse(str);
    }
}


Measured memory_bytes: 55036