import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
from collections import defaultdict
ns = defaultdict(set)
for i in range(n-1):
    u,v,w = map(int,input().split())
    u -= 1
    v -= 1
    ns[u].add((w, v))
    ns[v].add((w, u))
    
q = [(0,0)]
ans = [None]*n
ans[0] = 0
while q:
    d,u = q.pop()
    for w,v in ns[u]:
        if ans[v] is None:
            val = (w+d)%2
            q.append((val, v))
            ans[v] = val
write("\n".join(map(str, ans))) import sys sys input = lambda : sys.stdin.readline().rstrip() input lambda : sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip sys.setrecursionlimit(max(1000, 10**9)) sys.setrecursionlimit sys setrecursionlimit max(1000, 10**9) max 1000 10**9 10 9 write = lambda x: sys.stdout.write(x+"\n") write lambda x: sys.stdout.write(x+"\n") sys.stdout.write(x+"\n") sys.stdout.write sys.stdout sys stdout write x+"\n" x "\n" x n = int(input()) n int(input()) int input() input from collections import defaultdict ns = defaultdict(set) ns defaultdict(set) defaultdict set for i in range(n-1):
    u,v,w = map(int,input().split())
    u -= 1
    v -= 1
    ns[u].add((w, v))
    ns[v].add((w, u))
     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 u -= 1 u 1 v -= 1 v 1 ns[u].add((w, v)) [u].add [u] ns u add (w, v) w v ns[v].add((w, u)) [v].add [v] ns v add (w, u) w u q = [(0,0)] q [(0,0)] (0,0) 0 0 ans = [None]*n ans [None]*n [None] None n ans[0] = 0 ans[0] ans 0 0 while q:
    d,u = q.pop()
    for w,v in ns[u]:
        if ans[v] is None:
            val = (w+d)%2
            q.append((val, v))
            ans[v] = val q d,u = q.pop() d q.pop() q.pop q pop u for w,v in ns[u]:
        if ans[v] is None:
            val = (w+d)%2
            q.append((val, v))
            ans[v] = val w v ns[u] ns u if ans[v] is None:
            val = (w+d)%2
            q.append((val, v))
            ans[v] = val ans[v] is None ans[v] ans v None val = (w+d)%2 val (w+d)%2 w+d w d 2 q.append((val, v)) q.append q append (val, v) val v ans[v] = val ans[v] ans v val write("\n".join(map(str, ans))) write "\n".join(map(str, ans)) "\n".join "\n" join map(str, ans) map str ans u,v,w = map(int,input().split()) map(int,input().split()) u q = [(0,0)] [(0,0)] q u -= 1 1 u u = q.pop() q.pop() u write = lambda x: sys.stdout.write(x+"\n") lambda x: sys.stdout.write(x+"\n") write ans = [None]*n [None]*n ans d,u = q.pop() q.pop() d w = map(int,input().split()) map(int,input().split()) w val = (w+d)%2 (w+d)%2 val input = lambda : sys.stdin.readline().rstrip() lambda : sys.stdin.readline().rstrip() input n = int(input()) int(input()) n v,w = map(int,input().split()) map(int,input().split()) v ns = defaultdict(set) defaultdict(set) ns v -= 1 1 v
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
from collections import defaultdict
ns = defaultdict(set)
for i in range(n-1):
    u,v,w = map(int,input().split())
    u -= 1
    v -= 1
    ns[u].add((w, v))
    ns[v].add((w, u))
    
q = [(0,0)]
ans = [None]*n
ans[0] = 0
while q:
    d,u = q.pop()
    for w,v in ns[u]:
        if ans[v] is None:
            val = (w+d)%2
            q.append((val, v))
            ans[v] = val
write("\n".join(map(str, ans)))