class UnionFind():
  def __init__(self, n=10**6):
    self.n = n
    self.root = [-1]*(n+1)
    self.rnk = [0]*(n+1)
  def find(self, x):
    if(self.root[x] < 0):
      return x
    else:
      self.root[x] = self.find(self.root[x])
      return self.root[x]
  def unite(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if(x == y):return 
    elif(self.rnk[x] > self.rnk[y]):
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if(self.rnk[x] == self.rnk[y]):
        self.rnk[y] += 1
  def same(self, x, y):
    return self.find(x) == self.find(y)
  def count(self, x):
    return -self.root[self.find(x)]
uf=UnionFind()
n=int(input())
for _ in range(n-1):
  u,v,w=map(int,input().split())
  if w%2:
    uf.unite(2*u,2*v-1)
    uf.unite(2*u-1,2*v)
  else:
    uf.unite(2*u,2*v)
    uf.unite(2*u-1,2*v-1)
f=uf.find(2*1)
for i in range(1,n+1):
  print(int(uf.find(2*i)==f)) class UnionFind():
  def __init__(self, n=10**6):
    self.n = n
    self.root = [-1]*(n+1)
    self.rnk = [0]*(n+1)
  def find(self, x):
    if(self.root[x] < 0):
      return x
    else:
      self.root[x] = self.find(self.root[x])
      return self.root[x]
  def unite(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if(x == y):return 
    elif(self.rnk[x] > self.rnk[y]):
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if(self.rnk[x] == self.rnk[y]):
        self.rnk[y] += 1
  def same(self, x, y):
    return self.find(x) == self.find(y)
  def count(self, x):
    return -self.root[self.find(x)] UnionFind def __init__(self, n=10**6):
    self.n = n
    self.root = [-1]*(n+1)
    self.rnk = [0]*(n+1)
   __init__ self.n = n self.n self n n self.root = [-1]*(n+1) self.root self root [-1]*(n+1) [-1] -1 n+1 n 1 self.rnk = [0]*(n+1) self.rnk self rnk [0]*(n+1) [0] 0 n+1 n 1 self self n=10**6 n 10**6 10 6 def find(self, x):
    if(self.root[x] < 0):
      return x
    else:
      self.root[x] = self.find(self.root[x])
      return self.root[x]
   find if(self.root[x] < 0):
      return x
    else:
      self.root[x] = self.find(self.root[x])
      return self.root[x]
   self.root[x] < 0 self.root[x] self.root self root x 0 return x x self.root[x] = self.find(self.root[x]) self.root[x] self.root self root x self.find(self.root[x]) self.find self find self.root[x] self.root self root x return self.root[x] self.root[x] self.root self root x self self x x def unite(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if(x == y):return 
    elif(self.rnk[x] > self.rnk[y]):
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if(self.rnk[x] == self.rnk[y]):
        self.rnk[y] += 1
   unite x = self.find(x) x self.find(x) self.find self find x y = self.find(y) y self.find(y) self.find self find y if(x == y):return 
    elif(self.rnk[x] > self.rnk[y]):
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if(self.rnk[x] == self.rnk[y]):
        self.rnk[y] += 1
   x == y x y elif(self.rnk[x] > self.rnk[y]):
      self.root[x] += self.root[y]
      self.root[y] = x
     self.rnk[x] > self.rnk[y] self.rnk[x] self.rnk self rnk x self.rnk[y] self.rnk self rnk y self.root[x] += self.root[y] self.root[x] self.root self root x self.root[y] self.root self root y self.root[y] = x self.root[y] self.root self root y x self.root[y] += self.root[x] self.root[y] self.root self root y self.root[x] self.root self root x self.root[x] = y self.root[x] self.root self root x y if(self.rnk[x] == self.rnk[y]):
        self.rnk[y] += 1
   self.rnk[x] == self.rnk[y] self.rnk[x] self.rnk self rnk x self.rnk[y] self.rnk self rnk y self.rnk[y] += 1 self.rnk[y] self.rnk self rnk y 1 self self x x y y def same(self, x, y):
    return self.find(x) == self.find(y)
   same return self.find(x) == self.find(y) self.find(x) == self.find(y) self.find(x) self.find self find x self.find(y) self.find self find y self self x x y y def count(self, x):
    return -self.root[self.find(x)] count return -self.root[self.find(x)] -self.root[self.find(x)] self.root[self.find(x)] self.root self root self.find(x) self.find self find x self self x x uf=UnionFind() uf UnionFind() UnionFind n=int(input()) n int(input()) int input() input for _ in range(n-1):
  u,v,w=map(int,input().split())
  if w%2:
    uf.unite(2*u,2*v-1)
    uf.unite(2*u-1,2*v)
  else:
    uf.unite(2*u,2*v)
    uf.unite(2*u-1,2*v-1) _ 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 if w%2:
    uf.unite(2*u,2*v-1)
    uf.unite(2*u-1,2*v)
  else:
    uf.unite(2*u,2*v)
    uf.unite(2*u-1,2*v-1) w%2 w 2 uf.unite(2*u,2*v-1) uf.unite uf unite 2*u 2 u 2*v-1 2*v 2 v 1 uf.unite(2*u-1,2*v) uf.unite uf unite 2*u-1 2*u 2 u 1 2*v 2 v uf.unite(2*u,2*v) uf.unite uf unite 2*u 2 u 2*v 2 v uf.unite(2*u-1,2*v-1) uf.unite uf unite 2*u-1 2*u 2 u 1 2*v-1 2*v 2 v 1 f=uf.find(2*1) f uf.find(2*1) uf.find uf find 2*1 2 1 for i in range(1,n+1):
  print(int(uf.find(2*i)==f)) i range(1,n+1) range 1 n+1 n 1 print(int(uf.find(2*i)==f)) print int(uf.find(2*i)==f) int uf.find(2*i)==f uf.find(2*i) uf.find uf find 2*i 2 i f u,v,w=map(int,input().split()) map(int,input().split()) u n=int(input()) int(input()) n w=map(int,input().split()) map(int,input().split()) w uf=UnionFind() UnionFind() uf class UnionFind():
  def __init__(self, n=10**6):
    self.n = n
    self.root = [-1]*(n+1)
    self.rnk = [0]*(n+1)
  def find(self, x):
    if(self.root[x] < 0):
      return x
    else:
      self.root[x] = self.find(self.root[x])
      return self.root[x]
  def unite(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if(x == y):return 
    elif(self.rnk[x] > self.rnk[y]):
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if(self.rnk[x] == self.rnk[y]):
        self.rnk[y] += 1
  def same(self, x, y):
    return self.find(x) == self.find(y)
  def count(self, x):
    return -self.root[self.find(x)] class UnionFind():
  def __init__(self, n=10**6):
    self.n = n
    self.root = [-1]*(n+1)
    self.rnk = [0]*(n+1)
  def find(self, x):
    if(self.root[x] < 0):
      return x
    else:
      self.root[x] = self.find(self.root[x])
      return self.root[x]
  def unite(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if(x == y):return 
    elif(self.rnk[x] > self.rnk[y]):
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if(self.rnk[x] == self.rnk[y]):
        self.rnk[y] += 1
  def same(self, x, y):
    return self.find(x) == self.find(y)
  def count(self, x):
    return -self.root[self.find(x)] UnionFind v,w=map(int,input().split()) map(int,input().split()) v f=uf.find(2*1) uf.find(2*1) f
class UnionFind():
  def __init__(self, n=10**6):
    self.n = n
    self.root = [-1]*(n+1)
    self.rnk = [0]*(n+1)
  def find(self, x):
    if(self.root[x] < 0):
      return x
    else:
      self.root[x] = self.find(self.root[x])
      return self.root[x]
  def unite(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if(x == y):return 
    elif(self.rnk[x] > self.rnk[y]):
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if(self.rnk[x] == self.rnk[y]):
        self.rnk[y] += 1
  def same(self, x, y):
    return self.find(x) == self.find(y)
  def count(self, x):
    return -self.root[self.find(x)]
uf=UnionFind()
n=int(input())
for _ in range(n-1):
  u,v,w=map(int,input().split())
  if w%2:
    uf.unite(2*u,2*v-1)
    uf.unite(2*u-1,2*v)
  else:
    uf.unite(2*u,2*v)
    uf.unite(2*u-1,2*v-1)
f=uf.find(2*1)
for i in range(1,n+1):
  print(int(uf.find(2*i)==f))