from collections import deque



def bfs(i):

    q = deque()

    q.append(i)

    c[i] = 1

    while q:

        p = q.popleft()

        f = G[p]

        z = W[p]

        for j in range(len(f)):

            if c[f[j]] == 0:

                q.append(f[j])

                c[f[j]] = 1

                d[f[j]] = d[p] + z[j]

    return



n = int(eval(input()))

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

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

c = [0] * n

d = [0] * n

for _ in range(n - 1):

    u, v, w = list(map(int, input().split()))

    G[u - 1].append(v - 1)

    G[v - 1].append(u - 1)

    W[u - 1].append(w)

    W[v - 1].append(w)

bfs(0)

for i in d:

    print((i % 2))
from collections import deque



def bfs(s):

    global color

    q = deque()

    q.append(s)

    color[s] = 0

    while q:

        i = q.popleft()

        for g in G[i]:

            if color[g[0]] == -1:

                if g[1] % 2 == 0:

                    color[g[0]] = color[i]

                else:

                    color[g[0]] = 1 - color[i]

                q.append(g[0])

    return



n = int(eval(input()))

G = [[] for _ in range(n + 1)]

color = [-1] * (n + 1)

for _ in range(n - 1):

    u, v, w = list(map(int, input().split()))

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

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

bfs(1)

for i in range(1, n + 1):

    print((color[i]))
from collections import deque


def bfs(i):
    q = deque()
    q.append(i)
    c[i] = 1
    while q:
        p = q.popleft()
        f = G[p]
        z = W[p]
        for j in range(len(f)):
            if c[f[j]] == 0:
                q.append(f[j])
                c[f[j]] = 1
                d[f[j]] = d[p] + z[j]
    return


n = int(eval(input()))
G = [[] for _ in range(n)]
W = [[] for _ in range(n)]
c = [0] * n
d = [0] * n
for _ in range(n - 1):
    u, v, w = list(map(int, input().split()))
    G[u - 1].append(v - 1)
    G[v - 1].append(u - 1)
    W[u - 1].append(w)
    W[v - 1].append(w)
bfs(0)
for i in d:
    print((i % 2))

from collections import deque


def bfs(s):
    global color
    q = deque()
    q.append(s)
    color[s] = 0
    while q:
        i = q.popleft()
        for g in G[i]:
            if color[g[0]] == -1:
                if g[1] % 2 == 0:
                    color[g[0]] = color[i]
                else:
                    color[g[0]] = 1 - color[i]
                q.append(g[0])
    return


n = int(eval(input()))
G = [[] for _ in range(n + 1)]
color = [-1] * (n + 1)
for _ in range(n - 1):
    u, v, w = list(map(int, input().split()))
    G[u].append([v, w])
    G[v].append([u, w])
bfs(1)
for i in range(1, n + 1):
    print((color[i]))

-def bfs(i): +def bfs(s): +    global color -    q.append(i) -    c[i] = 1 +    q.append(s) +    color[s] = 0 -        p = q.popleft() -        f = G[p] -        z = W[p] -        for j in range(len(f)): -            if c[f[j]] == 0: -                q.append(f[j]) -                c[f[j]] = 1 -                d[f[j]] = d[p] + z[j] +        i = q.popleft() +        for g in G[i]: +            if color[g[0]] == -1: +                if g[1] % 2 == 0: +                    color[g[0]] = color[i] +                else: +                    color[g[0]] = 1 - color[i] +                q.append(g[0]) -G = [[] for _ in range(n)] -W = [[] for _ in range(n)] -c = [0] * n -d = [0] * n +G = [[] for _ in range(n + 1)] +color = [-1] * (n + 1) -    G[u - 1].append(v - 1) -    G[v - 1].append(u - 1) -    W[u - 1].append(w) -    W[v - 1].append(w) -bfs(0) -for i in d: -    print((i % 2)) +    G[u].append([v, w]) +    G[v].append([u, w]) +bfs(1) +for i in range(1, n + 1): +    print((color[i]))