from collections import deque
N = int(input())
G = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    G[u - 1].append([v - 1, w])
    G[v - 1].append([u - 1, w])

Q = deque()
Q.append(0)
c = [-1] * N
c[0] = 0
while len(Q) > 0:
    q = Q.popleft()
    pc = c[q]
    for g, w in G[q]:
        if c[g] != -1:
            continue
        if w % 2 == 0:
            c[g] = pc
        else:
            c[g] = 1 - pc
        Q.append(g)

for i in c:
    print(i) from collections import deque N = int(input()) N int(input()) int input() input [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] G = [[] for _ in range(N)] G [[] for _ in range(N)] for _ in range(N - 1):
    u, v, w = map(int, input().split())
    G[u - 1].append([v - 1, w])
    G[v - 1].append([u - 1, w]) _ 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 G[u - 1].append([v - 1, w]) [u - 1].append [u - 1] G u - 1 u 1 append [v - 1, w] v - 1 v 1 w G[v - 1].append([u - 1, w]) [v - 1].append [v - 1] G v - 1 v 1 append [u - 1, w] u - 1 u 1 w Q = deque() Q deque() deque Q.append(0) Q.append Q append 0 c = [-1] * N c [-1] * N [-1] -1 N c[0] = 0 c[0] c 0 0 while len(Q) > 0:
    q = Q.popleft()
    pc = c[q]
    for g, w in G[q]:
        if c[g] != -1:
            continue
        if w % 2 == 0:
            c[g] = pc
        else:
            c[g] = 1 - pc
        Q.append(g) len(Q) > 0 len(Q) len Q 0 q = Q.popleft() q Q.popleft() Q.popleft Q popleft pc = c[q] pc c[q] c q for g, w in G[q]:
        if c[g] != -1:
            continue
        if w % 2 == 0:
            c[g] = pc
        else:
            c[g] = 1 - pc
        Q.append(g) g w G[q] G q if c[g] != -1:
            continue
         c[g] != -1 c[g] c g -1 continue if w % 2 == 0:
            c[g] = pc
        else:
            c[g] = 1 - pc
         w % 2 == 0 w % 2 w 2 0 c[g] = pc c[g] c g pc c[g] = 1 - pc c[g] c g 1 - pc 1 pc Q.append(g) Q.append Q append g for i in c:
    print(i) i c print(i) print i c = [-1] * N [-1] * N c G = [[] for _ in range(N)] [[] for _ in range(N)] G N = int(input()) int(input()) N Q = deque() deque() Q u, v, w = map(int, input().split()) map(int, input().split()) u w = map(int, input().split()) map(int, input().split()) w v, w = map(int, input().split()) map(int, input().split()) v pc = c[q] c[q] pc q = Q.popleft() Q.popleft() q
from collections import deque
N = int(input())
G = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    G[u - 1].append([v - 1, w])
    G[v - 1].append([u - 1, w])

Q = deque()
Q.append(0)
c = [-1] * N
c[0] = 0
while len(Q) > 0:
    q = Q.popleft()
    pc = c[q]
    for g, w in G[q]:
        if c[g] != -1:
            continue
        if w % 2 == 0:
            c[g] = pc
        else:
            c[g] = 1 - pc
        Q.append(g)

for i in c:
    print(i)