# https://atcoder.jp/contests/abc126/tasks/abc126_d

import heapq
from collections import defaultdict

class Dijkstra:
    def __init__(self, rote_map, start_point, goal_point=None):
        self.rote_map = rote_map
        self.start_point = start_point
        self.goal_point = goal_point

    def execute(self):
        num_of_city = len(self.rote_map)
        dist = [float("inf") for _ in range(num_of_city)]
        prev = [float("inf") for _ in range(num_of_city)]

        dist[self.start_point] = 0
        heap_q = []
        heapq.heappush(heap_q, (0, self.start_point))
        while len(heap_q) > 0:
            prev_cost, src = heapq.heappop(heap_q)

            if dist[src] < prev_cost:
                continue

            for dest, cost in self.rote_map[src].items():
                if cost != float("inf") and dist[dest] > dist[src] + cost:
                    dist[dest] = dist[src] + cost
                    heapq.heappush(heap_q, (dist[dest], dest))
                    prev[dest] = src
        return dist

    def get_path(self, goal, prev):
        path = [goal]
        dest = goal
        while prev[dest] != float("inf"):
            path.append(prev[dest])
            dest = prev[dest]
        return list(reversed(path))

n = int(input())
route_map = [dict() for _ in range(n)]
for i in range(n - 1):
    u, v, wi = map(int, input().split())
    u, v = u - 1, v - 1
    route_map[u][v] = wi
    route_map[v][u] = wi

