import sys
sys.setrecursionlimit(10 ** 6)


N = int(input())
G = [[] for i in range(N)]

for i in range(N-1):
    a,b,w = map(int,input().split())
    G[a-1].append([b,w])
    G[b-1].append([a,w])
S = [-1]*N

def dfs(x,w,c):
    if w%2 !=0:
        c = 1-c
    S[x]=c
    for i in range(len(G[x])):
        x1 = G[x][i][0]-1
        if S[x1] != -1:
            continue
        w1 = G[x][i][1]
        dfs(x1,w1,c)

dfs(G[0][0][0]-1,G[0][0][1],0)
for i in range(N):
    print(S[i]) import sys sys sys.setrecursionlimit(10 ** 6) sys.setrecursionlimit sys setrecursionlimit 10 ** 6 10 6 N = int(input()) N int(input()) int input() input [] for i in range(N) for i in range(N) i range(N) range N for i in range(N) [] G = [[] for i in range(N)] G [[] for i in range(N)] for i in range(N-1):
    a,b,w = map(int,input().split())
    G[a-1].append([b,w])
    G[b-1].append([a,w]) i range(N-1) range N-1 N 1 a,b,w = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b w G[a-1].append([b,w]) [a-1].append [a-1] G a-1 a 1 append [b,w] b w G[b-1].append([a,w]) [b-1].append [b-1] G b-1 b 1 append [a,w] a w S = [-1]*N S [-1]*N [-1] -1 N def dfs(x,w,c):
    if w%2 !=0:
        c = 1-c
    S[x]=c
    for i in range(len(G[x])):
        x1 = G[x][i][0]-1
        if S[x1] != -1:
            continue
        w1 = G[x][i][1]
        dfs(x1,w1,c) dfs if w%2 !=0:
        c = 1-c
     w%2 !=0 w%2 w 2 0 c = 1-c c 1-c 1 c S[x]=c S[x] S x c for i in range(len(G[x])):
        x1 = G[x][i][0]-1
        if S[x1] != -1:
            continue
        w1 = G[x][i][1]
        dfs(x1,w1,c) i range(len(G[x])) range len(G[x]) len G[x] G x x1 = G[x][i][0]-1 x1 G[x][i][0]-1 G[x][i][0] [i] [x] G x i 0 1 if S[x1] != -1:
            continue
         S[x1] != -1 S[x1] S x1 -1 continue w1 = G[x][i][1] w1 G[x][i][1] [i] [x] G x i 1 dfs(x1,w1,c) dfs x1 w1 c x x w w c c dfs(G[0][0][0]-1,G[0][0][1],0) dfs G[0][0][0]-1 G[0][0][0] [0] [0] G 0 0 0 1 G[0][0][1] [0] [0] G 0 0 1 0 for i in range(N):
    print(S[i]) i range(N) range N print(S[i]) print S[i] S i a,b,w = map(int,input().split()) map(int,input().split()) a def dfs(x,w,c):
    if w%2 !=0:
        c = 1-c
    S[x]=c
    for i in range(len(G[x])):
        x1 = G[x][i][0]-1
        if S[x1] != -1:
            continue
        w1 = G[x][i][1]
        dfs(x1,w1,c) def dfs(x,w,c):
    if w%2 !=0:
        c = 1-c
    S[x]=c
    for i in range(len(G[x])):
        x1 = G[x][i][0]-1
        if S[x1] != -1:
            continue
        w1 = G[x][i][1]
        dfs(x1,w1,c) dfs b,w = map(int,input().split()) map(int,input().split()) b N = int(input()) int(input()) N G = [[] for i in range(N)] [[] for i in range(N)] G w = map(int,input().split()) map(int,input().split()) w S = [-1]*N [-1]*N S
import sys
sys.setrecursionlimit(10 ** 6)


N = int(input())
G = [[] for i in range(N)]

for i in range(N-1):
    a,b,w = map(int,input().split())
    G[a-1].append([b,w])
    G[b-1].append([a,w])
S = [-1]*N

def dfs(x,w,c):
    if w%2 !=0:
        c = 1-c
    S[x]=c
    for i in range(len(G[x])):
        x1 = G[x][i][0]-1
        if S[x1] != -1:
            continue
        w1 = G[x][i][1]
        dfs(x1,w1,c)

dfs(G[0][0][0]-1,G[0][0][1],0)
for i in range(N):
    print(S[i])