n = int(eval(input()))

Edges = [list(map(int,input().split())) for i in range(n-1)]

for edge in Edges:

    edge[0] -= 1

    edge[1] -= 1

    edge[2] %= 2



Graph = [[] for i in range(n)]

for edge in Edges:

    Graph[edge[0]].append([edge[1],edge[2]])

    Graph[edge[1]].append([edge[0],edge[2]])



Color = [-1 for i in range(n)]

Color[0] = 0



stack = [0]



while stack:

    node = stack.pop()

    for adj in Graph[node]:

        if Color[adj[0]] == -1:

            if adj[1] == 0:

                Color[adj[0]] = Color[node]

            elif Color[node] == 0:

                Color[adj[0]] = 1

            else:

                Color[adj[0]] = 0

            stack.append(adj[0])



for color in Color:

    print(color)

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(eval(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))
n = int(eval(input()))
Edges = [list(map(int, input().split())) for i in range(n - 1)]
for edge in Edges:
    edge[0] -= 1
    edge[1] -= 1
    edge[2] %= 2
Graph = [[] for i in range(n)]
for edge in Edges:
    Graph[edge[0]].append([edge[1], edge[2]])
    Graph[edge[1]].append([edge[0], edge[2]])
Color = [-1 for i in range(n)]
Color[0] = 0
stack = [0]
while stack:
    node = stack.pop()
    for adj in Graph[node]:
        if Color[adj[0]] == -1:
            if adj[1] == 0:
                Color[adj[0]] = Color[node]
            elif Color[node] == 0:
                Color[adj[0]] = 1
            else:
                Color[adj[0]] = 0
            stack.append(adj[0])
for color in Color:
    print(color)

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(eval(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))

-n = int(eval(input())) -Edges = [list(map(int, input().split())) for i in range(n - 1)] -for edge in Edges: -    edge[0] -= 1 -    edge[1] -= 1 -    edge[2] %= 2 -Graph = [[] for i in range(n)] -for edge in Edges: -    Graph[edge[0]].append([edge[1], edge[2]]) -    Graph[edge[1]].append([edge[0], edge[2]]) -Color = [-1 for i in range(n)] -Color[0] = 0 -stack = [0] -while stack: -    node = stack.pop() -    for adj in Graph[node]: -        if Color[adj[0]] == -1: -            if adj[1] == 0: -                Color[adj[0]] = Color[node] -            elif Color[node] == 0: -                Color[adj[0]] = 1 -            else: -                Color[adj[0]] = 0 -            stack.append(adj[0]) -for color in Color: -    print(color) +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(eval(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))