import sys

sys.setrecursionlimit(10 ** 6)



n = int(eval(input()))

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



g = [[] for _ in range(n)]



for u, v, w in uvw:

    u -= 1

    v -= 1

    g[u].append([v, w])

    g[v].append([u, w])





WHITE = 0

GRAY = 1

BLACK = 2



ds = [0] * n

colors = [WHITE] * n





def dfs(u):

    if colors[u] == BLACK:

        return



    colors[u] = GRAY



    for v, w in g[u]:

        if colors[v] == WHITE:

            ds[v] = ds[u] + w

            dfs(v)



    colors[u] = BLACK





dfs(0)



for d in ds:

    print((d % 2))

import sys

sys.setrecursionlimit(10 ** 6)





class Tree:

    WHITE = 0

    GRAY = 1

    BLACK = 2



    def __init__(self, adj):

        n = len(adj)

        self.adj = adj

        self.colors = [self.WHITE] * n

        self.depths = [-1] * n

        self.depth = 0



    def dfs(self, u):

        if self.colors[u] == self.BLACK:

            return



        self.colors[u] = self.GRAY

        self.depths[u] = self.depth



        for v, w in self.adj[u]:

            if self.colors[v] == self.WHITE:

                self.depth += w

                self.dfs(v)

                self.depth -= w



        self.colors[u] = self.BLACK





if __name__ == "__main__":

    n = int(input())

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



    g = [[] for _ in range(n)]



    for u, v, w in uvw:

        u -= 1

        v -= 1

        g[u].append((v, w))

        g[v].append((u, w))



    tree = Tree(g)

    tree.dfs(0)

    ans = [x % 2 for x in tree.depths]

    print(*ans, sep="\n")

import sys

sys.setrecursionlimit(10**6)
n = int(eval(input()))
uvw = [list(map(int, input().split())) for _ in range(n - 1)]
g = [[] for _ in range(n)]
for u, v, w in uvw:
    u -= 1
    v -= 1
    g[u].append([v, w])
    g[v].append([u, w])
WHITE = 0
GRAY = 1
BLACK = 2
ds = [0] * n
colors = [WHITE] * n


def dfs(u):
    if colors[u] == BLACK:
        return
    colors[u] = GRAY
    for v, w in g[u]:
        if colors[v] == WHITE:
            ds[v] = ds[u] + w
            dfs(v)
    colors[u] = BLACK


dfs(0)
for d in ds:
    print((d % 2))

import sys

sys.setrecursionlimit(10**6)


class Tree:
    WHITE = 0
    GRAY = 1
    BLACK = 2

    def __init__(self, adj):
        n = len(adj)
        self.adj = adj
        self.colors = [self.WHITE] * n
        self.depths = [-1] * n
        self.depth = 0

    def dfs(self, u):
        if self.colors[u] == self.BLACK:
            return
        self.colors[u] = self.GRAY
        self.depths[u] = self.depth
        for v, w in self.adj[u]:
            if self.colors[v] == self.WHITE:
                self.depth += w
                self.dfs(v)
                self.depth -= w
        self.colors[u] = self.BLACK


if __name__ == "__main__":
    n = int(input())
    uvw = [list(map(int, input().split())) for _ in range(n - 1)]
    g = [[] for _ in range(n)]
    for u, v, w in uvw:
        u -= 1
        v -= 1
        g[u].append((v, w))
        g[v].append((u, w))
    tree = Tree(g)
    tree.dfs(0)
    ans = [x % 2 for x in tree.depths]
    print(*ans, sep="\n")

-n = int(eval(input())) -uvw = [list(map(int, input().split())) for _ in range(n - 1)] -g = [[] for _ in range(n)] -for u, v, w in uvw: -    u -= 1 -    v -= 1 -    g[u].append([v, w]) -    g[v].append([u, w]) -WHITE = 0 -GRAY = 1 -BLACK = 2 -ds = [0] * n -colors = [WHITE] * n -def dfs(u): -    if colors[u] == BLACK: -        return -    colors[u] = GRAY -    for v, w in g[u]: -        if colors[v] == WHITE: -            ds[v] = ds[u] + w -            dfs(v) -    colors[u] = BLACK +class Tree: +    WHITE = 0 +    GRAY = 1 +    BLACK = 2 + +    def __init__(self, adj): +        n = len(adj) +        self.adj = adj +        self.colors = [self.WHITE] * n +        self.depths = [-1] * n +        self.depth = 0 + +    def dfs(self, u): +        if self.colors[u] == self.BLACK: +            return +        self.colors[u] = self.GRAY +        self.depths[u] = self.depth +        for v, w in self.adj[u]: +            if self.colors[v] == self.WHITE: +                self.depth += w +                self.dfs(v) +                self.depth -= w +        self.colors[u] = self.BLACK -dfs(0) -for d in ds: -    print((d % 2)) +if __name__ == "__main__": +    n = int(input()) +    uvw = [list(map(int, input().split())) for _ in range(n - 1)] +    g = [[] for _ in range(n)] +    for u, v, w in uvw: +        u -= 1 +        v -= 1 +        g[u].append((v, w)) +        g[v].append((u, w)) +    tree = Tree(g) +    tree.dfs(0) +    ans = [x % 2 for x in tree.depths] +    print(*ans, sep="\n")