import sys
sys.setrecursionlimit(2147483647)
input=sys.stdin.readline

def search(nodes, searched, labels, v):
  searched[v] = 1
  label = labels[v]
  for l in nodes[v]:
    x, w = l
    if not searched[x]:
      if w %2 == 0:
        labels[x] = label
      else:
        labels[x] = (label + 1) % 2
      search(nodes, searched, labels, x)

def solve(n, nodes):
  searched = [0]*n
  labels = [None]*n
  labels[0] = 0
  search(nodes, searched, labels, 0)
  return labels

def main():
  n = int(input())
  nodes = [[] for _ in range(n)]
  for _ in range(n-1):
    v, u, w = map(int, input().split(' '))
    nodes[v-1].append((u-1,w))
    nodes[u-1].append((v-1,w))
  ans = solve(n, nodes)
  for r in ans:
    print(r)
  

if __name__=='__main__':
  main() import sys sys sys.setrecursionlimit(2147483647) sys.setrecursionlimit sys setrecursionlimit 2147483647 input=sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def search(nodes, searched, labels, v):
  searched[v] = 1
  label = labels[v]
  for l in nodes[v]:
    x, w = l
    if not searched[x]:
      if w %2 == 0:
        labels[x] = label
      else:
        labels[x] = (label + 1) % 2
      search(nodes, searched, labels, x) search searched[v] = 1 searched[v] searched v 1 label = labels[v] label labels[v] labels v for l in nodes[v]:
    x, w = l
    if not searched[x]:
      if w %2 == 0:
        labels[x] = label
      else:
        labels[x] = (label + 1) % 2
      search(nodes, searched, labels, x) l nodes[v] nodes v x, w = l x l w if not searched[x]:
      if w %2 == 0:
        labels[x] = label
      else:
        labels[x] = (label + 1) % 2
      search(nodes, searched, labels, x) not searched[x] searched[x] searched x if w %2 == 0:
        labels[x] = label
      else:
        labels[x] = (label + 1) % 2
       w %2 == 0 w %2 w 2 0 labels[x] = label labels[x] labels x label labels[x] = (label + 1) % 2 labels[x] labels x (label + 1) % 2 label + 1 label 1 2 search(nodes, searched, labels, x) search nodes searched labels x nodes nodes searched searched labels labels v v def solve(n, nodes):
  searched = [0]*n
  labels = [None]*n
  labels[0] = 0
  search(nodes, searched, labels, 0)
  return labels solve searched = [0]*n searched [0]*n [0] 0 n labels = [None]*n labels [None]*n [None] None n labels[0] = 0 labels[0] labels 0 0 search(nodes, searched, labels, 0) search nodes searched labels 0 return labels labels n n nodes nodes def main():
  n = int(input())
  nodes = [[] for _ in range(n)]
  for _ in range(n-1):
    v, u, w = map(int, input().split(' '))
    nodes[v-1].append((u-1,w))
    nodes[u-1].append((v-1,w))
  ans = solve(n, nodes)
  for r in ans:
    print(r)
   main n = int(input()) n int(input()) int input() input [] for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) [] nodes = [[] for _ in range(n)] nodes [[] for _ in range(n)] for _ in range(n-1):
    v, u, w = map(int, input().split(' '))
    nodes[v-1].append((u-1,w))
    nodes[u-1].append((v-1,w))
   _ range(n-1) range n-1 n 1 v, u, w = map(int, input().split(' ')) v map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' u w nodes[v-1].append((u-1,w)) [v-1].append [v-1] nodes v-1 v 1 append (u-1,w) u-1 u 1 w nodes[u-1].append((v-1,w)) [u-1].append [u-1] nodes u-1 u 1 append (v-1,w) v-1 v 1 w ans = solve(n, nodes) ans solve(n, nodes) solve n nodes for r in ans:
    print(r)
   r ans print(r) print r if __name__=='__main__':
  main() __name__=='__main__' __name__ '__main__' main() main input=sys.stdin.readline sys.stdin.readline input def solve(n, nodes):
  searched = [0]*n
  labels = [None]*n
  labels[0] = 0
  search(nodes, searched, labels, 0)
  return labels def solve(n, nodes):
  searched = [0]*n
  labels = [None]*n
  labels[0] = 0
  search(nodes, searched, labels, 0)
  return labels solve def main():
  n = int(input())
  nodes = [[] for _ in range(n)]
  for _ in range(n-1):
    v, u, w = map(int, input().split(' '))
    nodes[v-1].append((u-1,w))
    nodes[u-1].append((v-1,w))
  ans = solve(n, nodes)
  for r in ans:
    print(r)
   def main():
  n = int(input())
  nodes = [[] for _ in range(n)]
  for _ in range(n-1):
    v, u, w = map(int, input().split(' '))
    nodes[v-1].append((u-1,w))
    nodes[u-1].append((v-1,w))
  ans = solve(n, nodes)
  for r in ans:
    print(r)
   main def search(nodes, searched, labels, v):
  searched[v] = 1
  label = labels[v]
  for l in nodes[v]:
    x, w = l
    if not searched[x]:
      if w %2 == 0:
        labels[x] = label
      else:
        labels[x] = (label + 1) % 2
      search(nodes, searched, labels, x) def search(nodes, searched, labels, v):
  searched[v] = 1
  label = labels[v]
  for l in nodes[v]:
    x, w = l
    if not searched[x]:
      if w %2 == 0:
        labels[x] = label
      else:
        labels[x] = (label + 1) % 2
      search(nodes, searched, labels, x) search
import sys
sys.setrecursionlimit(2147483647)
input=sys.stdin.readline

def search(nodes, searched, labels, v):
  searched[v] = 1
  label = labels[v]
  for l in nodes[v]:
    x, w = l
    if not searched[x]:
      if w %2 == 0:
        labels[x] = label
      else:
        labels[x] = (label + 1) % 2
      search(nodes, searched, labels, x)

def solve(n, nodes):
  searched = [0]*n
  labels = [None]*n
  labels[0] = 0
  search(nodes, searched, labels, 0)
  return labels

def main():
  n = int(input())
  nodes = [[] for _ in range(n)]
  for _ in range(n-1):
    v, u, w = map(int, input().split(' '))
    nodes[v-1].append((u-1,w))
    nodes[u-1].append((v-1,w))
  ans = solve(n, nodes)
  for r in ans:
    print(r)
  

if __name__=='__main__':
  main()