#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

n = I()
graph =[[]*(n+1) for i in range(n+1)]
ans = [0]*(n+1)
for i in range(n-1):
    u,v,w = map(int,input().split())
    w = w%2
    graph[u].append([v,w])
    graph[v].append([u,w])
#vをcに塗る。pはvの親
def dfs(v,p,c,ans):
    ans[v] = c
    for i in graph[v]:
        if i[0] == p:
            continue
        if i[1] == 1:
            dfs(i[0],v,1-c,ans)
        if i[1] == 0:
            dfs(i[0],v,c,ans)
dfs(1,0,0,ans)
for i in ans[1:]:
    print(i) import sys sys sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 import bisect bisect import heapq heapq import itertools itertools import math math from collections import Counter, defaultdict, deque from copy import deepcopy from decimal import Decimal from math import gcd from operator import add, itemgetter, mul, xor def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod cmb bunshi=1 bunshi 1 bunbo=1 bunbo 1 for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
   i range(r) range r bunbo = bunbo*(i+1)%mod bunbo bunbo*(i+1)%mod bunbo*(i+1) bunbo i+1 i 1 mod bunshi = bunshi*(n-i)%mod bunshi bunshi*(n-i)%mod bunshi*(n-i) bunshi n-i n i mod return (bunshi*pow(bunbo,mod-2,mod))%mod (bunshi*pow(bunbo,mod-2,mod))%mod bunshi*pow(bunbo,mod-2,mod) bunshi pow(bunbo,mod-2,mod) pow bunbo mod-2 mod 2 mod mod n n r r mod mod mod = 10**9+7 mod 10**9+7 10**9 10 9 7 def I(): return int(input()) I def LI(): return list(map(int,input().split())) LI def MI(): return map(int,input().split()) MI list(map(int, input().split())) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split def LLI(n): return [list(map(int, input().split())) for _ in range(n)] LLI n n n = I() n I() I []*(n+1) for i in range(n+1) for i in range(n+1) i range(n+1) range n+1 n 1 for i in range(n+1) []*(n+1) [] n+1 n 1 graph =[[]*(n+1) for i in range(n+1)] graph [[]*(n+1) for i in range(n+1)] ans = [0]*(n+1) ans [0]*(n+1) [0] 0 n+1 n 1 for i in range(n-1):
    u,v,w = map(int,input().split())
    w = w%2
    graph[u].append([v,w])
    graph[v].append([u,w])
#vをcに塗る。pはvの親 i range(n-1) range n-1 n 1 u,v,w = map(int,input().split()) u map(int,input().split()) map int input().split() ().split () input split v w w = w%2 w w%2 w 2 graph[u].append([v,w]) [u].append [u] graph u append [v,w] v w graph[v].append([u,w]) [v].append [v] graph v append [u,w] u w def dfs(v,p,c,ans):
    ans[v] = c
    for i in graph[v]:
        if i[0] == p:
            continue
        if i[1] == 1:
            dfs(i[0],v,1-c,ans)
        if i[1] == 0:
            dfs(i[0],v,c,ans) dfs ans[v] = c ans[v] ans v c for i in graph[v]:
        if i[0] == p:
            continue
        if i[1] == 1:
            dfs(i[0],v,1-c,ans)
        if i[1] == 0:
            dfs(i[0],v,c,ans) i graph[v] graph v if i[0] == p:
            continue
         i[0] == p i[0] i 0 p continue if i[1] == 1:
            dfs(i[0],v,1-c,ans)
         i[1] == 1 i[1] i 1 1 dfs(i[0],v,1-c,ans) dfs i[0] i 0 v 1-c 1 c ans if i[1] == 0:
            dfs(i[0],v,c,ans) i[1] == 0 i[1] i 1 0 dfs(i[0],v,c,ans) dfs i[0] i 0 v c ans v v p p c c ans ans dfs(1,0,0,ans) dfs 1 0 0 ans for i in ans[1:]:
    print(i) i ans[1:] ans 1: 1 print(i) print i def I(): return int(input()) def I(): return int(input()) I n = I() I() n graph =[[]*(n+1) for i in range(n+1)] [[]*(n+1) for i in range(n+1)] graph mod = 10**9+7 10**9+7 mod def LI(): return list(map(int,input().split())) def LI(): return list(map(int,input().split())) LI v,w = map(int,input().split()) map(int,input().split()) v def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod cmb w = map(int,input().split()) map(int,input().split()) w w = w%2 w%2 w def MI(): return map(int,input().split()) def MI(): return map(int,input().split()) MI def LLI(n): return [list(map(int, input().split())) for _ in range(n)] def LLI(n): return [list(map(int, input().split())) for _ in range(n)] LLI u,v,w = map(int,input().split()) map(int,input().split()) u def dfs(v,p,c,ans):
    ans[v] = c
    for i in graph[v]:
        if i[0] == p:
            continue
        if i[1] == 1:
            dfs(i[0],v,1-c,ans)
        if i[1] == 0:
            dfs(i[0],v,c,ans) def dfs(v,p,c,ans):
    ans[v] = c
    for i in graph[v]:
        if i[0] == p:
            continue
        if i[1] == 1:
            dfs(i[0],v,1-c,ans)
        if i[1] == 0:
            dfs(i[0],v,c,ans) dfs ans = [0]*(n+1) [0]*(n+1) ans
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

n = I()
graph =[[]*(n+1) for i in range(n+1)]
ans = [0]*(n+1)
for i in range(n-1):
    u,v,w = map(int,input().split())
    w = w%2
    graph[u].append([v,w])
    graph[v].append([u,w])
#vをcに塗る。pはvの親
def dfs(v,p,c,ans):
    ans[v] = c
    for i in graph[v]:
        if i[0] == p:
            continue
        if i[1] == 1:
            dfs(i[0],v,1-c,ans)
        if i[1] == 0:
            dfs(i[0],v,c,ans)
dfs(1,0,0,ans)
for i in ans[1:]:
    print(i)
