import collections

n = int(input())
v = []
for i in range(n+10):
    v.append([])

for _ in range(n-1):
    a,b,w = map(int,input().split())
    v[a].append([b,w])
    v[b].append([a,w])

q = collections.deque([])
used = [None] * (n+10)
q.append([1,0])
while len(q) > 0:
    cur, color = q.pop()
    used[cur] = color
    for i in range(len(v[cur])):
        nind, w = v[cur][i]
        if used[nind] != None:
            continue
        if w % 2 == 0:
            q.append([nind, color])
        else:
            q.append([nind, 1-color])
for i in range(1, n+1):
    print(used[i]) import collections collections n = int(input()) n int(input()) int input() input v = [] v [] for i in range(n+10):
    v.append([]) i range(n+10) range n+10 n 10 v.append([]) v.append v append [] for _ in range(n-1):
    a,b,w = map(int,input().split())
    v[a].append([b,w])
    v[b].append([a,w]) _ 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 v[a].append([b,w]) [a].append [a] v a append [b,w] b w v[b].append([a,w]) [b].append [b] v b append [a,w] a w q = collections.deque([]) q collections.deque([]) collections.deque collections deque [] used = [None] * (n+10) used [None] * (n+10) [None] None n+10 n 10 q.append([1,0]) q.append q append [1,0] 1 0 while len(q) > 0:
    cur, color = q.pop()
    used[cur] = color
    for i in range(len(v[cur])):
        nind, w = v[cur][i]
        if used[nind] != None:
            continue
        if w % 2 == 0:
            q.append([nind, color])
        else:
            q.append([nind, 1-color]) len(q) > 0 len(q) len q 0 cur, color = q.pop() cur q.pop() q.pop q pop color used[cur] = color used[cur] used cur color for i in range(len(v[cur])):
        nind, w = v[cur][i]
        if used[nind] != None:
            continue
        if w % 2 == 0:
            q.append([nind, color])
        else:
            q.append([nind, 1-color]) i range(len(v[cur])) range len(v[cur]) len v[cur] v cur nind, w = v[cur][i] nind v[cur][i] [cur] v cur i w if used[nind] != None:
            continue
         used[nind] != None used[nind] used nind None continue if w % 2 == 0:
            q.append([nind, color])
        else:
            q.append([nind, 1-color]) w % 2 == 0 w % 2 w 2 0 q.append([nind, color]) q.append q append [nind, color] nind color q.append([nind, 1-color]) q.append q append [nind, 1-color] nind 1-color 1 color for i in range(1, n+1):
    print(used[i]) i range(1, n+1) range 1 n+1 n 1 print(used[i]) print used[i] used i v = [] [] v w = v[cur][i] v[cur][i] w cur, color = q.pop() q.pop() cur w = map(int,input().split()) map(int,input().split()) w color = q.pop() q.pop() color a,b,w = map(int,input().split()) map(int,input().split()) a b,w = map(int,input().split()) map(int,input().split()) b nind, w = v[cur][i] v[cur][i] nind n = int(input()) int(input()) n q = collections.deque([]) collections.deque([]) q used = [None] * (n+10) [None] * (n+10) used
import collections

n = int(input())
v = []
for i in range(n+10):
    v.append([])

for _ in range(n-1):
    a,b,w = map(int,input().split())
    v[a].append([b,w])
    v[b].append([a,w])

q = collections.deque([])
used = [None] * (n+10)
q.append([1,0])
while len(q) > 0:
    cur, color = q.pop()
    used[cur] = color
    for i in range(len(v[cur])):
        nind, w = v[cur][i]
        if used[nind] != None:
            continue
        if w % 2 == 0:
            q.append([nind, color])
        else:
            q.append([nind, 1-color])
for i in range(1, n+1):
    print(used[i])