import sys
sys.setrecursionlimit(500*500)
n = int(input())
l = [list(map(int,input().split())) for _ in range(n-1)]
g = [[] for _ in range(n)]

for i in l:
    v = i[0]-1
    y = i[1]-1
    w = i[2]
    g[v].append([y,w])
    g[y].append([v,w])

seen = [0] + [-1] * (n-1)

def dfs(s):
    for k in g[s]:
        v,w = k[0],k[1]
        if seen[v]!=-1:continue
        seen[v] = seen[s]^(w%2)
        dfs(v)
        
dfs(0)

for i in seen:
    print(i) import sys sys sys.setrecursionlimit(500*500) sys.setrecursionlimit sys setrecursionlimit 500*500 500 500 n = int(input()) n int(input()) int input() input list(map(int,input().split())) for _ in range(n-1) for _ in range(n-1) _ range(n-1) range n-1 n 1 for _ in range(n-1) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split l = [list(map(int,input().split())) for _ in range(n-1)] l [list(map(int,input().split())) for _ in range(n-1)] [] for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) [] g = [[] for _ in range(n)] g [[] for _ in range(n)] for i in l:
    v = i[0]-1
    y = i[1]-1
    w = i[2]
    g[v].append([y,w])
    g[y].append([v,w]) i l v = i[0]-1 v i[0]-1 i[0] i 0 1 y = i[1]-1 y i[1]-1 i[1] i 1 1 w = i[2] w i[2] i 2 g[v].append([y,w]) [v].append [v] g v append [y,w] y w g[y].append([v,w]) [y].append [y] g y append [v,w] v w seen = [0] + [-1] * (n-1) seen [0] + [-1] * (n-1) [0] 0 [-1] * (n-1) [-1] -1 n-1 n 1 def dfs(s):
    for k in g[s]:
        v,w = k[0],k[1]
        if seen[v]!=-1:continue
        seen[v] = seen[s]^(w%2)
        dfs(v)
         dfs for k in g[s]:
        v,w = k[0],k[1]
        if seen[v]!=-1:continue
        seen[v] = seen[s]^(w%2)
        dfs(v)
         k g[s] g s v,w = k[0],k[1] v k[0] k 0 w k[1] k 1 if seen[v]!=-1:continue
         seen[v]!=-1 seen[v] seen v -1 seen[v] = seen[s]^(w%2) seen[v] seen v seen[s]^(w%2) seen[s] seen s w%2 w 2 dfs(v) dfs v s s dfs(0) dfs 0 for i in seen:
    print(i) i seen print(i) print i n = int(input()) int(input()) n y = i[1]-1 i[1]-1 y v = i[0]-1 i[0]-1 v w = i[2] i[2] w seen = [0] + [-1] * (n-1) [0] + [-1] * (n-1) seen def dfs(s):
    for k in g[s]:
        v,w = k[0],k[1]
        if seen[v]!=-1:continue
        seen[v] = seen[s]^(w%2)
        dfs(v)
         def dfs(s):
    for k in g[s]:
        v,w = k[0],k[1]
        if seen[v]!=-1:continue
        seen[v] = seen[s]^(w%2)
        dfs(v)
         dfs g = [[] for _ in range(n)] [[] for _ in range(n)] g l = [list(map(int,input().split())) for _ in range(n-1)] [list(map(int,input().split())) for _ in range(n-1)] l
import sys
sys.setrecursionlimit(500*500)
n = int(input())
l = [list(map(int,input().split())) for _ in range(n-1)]
g = [[] for _ in range(n)]

for i in l:
    v = i[0]-1
    y = i[1]-1
    w = i[2]
    g[v].append([y,w])
    g[y].append([v,w])

seen = [0] + [-1] * (n-1)

def dfs(s):
    for k in g[s]:
        v,w = k[0],k[1]
        if seen[v]!=-1:continue
        seen[v] = seen[s]^(w%2)
        dfs(v)
        
dfs(0)

for i in seen:
    print(i)