import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

color=[-1]*100100
G=[[] for _ in range(100100)]

def f(st):
  st_c=color[st]
  for v,d in G[st]:
    if color[v]!=-1:
      continue

    if d%2==0:
      color[v]=st_c
    else:
      color[v]=abs(st_c-1)

    f(v)

def main():
  n=I()
  for _ in range(n-1):
    a,b,c=LI()
    a-=1
    b-=1
    G[a].append((b,c))
    G[b].append((a,c))

  color[0]=0
  f(0)

  for i in range(n):
    print(color[i])

main()
# print(main()) import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy math itertools fractions heapq collections bisect sys queue copy sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 inf=10**20 inf 10**20 10 20 mod=10**9+7 mod 10**9+7 10**9 10 9 7 dd=[(-1,0),(0,1),(1,0),(0,-1)] dd [(-1,0),(0,1),(1,0),(0,-1)] (-1,0) -1 0 (0,1) 0 1 (1,0) 1 0 (0,-1) 0 -1 ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] ddn [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] (-1,0) -1 0 (-1,1) -1 1 (0,1) 0 1 (1,1) 1 1 (1,0) 1 0 (1,-1) 1 -1 (0,-1) 0 -1 (-1,-1) -1 -1 int(x) for x in sys.stdin.readline().split() for x in sys.stdin.readline().split() x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for x in sys.stdin.readline().split() int(x) int x def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()] LI def I(): return int(sys.stdin.readline()) I def F(): return float(sys.stdin.readline()) F def LS(): return sys.stdin.readline().split() LS def S(): return input() S color=[-1]*100100 color [-1]*100100 [-1] -1 100100 [] for _ in range(100100) for _ in range(100100) _ range(100100) range 100100 for _ in range(100100) [] G=[[] for _ in range(100100)] G [[] for _ in range(100100)] def f(st):
  st_c=color[st]
  for v,d in G[st]:
    if color[v]!=-1:
      continue

    if d%2==0:
      color[v]=st_c
    else:
      color[v]=abs(st_c-1)

    f(v) f st_c=color[st] st_c color[st] color st for v,d in G[st]:
    if color[v]!=-1:
      continue

    if d%2==0:
      color[v]=st_c
    else:
      color[v]=abs(st_c-1)

    f(v) v d G[st] G st if color[v]!=-1:
      continue

     color[v]!=-1 color[v] color v -1 continue if d%2==0:
      color[v]=st_c
    else:
      color[v]=abs(st_c-1)

     d%2==0 d%2 d 2 0 color[v]=st_c color[v] color v st_c color[v]=abs(st_c-1) color[v] color v abs(st_c-1) abs st_c-1 st_c 1 f(v) f v st st def main():
  n=I()
  for _ in range(n-1):
    a,b,c=LI()
    a-=1
    b-=1
    G[a].append((b,c))
    G[b].append((a,c))

  color[0]=0
  f(0)

  for i in range(n):
    print(color[i]) main n=I() n I() I for _ in range(n-1):
    a,b,c=LI()
    a-=1
    b-=1
    G[a].append((b,c))
    G[b].append((a,c))

   _ range(n-1) range n-1 n 1 a,b,c=LI() a LI() LI b c a-=1 a 1 b-=1 b 1 G[a].append((b,c)) [a].append [a] G a append (b,c) b c G[b].append((a,c)) [b].append [b] G b append (a,c) a c color[0]=0 color[0] color 0 0 f(0) f 0 for i in range(n):
    print(color[i]) i range(n) range n print(color[i]) print color[i] color i main() main inf=10**20 10**20 inf G=[[] for _ in range(100100)] [[] for _ in range(100100)] G def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()] def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()] LI def LS(): return sys.stdin.readline().split() def LS(): return sys.stdin.readline().split() LS dd=[(-1,0),(0,1),(1,0),(0,-1)] [(-1,0),(0,1),(1,0),(0,-1)] dd def f(st):
  st_c=color[st]
  for v,d in G[st]:
    if color[v]!=-1:
      continue

    if d%2==0:
      color[v]=st_c
    else:
      color[v]=abs(st_c-1)

    f(v) def f(st):
  st_c=color[st]
  for v,d in G[st]:
    if color[v]!=-1:
      continue

    if d%2==0:
      color[v]=st_c
    else:
      color[v]=abs(st_c-1)

    f(v) f def F(): return float(sys.stdin.readline()) def F(): return float(sys.stdin.readline()) F def main():
  n=I()
  for _ in range(n-1):
    a,b,c=LI()
    a-=1
    b-=1
    G[a].append((b,c))
    G[b].append((a,c))

  color[0]=0
  f(0)

  for i in range(n):
    print(color[i]) def main():
  n=I()
  for _ in range(n-1):
    a,b,c=LI()
    a-=1
    b-=1
    G[a].append((b,c))
    G[b].append((a,c))

  color[0]=0
  f(0)

  for i in range(n):
    print(color[i]) main def S(): return input() def S(): return input() S mod=10**9+7 10**9+7 mod ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] ddn def I(): return int(sys.stdin.readline()) def I(): return int(sys.stdin.readline()) I color=[-1]*100100 [-1]*100100 color
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

color=[-1]*100100
G=[[] for _ in range(100100)]

def f(st):
  st_c=color[st]
  for v,d in G[st]:
    if color[v]!=-1:
      continue

    if d%2==0:
      color[v]=st_c
    else:
      color[v]=abs(st_c-1)

    f(v)

def main():
  n=I()
  for _ in range(n-1):
    a,b,c=LI()
    a-=1
    b-=1
    G[a].append((b,c))
    G[b].append((a,c))

  color[0]=0
  f(0)

  for i in range(n):
    print(color[i])

main()
# print(main())
