from collections import deque

n = int (input())
roots = [[] for _ in range(2*n)]
color = [0] * 2 * n

for i in range(n-1):
    u, v, w = [int(i) for i in input().split()]
    u = u - 1
    v = v - 1

    if (w % 2 == 1):
        roots[u].append(v)
        roots[v].append(u)
    else:
        roots[u].append(u+n)
        roots[u+n].append(v)
        roots[v].append(v+n)
        roots[v+n].append(u)

d = deque()
d.append(0)
color[0] = 1

while(len(d)):
    temp = d.popleft()
    for i in roots[temp]:
        if(color[i] == 0):
            color[i] = color[temp] * (-1)
            d.append(i)

for i in range(n):
    print(max(0,color[i])) from collections import deque n = int (input()) n int (input()) int input() input [] for _ in range(2*n) for _ in range(2*n) _ range(2*n) range 2*n 2 n for _ in range(2*n) [] roots = [[] for _ in range(2*n)] roots [[] for _ in range(2*n)] color = [0] * 2 * n color [0] * 2 * n [0] * 2 [0] 0 2 n for i in range(n-1):
    u, v, w = [int(i) for i in input().split()]
    u = u - 1
    v = v - 1

    if (w % 2 == 1):
        roots[u].append(v)
        roots[v].append(u)
    else:
        roots[u].append(u+n)
        roots[u+n].append(v)
        roots[v].append(v+n)
        roots[v+n].append(u) i range(n-1) range n-1 n 1 int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i u, v, w = [int(i) for i in input().split()] u [int(i) for i in input().split()] v w u = u - 1 u u - 1 u 1 v = v - 1 v v - 1 v 1 if (w % 2 == 1):
        roots[u].append(v)
        roots[v].append(u)
    else:
        roots[u].append(u+n)
        roots[u+n].append(v)
        roots[v].append(v+n)
        roots[v+n].append(u) w % 2 == 1 w % 2 w 2 1 roots[u].append(v) [u].append [u] roots u append v roots[v].append(u) [v].append [v] roots v append u roots[u].append(u+n) [u].append [u] roots u append u+n u n roots[u+n].append(v) [u+n].append [u+n] roots u+n u n append v roots[v].append(v+n) [v].append [v] roots v append v+n v n roots[v+n].append(u) [v+n].append [v+n] roots v+n v n append u d = deque() d deque() deque d.append(0) d.append d append 0 color[0] = 1 color[0] color 0 1 while(len(d)):
    temp = d.popleft()
    for i in roots[temp]:
        if(color[i] == 0):
            color[i] = color[temp] * (-1)
            d.append(i) len(d) len d temp = d.popleft() temp d.popleft() d.popleft d popleft for i in roots[temp]:
        if(color[i] == 0):
            color[i] = color[temp] * (-1)
            d.append(i) i roots[temp] roots temp if(color[i] == 0):
            color[i] = color[temp] * (-1)
            d.append(i) color[i] == 0 color[i] color i 0 color[i] = color[temp] * (-1) color[i] color i color[temp] * (-1) color[temp] color temp -1 d.append(i) d.append d append i for i in range(n):
    print(max(0,color[i])) i range(n) range n print(max(0,color[i])) print max(0,color[i]) max 0 color[i] color i temp = d.popleft() d.popleft() temp v, w = [int(i) for i in input().split()] [int(i) for i in input().split()] v v = v - 1 v - 1 v u = u - 1 u - 1 u u, v, w = [int(i) for i in input().split()] [int(i) for i in input().split()] u d = deque() deque() d n = int (input()) int (input()) n roots = [[] for _ in range(2*n)] [[] for _ in range(2*n)] roots color = [0] * 2 * n [0] * 2 * n color w = [int(i) for i in input().split()] [int(i) for i in input().split()] w
from collections import deque

n = int (input())
roots = [[] for _ in range(2*n)]
color = [0] * 2 * n

for i in range(n-1):
    u, v, w = [int(i) for i in input().split()]
    u = u - 1
    v = v - 1

    if (w % 2 == 1):
        roots[u].append(v)
        roots[v].append(u)
    else:
        roots[u].append(u+n)
        roots[u+n].append(v)
        roots[v].append(v+n)
        roots[v+n].append(u)

d = deque()
d.append(0)
color[0] = 1

while(len(d)):
    temp = d.popleft()
    for i in roots[temp]:
        if(color[i] == 0):
            color[i] = color[temp] * (-1)
            d.append(i)

for i in range(n):
    print(max(0,color[i]))