class Tree(): #weighted
    def __init__(self, n, edge, indexed=1):
        self.n = n
        self.tree = [[] for _ in range(n)]
        for e in edge:
            self.tree[e[0] - indexed].append((e[1] - indexed, e[2]))
            self.tree[e[1] - indexed].append((e[0] - indexed, e[2]))

    def setroot(self, root):
        self.root = root
        self.parent = [None for _ in range(self.n)]
        self.parent[root] = -1
        self.depth = [None for _ in range(self.n)]
        self.depth[root] = 0
        self.distance = [None for _ in range(self.n)]
        self.distance[root] = 0
        self.order = []
        self.order.append(root)
        self.cost = [0 for _ in range(self.n)]
        self.size = [1 for _ in range(self.n)]
        stack = [root]
        while stack:
            node = stack.pop()
            for adj, cost in self.tree[node]:
                if self.parent[adj] is None:
                    self.parent[adj] = node
                    self.depth[adj] = self.depth[node] + 1
                    self.distance[adj] = self.distance[node] + cost
                    self.cost[adj] = cost
                    self.order.append(adj)
                    stack.append(adj)
        for node in self.order[::-1]:
            for adj, cost in self.tree[node]:
                if self.parent[node] == adj:
                    continue
                self.size[node] += self.size[adj]

import sys
input = sys.stdin.readline

N = int(input())
E = [tuple(map(int, input().split())) for _ in range(N - 1)]
t = Tree(N, E)
t.setroot(0)

