from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N = int(input())

al = [[] for i in range(N+1)]
for i in range(N-1):
    a, b, c = map(int, input().split())
    al[a].append((b,c))
    al[b].append((a,c))


seen = [0 for i in range(N+1)]
ans = [0 for i in range(N+1)]

def bfs(u):
    stack = deque([u])
    seen[u] = 1
    ans[u] = 0

    while len(stack) > 0:
        v = stack.popleft()

        for w in al[v]:
            if seen[w[0]] == 0:
                stack.append(w[0])
                if w[1] % 2 == 0:
                    ans[w[0]] = ans[v]
                else:
                    ans[w[0]] = 1 - ans[v]
                seen[w[0]] = 1

bfs(1)

for i in range(1,N+1):
    print(ans[i]) from sys import stdin import sys sys import math math from functools import reduce import functools functools import itertools itertools from collections import deque,Counter,defaultdict from operator import mul import copy copy import heapq heapq sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 INF = 10**18 INF 10**18 10 18 import bisect bisect import statistics statistics mod = 10**9+7 mod 10**9+7 10**9 10 9 7 N = int(input()) N int(input()) int input() input [] for i in range(N+1) for i in range(N+1) i range(N+1) range N+1 N 1 for i in range(N+1) [] al = [[] for i in range(N+1)] al [[] for i in range(N+1)] for i in range(N-1):
    a, b, c = map(int, input().split())
    al[a].append((b,c))
    al[b].append((a,c)) i range(N-1) range N-1 N 1 a, b, c = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b c al[a].append((b,c)) [a].append [a] al a append (b,c) b c al[b].append((a,c)) [b].append [b] al b append (a,c) a c 0 for i in range(N+1) for i in range(N+1) i range(N+1) range N+1 N 1 for i in range(N+1) 0 seen = [0 for i in range(N+1)] seen [0 for i in range(N+1)] 0 for i in range(N+1) for i in range(N+1) i range(N+1) range N+1 N 1 for i in range(N+1) 0 ans = [0 for i in range(N+1)] ans [0 for i in range(N+1)] def bfs(u):
    stack = deque([u])
    seen[u] = 1
    ans[u] = 0

    while len(stack) > 0:
        v = stack.popleft()

        for w in al[v]:
            if seen[w[0]] == 0:
                stack.append(w[0])
                if w[1] % 2 == 0:
                    ans[w[0]] = ans[v]
                else:
                    ans[w[0]] = 1 - ans[v]
                seen[w[0]] = 1 bfs stack = deque([u]) stack deque([u]) deque [u] u seen[u] = 1 seen[u] seen u 1 ans[u] = 0 ans[u] ans u 0 while len(stack) > 0:
        v = stack.popleft()

        for w in al[v]:
            if seen[w[0]] == 0:
                stack.append(w[0])
                if w[1] % 2 == 0:
                    ans[w[0]] = ans[v]
                else:
                    ans[w[0]] = 1 - ans[v]
                seen[w[0]] = 1 len(stack) > 0 len(stack) len stack 0 v = stack.popleft() v stack.popleft() stack.popleft stack popleft for w in al[v]:
            if seen[w[0]] == 0:
                stack.append(w[0])
                if w[1] % 2 == 0:
                    ans[w[0]] = ans[v]
                else:
                    ans[w[0]] = 1 - ans[v]
                seen[w[0]] = 1 w al[v] al v if seen[w[0]] == 0:
                stack.append(w[0])
                if w[1] % 2 == 0:
                    ans[w[0]] = ans[v]
                else:
                    ans[w[0]] = 1 - ans[v]
                seen[w[0]] = 1 seen[w[0]] == 0 seen[w[0]] seen w[0] w 0 0 stack.append(w[0]) stack.append stack append w[0] w 0 if w[1] % 2 == 0:
                    ans[w[0]] = ans[v]
                else:
                    ans[w[0]] = 1 - ans[v]
                 w[1] % 2 == 0 w[1] % 2 w[1] w 1 2 0 ans[w[0]] = ans[v] ans[w[0]] ans w[0] w 0 ans[v] ans v ans[w[0]] = 1 - ans[v] ans[w[0]] ans w[0] w 0 1 - ans[v] 1 ans[v] ans v seen[w[0]] = 1 seen[w[0]] seen w[0] w 0 1 u u bfs(1) bfs 1 for i in range(1,N+1):
    print(ans[i]) i range(1,N+1) range 1 N+1 N 1 print(ans[i]) print ans[i] ans i seen = [0 for i in range(N+1)] [0 for i in range(N+1)] seen INF = 10**18 10**18 INF al = [[] for i in range(N+1)] [[] for i in range(N+1)] al c = map(int, input().split()) map(int, input().split()) c N = int(input()) int(input()) N ans = [0 for i in range(N+1)] [0 for i in range(N+1)] ans b, c = map(int, input().split()) map(int, input().split()) b def bfs(u):
    stack = deque([u])
    seen[u] = 1
    ans[u] = 0

    while len(stack) > 0:
        v = stack.popleft()

        for w in al[v]:
            if seen[w[0]] == 0:
                stack.append(w[0])
                if w[1] % 2 == 0:
                    ans[w[0]] = ans[v]
                else:
                    ans[w[0]] = 1 - ans[v]
                seen[w[0]] = 1 def bfs(u):
    stack = deque([u])
    seen[u] = 1
    ans[u] = 0

    while len(stack) > 0:
        v = stack.popleft()

        for w in al[v]:
            if seen[w[0]] == 0:
                stack.append(w[0])
                if w[1] % 2 == 0:
                    ans[w[0]] = ans[v]
                else:
                    ans[w[0]] = 1 - ans[v]
                seen[w[0]] = 1 bfs mod = 10**9+7 10**9+7 mod a, b, c = map(int, input().split()) map(int, input().split()) a
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N = int(input())

al = [[] for i in range(N+1)]
for i in range(N-1):
    a, b, c = map(int, input().split())
    al[a].append((b,c))
    al[b].append((a,c))


seen = [0 for i in range(N+1)]
ans = [0 for i in range(N+1)]

def bfs(u):
    stack = deque([u])
    seen[u] = 1
    ans[u] = 0

    while len(stack) > 0:
        v = stack.popleft()

        for w in al[v]:
            if seen[w[0]] == 0:
                stack.append(w[0])
                if w[1] % 2 == 0:
                    ans[w[0]] = ans[v]
                else:
                    ans[w[0]] = 1 - ans[v]
                seen[w[0]] = 1

bfs(1)

for i in range(1,N+1):
    print(ans[i])