using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC126D
{
    class Program
    {
        class PriorityQueue<T> where T : IComparable<T>
        {
            List<T> Heap;
            Func<T, T, bool> compare;

            public PriorityQueue(int capacity, bool isMinHeap = true)
            {
                this.Heap = new List<T>(capacity);

                if (isMinHeap)
                {
                    compare = (x, y) => x.CompareTo(y) < 0;
                }
                else
                {
                    compare = (x, y) => x.CompareTo(y) > 0;
                }
            }

            public PriorityQueue() : this(0) { }

            static void pushHeap(List<T> heap, Func<T, T, bool> compare, T item)
            {
                var n = heap.Count();
                heap.Add(item);

                while (n != 0)
                {
                    var parent = (n - 1) / 2;

                    if (compare(heap[n], heap[parent]))
                    {
                        var temp = heap[n];
                        heap[n] = heap[parent];
                        heap[parent] = temp;
                    }

                    n = parent;
                }
            }

            static T popHeap(List<T> heap, Func<T, T, bool> compare)
            {
                if (!heap.Any())
                {
                    throw new Exception();
                }
                var item = heap[0];

                var n = heap.Count() - 1;
                heap[0] = heap.Last();
                heap.RemoveAt(n);

                var parent = 0;
                var child = 2 * parent + 1;
                while (child < n)
                {
                    if ((child != n - 1) && compare(heap[child + 1], heap[child]))
                    {
                        child++;
                    }

                    if (compare(heap[child], heap[parent]))
                    {
                        var temp = heap[parent];
                        heap[parent] = heap[child];
                        heap[child] = temp;
                    }

                    parent = child;
                    child = 2 * parent + 1;
                }

                return item;
            }

            /// <summary>
            /// 要素追加
            /// </summary>
            /// <param name="item"></param>
            public void Push(T item)
            {
                pushHeap(this.Heap, this.compare, item);
            }

            /// <summary>
            /// 先頭の値取得し削除する
            /// </summary>
            /// <returns></returns>
            public T Pop()
            {
                return popHeap(this.Heap, this.compare);
            }

            /// <summary>
            /// 先頭の値取得（削除はしない）
            /// </summary>
            /// <returns></returns>
            public T Peak()
            {
                if (!this.Heap.Any())
                {
                    throw new Exception();
                }

                return this.Heap[0];
            }

            public bool Any() => this.Heap.Any();

        }

        class Graph
        {
            enum State
            {
                None,
                Detected,
                Finished
            }

            List<Node> Nodes;

            class Edge : IComparable<Edge>
            {
                public Node To;
                public int Cost;

                public Edge(Node to, int cost)
                {
                    this.To = to;
                    this.Cost = cost;
                }

                public int CompareTo(Edge other)
                {
                    return this.Cost - other.Cost;
                }
            }

            class Node
            {
                static readonly int idIgnore = int.MinValue;

                public int Id { get; set; }
                public int GroupId { get; set; }
                public List<Edge> Connection { get; set; }

                public bool HasGroupId { get { return this.GroupId != idIgnore; } }

                public Node(int id)
                {
                    this.Id = id;
                    this.GroupId = idIgnore;
                    this.Connection = new List<Edge>();
                }

                public void Connect(Node node, int cost)
                {
                    this.Connection.Add(new Edge(node, cost));
                }

                public bool Grouping(int groupId)
                {
                    if (this.HasGroupId)
                    {
                        return false;
                    }

                    var q = new Queue<Node>();

                    q.Enqueue(this);
                    while (q.Any())
                    {
                        var node = q.Dequeue();
                        node.GroupId = groupId;

                        foreach (var friend in node.Connection.Select(x => x.To))
                        {
                            if (friend.HasGroupId) continue;

                            friend.GroupId = groupId;
                            q.Enqueue(friend);
                        }
                    }

                    return true;
                }
            }

            public Graph(int capacity)
            {
                this.Nodes = Enumerable.Range(0, capacity)
                    .Select(x => new Node(x)).ToList();
            }

            public void Connect(int from, int to, int cost = 1)
            {
                this.Nodes[from].Connection.Add(new Edge(this.Nodes[to], cost));
                this.Nodes[to].Connection.Add(new Edge(this.Nodes[from], cost));
            }

            public void Grouping()
            {
                var groupId = 0;
                foreach (var node in this.Nodes)
                {
                    if (!node.HasGroupId)
                    {
                        node.Grouping(groupId);
                        groupId++;
                    }
                }
            }

            public List<int> Dijkstra(int s)
            {
                var n = this.Nodes.Count();
                var status = Enumerable.Repeat(State.None, n).ToList();
                // 始点からの最短移動コスト
                var d = Enumerable.Repeat(int.MaxValue, n).ToList();
                var pq = new PriorityQueue<Edge>(n);

                d[s] = 0;
                pq.Push(new Edge(this.Nodes[s], d[s]));
                status[s] = State.Detected;

                while (pq.Any())
                {
                    var f = pq.Pop();
                    var u = f.To.Id;
                    status[u] = State.Finished;

                    // 最小コストノードが祭壇でなければ無視
                    if (d[u] < f.Cost) continue;

                    foreach (var edge in this.Nodes[u].Connection)
                    {
                        var v = edge.To.Id;

                        if (status[v] == State.Finished) continue;
                        if (d[v] <= d[u] + edge.Cost) continue;

                        d[v] = d[u] + edge.Cost;
                        pq.Push(new Edge(edge.To, d[v]));
                        status[v] = State.Detected;
                    }
                }

                return d;
            }
        }

        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = int.Parse(Console.ReadLine());
            var g = new Graph(n);

            while (true)
            {
                var input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) break;

                var nums = input.Split(' ').Select(s => int.Parse(s)).ToList();
                g.Connect(nums[0] - 1, nums[1] - 1, nums[2]);
            }

            var d = g.Dijkstra(0);

            foreach (var i in Enumerable.Range(0, n))
            {
                if ((d[i] % 2) == 0)
                {
                    Console.WriteLine("0");
                }
                else
                {
                    Console.WriteLine("1");
                }
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 41800