for i in range(N):
    if t.distance[i] % 2 == 0:
        print(0)
    else:
        print(1) class Tree(): #weighted
    def __init__(self, n, edge, indexed=1):
        self.n = n
        self.tree = [[] for _ in range(n)]
        for e in edge:
            self.tree[e[0] - indexed].append((e[1] - indexed, e[2]))
            self.tree[e[1] - indexed].append((e[0] - indexed, e[2]))

    def setroot(self, root):
        self.root = root
        self.parent = [None for _ in range(self.n)]
        self.parent[root] = -1
        self.depth = [None for _ in range(self.n)]
        self.depth[root] = 0
        self.distance = [None for _ in range(self.n)]
        self.distance[root] = 0
        self.order = []
        self.order.append(root)
        self.cost = [0 for _ in range(self.n)]
        self.size = [1 for _ in range(self.n)]
        stack = [root]
        while stack:
            node = stack.pop()
            for adj, cost in self.tree[node]:
                if self.parent[adj] is None:
                    self.parent[adj] = node
                    self.depth[adj] = self.depth[node] + 1
                    self.distance[adj] = self.distance[node] + cost
                    self.cost[adj] = cost
                    self.order.append(adj)
                    stack.append(adj)
        for node in self.order[::-1]:
            for adj, cost in self.tree[node]:
                if self.parent[node] == adj:
                    continue
                self.size[node] += self.size[adj] Tree def __init__(self, n, edge, indexed=1):
        self.n = n
        self.tree = [[] for _ in range(n)]
        for e in edge:
            self.tree[e[0] - indexed].append((e[1] - indexed, e[2]))
            self.tree[e[1] - indexed].append((e[0] - indexed, e[2]))

     __init__ self.n = n self.n self n n [] for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) [] self.tree = [[] for _ in range(n)] self.tree self tree [[] for _ in range(n)] for e in edge:
            self.tree[e[0] - indexed].append((e[1] - indexed, e[2]))
            self.tree[e[1] - indexed].append((e[0] - indexed, e[2]))

     e edge self.tree[e[0] - indexed].append((e[1] - indexed, e[2])) self.tree[e[0] - indexed].append self.tree[e[0] - indexed] self.tree self tree e[0] - indexed e[0] e 0 indexed append (e[1] - indexed, e[2]) e[1] - indexed e[1] e 1 indexed e[2] e 2 self.tree[e[1] - indexed].append((e[0] - indexed, e[2])) self.tree[e[1] - indexed].append self.tree[e[1] - indexed] self.tree self tree e[1] - indexed e[1] e 1 indexed append (e[0] - indexed, e[2]) e[0] - indexed e[0] e 0 indexed e[2] e 2 self self n n edge edge indexed=1 indexed 1 def setroot(self, root):
        self.root = root
        self.parent = [None for _ in range(self.n)]
        self.parent[root] = -1
        self.depth = [None for _ in range(self.n)]
        self.depth[root] = 0
        self.distance = [None for _ in range(self.n)]
        self.distance[root] = 0
        self.order = []
        self.order.append(root)
        self.cost = [0 for _ in range(self.n)]
        self.size = [1 for _ in range(self.n)]
        stack = [root]
        while stack:
            node = stack.pop()
            for adj, cost in self.tree[node]:
                if self.parent[adj] is None:
                    self.parent[adj] = node
                    self.depth[adj] = self.depth[node] + 1
                    self.distance[adj] = self.distance[node] + cost
                    self.cost[adj] = cost
                    self.order.append(adj)
                    stack.append(adj)
        for node in self.order[::-1]:
            for adj, cost in self.tree[node]:
                if self.parent[node] == adj:
                    continue
                self.size[node] += self.size[adj] setroot self.root = root self.root self root root None for _ in range(self.n) for _ in range(self.n) _ range(self.n) range self.n self n for _ in range(self.n) None self.parent = [None for _ in range(self.n)] self.parent self parent [None for _ in range(self.n)] self.parent[root] = -1 self.parent[root] self.parent self parent root -1 None for _ in range(self.n) for _ in range(self.n) _ range(self.n) range self.n self n for _ in range(self.n) None self.depth = [None for _ in range(self.n)] self.depth self depth [None for _ in range(self.n)] self.depth[root] = 0 self.depth[root] self.depth self depth root 0 None for _ in range(self.n) for _ in range(self.n) _ range(self.n) range self.n self n for _ in range(self.n) None self.distance = [None for _ in range(self.n)] self.distance self distance [None for _ in range(self.n)] self.distance[root] = 0 self.distance[root] self.distance self distance root 0 self.order = [] self.order self order [] self.order.append(root) self.order.append self.order self order append root 0 for _ in range(self.n) for _ in range(self.n) _ range(self.n) range self.n self n for _ in range(self.n) 0 self.cost = [0 for _ in range(self.n)] self.cost self cost [0 for _ in range(self.n)] 1 for _ in range(self.n) for _ in range(self.n) _ range(self.n) range self.n self n for _ in range(self.n) 1 self.size = [1 for _ in range(self.n)] self.size self size [1 for _ in range(self.n)] stack = [root] stack [root] root while stack:
            node = stack.pop()
            for adj, cost in self.tree[node]:
                if self.parent[adj] is None:
                    self.parent[adj] = node
                    self.depth[adj] = self.depth[node] + 1
                    self.distance[adj] = self.distance[node] + cost
                    self.cost[adj] = cost
                    self.order.append(adj)
                    stack.append(adj)
         stack node = stack.pop() node stack.pop() stack.pop stack pop for adj, cost in self.tree[node]:
                if self.parent[adj] is None:
                    self.parent[adj] = node
                    self.depth[adj] = self.depth[node] + 1
                    self.distance[adj] = self.distance[node] + cost
                    self.cost[adj] = cost
                    self.order.append(adj)
                    stack.append(adj)
         adj cost self.tree[node] self.tree self tree node if self.parent[adj] is None:
                    self.parent[adj] = node
                    self.depth[adj] = self.depth[node] + 1
                    self.distance[adj] = self.distance[node] + cost
                    self.cost[adj] = cost
                    self.order.append(adj)
                    stack.append(adj)
         self.parent[adj] is None self.parent[adj] self.parent self parent adj None self.parent[adj] = node self.parent[adj] self.parent self parent adj node self.depth[adj] = self.depth[node] + 1 self.depth[adj] self.depth self depth adj self.depth[node] + 1 self.depth[node] self.depth self depth node 1 self.distance[adj] = self.distance[node] + cost self.distance[adj] self.distance self distance adj self.distance[node] + cost self.distance[node] self.distance self distance node cost self.cost[adj] = cost self.cost[adj] self.cost self cost adj cost self.order.append(adj) self.order.append self.order self order append adj stack.append(adj) stack.append stack append adj for node in self.order[::-1]:
            for adj, cost in self.tree[node]:
                if self.parent[node] == adj:
                    continue
                self.size[node] += self.size[adj] node self.order[::-1] self.order self order ::-1 -1 for adj, cost in self.tree[node]:
                if self.parent[node] == adj:
                    continue
                self.size[node] += self.size[adj] adj cost self.tree[node] self.tree self tree node if self.parent[node] == adj:
                    continue
                 self.parent[node] == adj self.parent[node] self.parent self parent node adj continue self.size[node] += self.size[adj] self.size[node] self.size self size node self.size[adj] self.size self size adj self self root root import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N = int(input()) N int(input()) int input() input tuple(map(int, input().split())) for _ in range(N - 1) for _ in range(N - 1) _ range(N - 1) range N - 1 N 1 for _ in range(N - 1) tuple(map(int, input().split())) tuple map(int, input().split()) map int input().split() ().split () input split E = [tuple(map(int, input().split())) for _ in range(N - 1)] E [tuple(map(int, input().split())) for _ in range(N - 1)] t = Tree(N, E) t Tree(N, E) Tree N E t.setroot(0) t.setroot t setroot 0 for i in range(N):
    if t.distance[i] % 2 == 0:
        print(0)
    else:
        print(1) i range(N) range N if t.distance[i] % 2 == 0:
        print(0)
    else:
        print(1) t.distance[i] % 2 == 0 t.distance[i] % 2 t.distance[i] t.distance t distance i 2 0 print(0) print 0 print(1) print 1 class Tree(): #weighted
    def __init__(self, n, edge, indexed=1):
        self.n = n
        self.tree = [[] for _ in range(n)]
        for e in edge:
            self.tree[e[0] - indexed].append((e[1] - indexed, e[2]))
            self.tree[e[1] - indexed].append((e[0] - indexed, e[2]))

    def setroot(self, root):
        self.root = root
        self.parent = [None for _ in range(self.n)]
        self.parent[root] = -1
        self.depth = [None for _ in range(self.n)]
        self.depth[root] = 0
        self.distance = [None for _ in range(self.n)]
        self.distance[root] = 0
        self.order = []
        self.order.append(root)
        self.cost = [0 for _ in range(self.n)]
        self.size = [1 for _ in range(self.n)]
        stack = [root]
        while stack:
            node = stack.pop()
            for adj, cost in self.tree[node]:
                if self.parent[adj] is None:
                    self.parent[adj] = node
                    self.depth[adj] = self.depth[node] + 1
                    self.distance[adj] = self.distance[node] + cost
                    self.cost[adj] = cost
                    self.order.append(adj)
                    stack.append(adj)
        for node in self.order[::-1]:
            for adj, cost in self.tree[node]:
                if self.parent[node] == adj:
                    continue
                self.size[node] += self.size[adj] class Tree(): #weighted
    def __init__(self, n, edge, indexed=1):
        self.n = n
        self.tree = [[] for _ in range(n)]
        for e in edge:
            self.tree[e[0] - indexed].append((e[1] - indexed, e[2]))
            self.tree[e[1] - indexed].append((e[0] - indexed, e[2]))

    def setroot(self, root):
        self.root = root
        self.parent = [None for _ in range(self.n)]
        self.parent[root] = -1
        self.depth = [None for _ in range(self.n)]
        self.depth[root] = 0
        self.distance = [None for _ in range(self.n)]
        self.distance[root] = 0
        self.order = []
        self.order.append(root)
        self.cost = [0 for _ in range(self.n)]
        self.size = [1 for _ in range(self.n)]
        stack = [root]
        while stack:
            node = stack.pop()
            for adj, cost in self.tree[node]:
                if self.parent[adj] is None:
                    self.parent[adj] = node
                    self.depth[adj] = self.depth[node] + 1
                    self.distance[adj] = self.distance[node] + cost
                    self.cost[adj] = cost
                    self.order.append(adj)
                    stack.append(adj)
        for node in self.order[::-1]:
            for adj, cost in self.tree[node]:
                if self.parent[node] == adj:
                    continue
                self.size[node] += self.size[adj] Tree N = int(input()) int(input()) N input = sys.stdin.readline sys.stdin.readline input t = Tree(N, E) Tree(N, E) t E = [tuple(map(int, input().split())) for _ in range(N - 1)] [tuple(map(int, input().split())) for _ in range(N - 1)] E