d = Dijkstra(route_map, 0).execute()
for k in range(n):
    if d[k] % 2 == 0:
        print(0)
    else:
        print(1) import heapq heapq from collections import defaultdict class Dijkstra:
    def __init__(self, rote_map, start_point, goal_point=None):
        self.rote_map = rote_map
        self.start_point = start_point
        self.goal_point = goal_point

    def execute(self):
        num_of_city = len(self.rote_map)
        dist = [float("inf") for _ in range(num_of_city)]
        prev = [float("inf") for _ in range(num_of_city)]

        dist[self.start_point] = 0
        heap_q = []
        heapq.heappush(heap_q, (0, self.start_point))
        while len(heap_q) > 0:
            prev_cost, src = heapq.heappop(heap_q)

            if dist[src] < prev_cost:
                continue

            for dest, cost in self.rote_map[src].items():
                if cost != float("inf") and dist[dest] > dist[src] + cost:
                    dist[dest] = dist[src] + cost
                    heapq.heappush(heap_q, (dist[dest], dest))
                    prev[dest] = src
        return dist

    def get_path(self, goal, prev):
        path = [goal]
        dest = goal
        while prev[dest] != float("inf"):
            path.append(prev[dest])
            dest = prev[dest]
        return list(reversed(path)) Dijkstra def __init__(self, rote_map, start_point, goal_point=None):
        self.rote_map = rote_map
        self.start_point = start_point
        self.goal_point = goal_point

     __init__ self.rote_map = rote_map self.rote_map self rote_map rote_map self.start_point = start_point self.start_point self start_point start_point self.goal_point = goal_point self.goal_point self goal_point goal_point self self rote_map rote_map start_point start_point goal_point=None goal_point None def execute(self):
        num_of_city = len(self.rote_map)
        dist = [float("inf") for _ in range(num_of_city)]
        prev = [float("inf") for _ in range(num_of_city)]

        dist[self.start_point] = 0
        heap_q = []
        heapq.heappush(heap_q, (0, self.start_point))
        while len(heap_q) > 0:
            prev_cost, src = heapq.heappop(heap_q)

            if dist[src] < prev_cost:
                continue

            for dest, cost in self.rote_map[src].items():
                if cost != float("inf") and dist[dest] > dist[src] + cost:
                    dist[dest] = dist[src] + cost
                    heapq.heappush(heap_q, (dist[dest], dest))
                    prev[dest] = src
        return dist

     execute num_of_city = len(self.rote_map) num_of_city len(self.rote_map) len self.rote_map self rote_map float("inf") for _ in range(num_of_city) for _ in range(num_of_city) _ range(num_of_city) range num_of_city for _ in range(num_of_city) float("inf") float "inf" dist = [float("inf") for _ in range(num_of_city)] dist [float("inf") for _ in range(num_of_city)] float("inf") for _ in range(num_of_city) for _ in range(num_of_city) _ range(num_of_city) range num_of_city for _ in range(num_of_city) float("inf") float "inf" prev = [float("inf") for _ in range(num_of_city)] prev [float("inf") for _ in range(num_of_city)] dist[self.start_point] = 0 dist[self.start_point] dist self.start_point self start_point 0 heap_q = [] heap_q [] heapq.heappush(heap_q, (0, self.start_point)) heapq.heappush heapq heappush heap_q (0, self.start_point) 0 self.start_point self start_point while len(heap_q) > 0:
            prev_cost, src = heapq.heappop(heap_q)

            if dist[src] < prev_cost:
                continue

            for dest, cost in self.rote_map[src].items():
                if cost != float("inf") and dist[dest] > dist[src] + cost:
                    dist[dest] = dist[src] + cost
                    heapq.heappush(heap_q, (dist[dest], dest))
                    prev[dest] = src
         len(heap_q) > 0 len(heap_q) len heap_q 0 prev_cost, src = heapq.heappop(heap_q) prev_cost heapq.heappop(heap_q) heapq.heappop heapq heappop heap_q src if dist[src] < prev_cost:
                continue

             dist[src] < prev_cost dist[src] dist src prev_cost continue for dest, cost in self.rote_map[src].items():
                if cost != float("inf") and dist[dest] > dist[src] + cost:
                    dist[dest] = dist[src] + cost
                    heapq.heappush(heap_q, (dist[dest], dest))
                    prev[dest] = src
         dest cost self.rote_map[src].items() self.rote_map[src].items self.rote_map[src] self.rote_map self rote_map src items if cost != float("inf") and dist[dest] > dist[src] + cost:
                    dist[dest] = dist[src] + cost
                    heapq.heappush(heap_q, (dist[dest], dest))
                    prev[dest] = src
         cost != float("inf") and dist[dest] > dist[src] + cost cost != float("inf") cost float("inf") float "inf" dist[dest] > dist[src] + cost dist[dest] dist dest dist[src] + cost dist[src] dist src cost dist[dest] = dist[src] + cost dist[dest] dist dest dist[src] + cost dist[src] dist src cost heapq.heappush(heap_q, (dist[dest], dest)) heapq.heappush heapq heappush heap_q (dist[dest], dest) dist[dest] dist dest dest prev[dest] = src prev[dest] prev dest src return dist dist self self def get_path(self, goal, prev):
        path = [goal]
        dest = goal
        while prev[dest] != float("inf"):
            path.append(prev[dest])
            dest = prev[dest]
        return list(reversed(path)) get_path path = [goal] path [goal] goal dest = goal dest goal while prev[dest] != float("inf"):
            path.append(prev[dest])
            dest = prev[dest]
         prev[dest] != float("inf") prev[dest] prev dest float("inf") float "inf" path.append(prev[dest]) path.append path append prev[dest] prev dest dest = prev[dest] dest prev[dest] prev dest return list(reversed(path)) list(reversed(path)) list reversed(path) reversed path self self goal goal prev prev n = int(input()) n int(input()) int input() input dict() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) dict() dict route_map = [dict() for _ in range(n)] route_map [dict() for _ in range(n)] for i in range(n - 1):
    u, v, wi = map(int, input().split())
    u, v = u - 1, v - 1
    route_map[u][v] = wi
    route_map[v][u] = wi i range(n - 1) range n - 1 n 1 u, v, wi = map(int, input().split()) u map(int, input().split()) map int input().split() ().split () input split v wi u, v = u - 1, v - 1 u u - 1 u 1 v v - 1 v 1 route_map[u][v] = wi route_map[u][v] [u] route_map u v wi route_map[v][u] = wi route_map[v][u] [v] route_map v u wi d = Dijkstra(route_map, 0).execute() d Dijkstra(route_map, 0).execute() (route_map, 0).execute (route_map, 0) Dijkstra route_map 0 execute for k in range(n):
    if d[k] % 2 == 0:
        print(0)
    else:
        print(1) k range(n) range n if d[k] % 2 == 0:
        print(0)
    else:
        print(1) d[k] % 2 == 0 d[k] % 2 d[k] d k 2 0 print(0) print 0 print(1) print 1 v, wi = map(int, input().split()) map(int, input().split()) v d = Dijkstra(route_map, 0).execute() Dijkstra(route_map, 0).execute() d class Dijkstra:
    def __init__(self, rote_map, start_point, goal_point=None):
        self.rote_map = rote_map
        self.start_point = start_point
        self.goal_point = goal_point

    def execute(self):
        num_of_city = len(self.rote_map)
        dist = [float("inf") for _ in range(num_of_city)]
        prev = [float("inf") for _ in range(num_of_city)]

        dist[self.start_point] = 0
        heap_q = []
        heapq.heappush(heap_q, (0, self.start_point))
        while len(heap_q) > 0:
            prev_cost, src = heapq.heappop(heap_q)

            if dist[src] < prev_cost:
                continue

            for dest, cost in self.rote_map[src].items():
                if cost != float("inf") and dist[dest] > dist[src] + cost:
                    dist[dest] = dist[src] + cost
                    heapq.heappush(heap_q, (dist[dest], dest))
                    prev[dest] = src
        return dist

    def get_path(self, goal, prev):
        path = [goal]
        dest = goal
        while prev[dest] != float("inf"):
            path.append(prev[dest])
            dest = prev[dest]
        return list(reversed(path)) class Dijkstra:
    def __init__(self, rote_map, start_point, goal_point=None):
        self.rote_map = rote_map
        self.start_point = start_point
        self.goal_point = goal_point

    def execute(self):
        num_of_city = len(self.rote_map)
        dist = [float("inf") for _ in range(num_of_city)]
        prev = [float("inf") for _ in range(num_of_city)]

        dist[self.start_point] = 0
        heap_q = []
        heapq.heappush(heap_q, (0, self.start_point))
        while len(heap_q) > 0:
            prev_cost, src = heapq.heappop(heap_q)

            if dist[src] < prev_cost:
                continue

            for dest, cost in self.rote_map[src].items():
                if cost != float("inf") and dist[dest] > dist[src] + cost:
                    dist[dest] = dist[src] + cost
                    heapq.heappush(heap_q, (dist[dest], dest))
                    prev[dest] = src
        return dist

    def get_path(self, goal, prev):
        path = [goal]
        dest = goal
        while prev[dest] != float("inf"):
            path.append(prev[dest])
            dest = prev[dest]
        return list(reversed(path)) Dijkstra wi = map(int, input().split()) map(int, input().split()) wi u, v = u - 1, v - 1 u - 1 u v = u - 1, v - 1 v - 1 v u, v, wi = map(int, input().split()) map(int, input().split()) u n = int(input()) int(input()) n route_map = [dict() for _ in range(n)] [dict() for _ in range(n)] route_map
