import sys
sys.setrecursionlimit(1<<30)

N = int(input())
def dfs(x):
    for y in Tree[x]:
        if Parent[x] != y:
            Parent[y] = x
            distance[y] += Web[min(x,y),max(x,y)]+distance[x]
            dfs(y)
Tree = [[] for i in range(N+1)]
Parent = [0]*(N+1)
Web = dict()
for i in range(N-1):
    a,b,w = map(int,input().split())
    Tree[a].append(b)
    Tree[b].append(a)
    Web[(min(a,b),max(a,b))] = w
distance = [0]*(N+1)
dfs(1)
for i in distance[1:]:
    if i%2 == 0:
        print(1)
    else:
        print(0) import sys sys sys.setrecursionlimit(1<<30) sys.setrecursionlimit sys setrecursionlimit 1<<30 1 30 N = int(input()) N int(input()) int input() input def dfs(x):
    for y in Tree[x]:
        if Parent[x] != y:
            Parent[y] = x
            distance[y] += Web[min(x,y),max(x,y)]+distance[x]
            dfs(y) dfs for y in Tree[x]:
        if Parent[x] != y:
            Parent[y] = x
            distance[y] += Web[min(x,y),max(x,y)]+distance[x]
            dfs(y) y Tree[x] Tree x if Parent[x] != y:
            Parent[y] = x
            distance[y] += Web[min(x,y),max(x,y)]+distance[x]
            dfs(y) Parent[x] != y Parent[x] Parent x y Parent[y] = x Parent[y] Parent y x distance[y] += Web[min(x,y),max(x,y)]+distance[x] distance[y] distance y Web[min(x,y),max(x,y)]+distance[x] Web[min(x,y),max(x,y)] Web min(x,y) min x y distance[x] distance x dfs(y) dfs y x x [] 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) [] Tree = [[] for i in range(N+1)] Tree [[] for i in range(N+1)] Parent = [0]*(N+1) Parent [0]*(N+1) [0] 0 N+1 N 1 Web = dict() Web dict() dict for i in range(N-1):
    a,b,w = map(int,input().split())
    Tree[a].append(b)
    Tree[b].append(a)
    Web[(min(a,b),max(a,b))] = w i range(N-1) range N-1 N 1 a,b,w = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b w Tree[a].append(b) [a].append [a] Tree a append b Tree[b].append(a) [b].append [b] Tree b append a Web[(min(a,b),max(a,b))] = w Web[(min(a,b),max(a,b))] Web (min(a,b),max(a,b)) min(a,b) min a b max(a,b) max a b w distance = [0]*(N+1) distance [0]*(N+1) [0] 0 N+1 N 1 dfs(1) dfs 1 for i in distance[1:]:
    if i%2 == 0:
        print(1)
    else:
        print(0) i distance[1:] distance 1: 1 if i%2 == 0:
        print(1)
    else:
        print(0) i%2 == 0 i%2 i 2 0 print(1) print 1 print(0) print 0 Web = dict() dict() Web a,b,w = map(int,input().split()) map(int,input().split()) a distance = [0]*(N+1) [0]*(N+1) distance N = int(input()) int(input()) N b,w = map(int,input().split()) map(int,input().split()) b Parent = [0]*(N+1) [0]*(N+1) Parent w = map(int,input().split()) map(int,input().split()) w def dfs(x):
    for y in Tree[x]:
        if Parent[x] != y:
            Parent[y] = x
            distance[y] += Web[min(x,y),max(x,y)]+distance[x]
            dfs(y) def dfs(x):
    for y in Tree[x]:
        if Parent[x] != y:
            Parent[y] = x
            distance[y] += Web[min(x,y),max(x,y)]+distance[x]
            dfs(y) dfs Tree = [[] for i in range(N+1)] [[] for i in range(N+1)] Tree
import sys
sys.setrecursionlimit(1<<30)

N = int(input())
def dfs(x):
    for y in Tree[x]:
        if Parent[x] != y:
            Parent[y] = x
            distance[y] += Web[min(x,y),max(x,y)]+distance[x]
            dfs(y)
Tree = [[] for i in range(N+1)]
Parent = [0]*(N+1)
Web = dict()
for i in range(N-1):
    a,b,w = map(int,input().split())
    Tree[a].append(b)
    Tree[b].append(a)
    Web[(min(a,b),max(a,b))] = w
distance = [0]*(N+1)
dfs(1)
for i in distance[1:]:
    if i%2 == 0:
        print(1)
    else:
        print(0)