class Tree(): #weighted
    def __init__(self, n, edge, indexed=1):
        self.n = n
        self.tree = [[] for _ in range(n)]
        for e in edge:
            self.tree[e[0] - indexed].append((e[1] - indexed, e[2]))
            self.tree[e[1] - indexed].append((e[0] - indexed, e[2]))

    def setroot(self, root):
        self.root = root
        self.parent = [None for _ in range(self.n)]
        self.parent[root] = -1
        self.depth = [None for _ in range(self.n)]
        self.depth[root] = 0
        self.distance = [None for _ in range(self.n)]
        self.distance[root] = 0
        self.order = []
        self.order.append(root)
        self.cost = [0 for _ in range(self.n)]
        self.size = [1 for _ in range(self.n)]
        stack = [root]
        while stack:
            node = stack.pop()
            for adj, cost in self.tree[node]:
                if self.parent[adj] is None:
                    self.parent[adj] = node
                    self.depth[adj] = self.depth[node] + 1
                    self.distance[adj] = self.distance[node] + cost
                    self.cost[adj] = cost
                    self.order.append(adj)
                    stack.append(adj)
        for node in self.order[::-1]:
            for adj, cost in self.tree[node]:
                if self.parent[node] == adj:
                    continue
                self.size[node] += self.size[adj]

import sys
input = sys.stdin.readline

N = int(input())
E = [tuple(map(int, input().split())) for _ in range(N - 1)]
t = Tree(N, E)
t.setroot(0)

for i in range(N):
    if t.distance[i] % 2 == 0:
        print(0)
    else:
        print(1)