import sys

sys.setrecursionlimit(10**9)

 

def dfs(now, prev):

    # 今いる頂点から行ける頂点を順に next に入れてループ

    for next, w in g[now]:

        if ans[next] == -1:

            ans[next]=0

            if  w % 2 != 0:

                if ans[now]==0:

                    ans[next]=1

                    dfs(next,now)

                else:

                    ans[next]=0

                    dfs(next,now)

            else:

                ans[next]=ans[now]

                dfs(next,now)

    

 

#木構造の取り込み 

n=int(eval(input()))

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

for i in range(n-1):

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

    u -= 1

    v -= 1

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

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



ans=[-1]*n

ans[0]=0

dfs(0,0)

for i in range(n):

    print((ans[i]))
import sys

input = sys.stdin.readline



n=int(eval(input()))

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



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



for i in range(n-1):

    b[a[i][0]-1].append((a[i][1]-1,a[i][2]))

    b[a[i][1]-1].append((a[i][0]-1,a[i][2]))



import collections

from collections import deque



INF = -10 ** 9

dis = [INF for i in range(n)]

ans = [-1]*n

def bfs(s):

    d = deque()

    d.append(s)

    dis[s]=0

    ans[s]=0

    flag = True



    while len(d):

        x = d.popleft()



        for i in range(len(b[x])):

            y=b[x][i][0]

            if dis[y] == INF:

                d.append(y)

                dis[y]=dis[x]+b[x][i][1]

                if dis[y]%2==0:

                    ans[y]=0

                else:

                    ans[y]=1

    return ans

z=bfs(0)



for i in range(n):

    print((z[i]))

import sys

sys.setrecursionlimit(10**9)


def dfs(now, prev):
    # 今いる頂点から行ける頂点を順に next に入れてループ
    for next, w in g[now]:
        if ans[next] == -1:
            ans[next] = 0
            if w % 2 != 0:
                if ans[now] == 0:
                    ans[next] = 1
                    dfs(next, now)
                else:
                    ans[next] = 0
                    dfs(next, now)
            else:
                ans[next] = ans[now]
                dfs(next, now)


# 木構造の取り込み
n = int(eval(input()))
g = [[] for i in range(n)]
for i in range(n - 1):
    u, v, w = list(map(int, input().split()))
    u -= 1
    v -= 1
    g[u].append([v, w])
    g[v].append([u, w])
ans = [-1] * n
ans[0] = 0
dfs(0, 0)
for i in range(n):
    print((ans[i]))

import sys

input = sys.stdin.readline
n = int(eval(input()))
a = [list(map(int, input().split())) for i in range(n - 1)]
b = [[] for i in range(n)]
for i in range(n - 1):
    b[a[i][0] - 1].append((a[i][1] - 1, a[i][2]))
    b[a[i][1] - 1].append((a[i][0] - 1, a[i][2]))
import collections
from collections import deque

INF = -(10**9)
dis = [INF for i in range(n)]
ans = [-1] * n


def bfs(s):
    d = deque()
    d.append(s)
    dis[s] = 0
    ans[s] = 0
    flag = True
    while len(d):
        x = d.popleft()
        for i in range(len(b[x])):
            y = b[x][i][0]
            if dis[y] == INF:
                d.append(y)
                dis[y] = dis[x] + b[x][i][1]
                if dis[y] % 2 == 0:
                    ans[y] = 0
                else:
                    ans[y] = 1
    return ans


z = bfs(0)
for i in range(n):
    print((z[i]))

-sys.setrecursionlimit(10**9) +input = sys.stdin.readline +n = int(eval(input())) +a = [list(map(int, input().split())) for i in range(n - 1)] +b = [[] for i in range(n)] +for i in range(n - 1): +    b[a[i][0] - 1].append((a[i][1] - 1, a[i][2])) +    b[a[i][1] - 1].append((a[i][0] - 1, a[i][2])) +import collections +from collections import deque + +INF = -(10**9) +dis = [INF for i in range(n)] +ans = [-1] * n -def dfs(now, prev): -    # 今いる頂点から行ける頂点を順に next に入れてループ -    for next, w in g[now]: -        if ans[next] == -1: -            ans[next] = 0 -            if w % 2 != 0: -                if ans[now] == 0: -                    ans[next] = 1 -                    dfs(next, now) +def bfs(s): +    d = deque() +    d.append(s) +    dis[s] = 0 +    ans[s] = 0 +    flag = True +    while len(d): +        x = d.popleft() +        for i in range(len(b[x])): +            y = b[x][i][0] +            if dis[y] == INF: +                d.append(y) +                dis[y] = dis[x] + b[x][i][1] +                if dis[y] % 2 == 0: +                    ans[y] = 0 -                    ans[next] = 0 -                    dfs(next, now) -            else: -                ans[next] = ans[now] -                dfs(next, now) +                    ans[y] = 1 +    return ans -# 木構造の取り込み -n = int(eval(input())) -g = [[] for i in range(n)] -for i in range(n - 1): -    u, v, w = list(map(int, input().split())) -    u -= 1 -    v -= 1 -    g[u].append([v, w]) -    g[v].append([u, w]) -ans = [-1] * n -ans[0] = 0 -dfs(0, 0) +z = bfs(0) -    print((ans[i])) +    print((z[i]))