# https://atcoder.jp/contests/abc126/tasks/abc126_d

import heapq
from collections import defaultdict

class Dijkstra:
    def __init__(self, rote_map, start_point, goal_point=None):
        self.rote_map = rote_map
        self.start_point = start_point
        self.goal_point = goal_point

    def execute(self):
        num_of_city = len(self.rote_map)
        dist = [float("inf") for _ in range(num_of_city)]
        prev = [float("inf") for _ in range(num_of_city)]

        dist[self.start_point] = 0
        heap_q = []
        heapq.heappush(heap_q, (0, self.start_point))
        while len(heap_q) > 0:
            prev_cost, src = heapq.heappop(heap_q)

            if dist[src] < prev_cost:
                continue

            for dest, cost in self.rote_map[src].items():
                if cost != float("inf") and dist[dest] > dist[src] + cost:
                    dist[dest] = dist[src] + cost
                    heapq.heappush(heap_q, (dist[dest], dest))
                    prev[dest] = src
        return dist

    def get_path(self, goal, prev):
        path = [goal]
        dest = goal
        while prev[dest] != float("inf"):
            path.append(prev[dest])
            dest = prev[dest]
        return list(reversed(path))

n = int(input())
route_map = [dict() for _ in range(n)]
for i in range(n - 1):
    u, v, wi = map(int, input().split())
    u, v = u - 1, v - 1
    route_map[u][v] = wi
    route_map[v][u] = wi

d = Dijkstra(route_map, 0).execute()
for k in range(n):
    if d[k] % 2 == 0:
        print(0)
    else:
        print(1)