import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########

n=int(input())
G=[[] for i in range(n)]
for i in range(n-1):
    a,b,w=map(int,input().split())
    a-=1;b-=1
    G[a].append((b,w))
    G[b].append((a,w))
C=[-1]*n 
C[0]=0
def dfs(x):
    for v,w in G[x]:
        if C[v]==-1:
            C[v]=1-C[x] if w%2==1 else C[x]
            dfs(v)

dfs(0)
# print(G)
for i in range(n):
    print(C[i]) import sys sys mod=10**9+7 mod 10**9+7 10**9 10 9 7 inf=float("inf") inf float("inf") float "inf" from math import sqrt, ceil from collections import deque, Counter, defaultdict input=lambda: sys.stdin.readline().strip() input lambda: sys.stdin.readline().strip() sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip sys.setrecursionlimit(11451419) sys.setrecursionlimit sys setrecursionlimit 11451419 from decimal import ROUND_HALF_UP,Decimal from functools import lru_cache from bisect import bisect_left as bileft, bisect_right as biright 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())
    a-=1;b-=1
    G[a].append((b,w))
    G[b].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 a-=1 a 1 b-=1 b 1 G[a].append((b,w)) [a].append [a] G a append (b,w) b w G[b].append((a,w)) [b].append [b] G b append (a,w) a w C=[-1]*n C [-1]*n [-1] -1 n C[0]=0 C[0] C 0 0 def dfs(x):
    for v,w in G[x]:
        if C[v]==-1:
            C[v]=1-C[x] if w%2==1 else C[x]
            dfs(v) dfs for v,w in G[x]:
        if C[v]==-1:
            C[v]=1-C[x] if w%2==1 else C[x]
            dfs(v) v w G[x] G x if C[v]==-1:
            C[v]=1-C[x] if w%2==1 else C[x]
            dfs(v) C[v]==-1 C[v] C v -1 C[v]=1-C[x] if w%2==1 else C[x] C[v] C v 1-C[x] if w%2==1 else C[x] w%2==1 w%2 w 2 1 1-C[x] 1 C[x] C x C[x] C x dfs(v) dfs v x x dfs(0) dfs 0 for i in range(n):
    print(C[i]) i range(n) range n print(C[i]) print C[i] C i a,b,w=map(int,input().split()) map(int,input().split()) a a-=1 1 a inf=float("inf") float("inf") inf mod=10**9+7 10**9+7 mod b-=1 1 b input=lambda: sys.stdin.readline().strip() lambda: sys.stdin.readline().strip() input w=map(int,input().split()) map(int,input().split()) w C=[-1]*n [-1]*n C n=int(input()) int(input()) n G=[[] for i in range(n)] [[] for i in range(n)] G b,w=map(int,input().split()) map(int,input().split()) b def dfs(x):
    for v,w in G[x]:
        if C[v]==-1:
            C[v]=1-C[x] if w%2==1 else C[x]
            dfs(v) def dfs(x):
    for v,w in G[x]:
        if C[v]==-1:
            C[v]=1-C[x] if w%2==1 else C[x]
            dfs(v) dfs
import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########

n=int(input())
G=[[] for i in range(n)]
for i in range(n-1):
    a,b,w=map(int,input().split())
    a-=1;b-=1
    G[a].append((b,w))
    G[b].append((a,w))
C=[-1]*n 
C[0]=0
def dfs(x):
    for v,w in G[x]:
        if C[v]==-1:
            C[v]=1-C[x] if w%2==1 else C[x]
            dfs(v)

dfs(0)
# print(G)
for i in range(n):
    print(C[i])
