n = int(input())
d = [[] for i in range(n)]
for i in range(n-1):
  u, v, w = map(int, input().split())
  d[u-1].append([v-1, w])
  d[v-1].append([u-1, w])
  
ans = [[] for i in range(n)]
ans[0].append(0)
q = [0]

while q:
  x = q.pop()
  for u, w in d[x]:
    if not ans[u]:
      buf = ans[x][0]
      if w%2==1:
        buf = (buf+1)%2
      ans[u].append(buf)
      q.append(u)
    
for i in ans:
  print(*i) 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) [] d = [[] for i in range(n)] d [[] for i in range(n)] for i in range(n-1):
  u, v, w = map(int, input().split())
  d[u-1].append([v-1, w])
  d[v-1].append([u-1, w])
   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 d[u-1].append([v-1, w]) [u-1].append [u-1] d u-1 u 1 append [v-1, w] v-1 v 1 w d[v-1].append([u-1, w]) [v-1].append [v-1] d v-1 v 1 append [u-1, w] u-1 u 1 w [] for i in range(n) for i in range(n) i range(n) range n for i in range(n) [] ans = [[] for i in range(n)] ans [[] for i in range(n)] ans[0].append(0) [0].append [0] ans 0 append 0 q = [0] q [0] 0 while q:
  x = q.pop()
  for u, w in d[x]:
    if not ans[u]:
      buf = ans[x][0]
      if w%2==1:
        buf = (buf+1)%2
      ans[u].append(buf)
      q.append(u)
     q x = q.pop() x q.pop() q.pop q pop for u, w in d[x]:
    if not ans[u]:
      buf = ans[x][0]
      if w%2==1:
        buf = (buf+1)%2
      ans[u].append(buf)
      q.append(u)
     u w d[x] d x if not ans[u]:
      buf = ans[x][0]
      if w%2==1:
        buf = (buf+1)%2
      ans[u].append(buf)
      q.append(u)
     not ans[u] ans[u] ans u buf = ans[x][0] buf ans[x][0] [x] ans x 0 if w%2==1:
        buf = (buf+1)%2
       w%2==1 w%2 w 2 1 buf = (buf+1)%2 buf (buf+1)%2 buf+1 buf 1 2 ans[u].append(buf) [u].append [u] ans u append buf q.append(u) q.append q append u for i in ans:
  print(*i) i ans print(*i) print *i i v, w = map(int, input().split()) map(int, input().split()) v n = int(input()) int(input()) n x = q.pop() q.pop() x u, v, w = map(int, input().split()) map(int, input().split()) u w = map(int, input().split()) map(int, input().split()) w q = [0] [0] q d = [[] for i in range(n)] [[] for i in range(n)] d ans = [[] for i in range(n)] [[] for i in range(n)] ans buf = ans[x][0] ans[x][0] buf buf = (buf+1)%2 (buf+1)%2 buf
n = int(input())
d = [[] for i in range(n)]
for i in range(n-1):
  u, v, w = map(int, input().split())
  d[u-1].append([v-1, w])
  d[v-1].append([u-1, w])
  
ans = [[] for i in range(n)]
ans[0].append(0)
q = [0]

while q:
  x = q.pop()
  for u, w in d[x]:
    if not ans[u]:
      buf = ans[x][0]
      if w%2==1:
        buf = (buf+1)%2
      ans[u].append(buf)
      q.append(u)
    
for i in ans:
  print(*i)