from collections import deque

def bfs(s):
    global color
    q = deque()
    q.append(s)
    color[s] = 0
    while q:
        i = q.popleft()
        for g in G[i]:
            if color[g[0]] == -1:
                if g[1] % 2 == 0:
                    color[g[0]] = color[i]
                else:
                    color[g[0]] = 1 - color[i]
                q.append(g[0])
    return

n = int(input())
G = [[] for _ in range(n + 1)]
color = [-1] * (n + 1)
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    G[u].append([v, w])
    G[v].append([u, w])
bfs(1)
for i in range(1, n + 1):
    print(color[i]) from collections import deque def bfs(s):
    global color
    q = deque()
    q.append(s)
    color[s] = 0
    while q:
        i = q.popleft()
        for g in G[i]:
            if color[g[0]] == -1:
                if g[1] % 2 == 0:
                    color[g[0]] = color[i]
                else:
                    color[g[0]] = 1 - color[i]
                q.append(g[0])
    return bfs global color q = deque() q deque() deque q.append(s) q.append q append s color[s] = 0 color[s] color s 0 while q:
        i = q.popleft()
        for g in G[i]:
            if color[g[0]] == -1:
                if g[1] % 2 == 0:
                    color[g[0]] = color[i]
                else:
                    color[g[0]] = 1 - color[i]
                q.append(g[0])
     q i = q.popleft() i q.popleft() q.popleft q popleft for g in G[i]:
            if color[g[0]] == -1:
                if g[1] % 2 == 0:
                    color[g[0]] = color[i]
                else:
                    color[g[0]] = 1 - color[i]
                q.append(g[0])
     g G[i] G i if color[g[0]] == -1:
                if g[1] % 2 == 0:
                    color[g[0]] = color[i]
                else:
                    color[g[0]] = 1 - color[i]
                q.append(g[0])
     color[g[0]] == -1 color[g[0]] color g[0] g 0 -1 if g[1] % 2 == 0:
                    color[g[0]] = color[i]
                else:
                    color[g[0]] = 1 - color[i]
                 g[1] % 2 == 0 g[1] % 2 g[1] g 1 2 0 color[g[0]] = color[i] color[g[0]] color g[0] g 0 color[i] color i color[g[0]] = 1 - color[i] color[g[0]] color g[0] g 0 1 - color[i] 1 color[i] color i q.append(g[0]) q.append q append g[0] g 0 return s s n = int(input()) n int(input()) int input() input [] for _ in range(n + 1) for _ in range(n + 1) _ range(n + 1) range n + 1 n 1 for _ in range(n + 1) [] G = [[] for _ in range(n + 1)] G [[] for _ in range(n + 1)] color = [-1] * (n + 1) color [-1] * (n + 1) [-1] -1 n + 1 n 1 for _ in range(n - 1):
    u, v, w = map(int, input().split())
    G[u].append([v, w])
    G[v].append([u, 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].append([v, w]) [u].append [u] G u append [v, w] v w G[v].append([u, w]) [v].append [v] G v append [u, w] u w bfs(1) bfs 1 for i in range(1, n + 1):
    print(color[i]) i range(1, n + 1) range 1 n + 1 n 1 print(color[i]) print color[i] color i v, w = map(int, input().split()) map(int, input().split()) v color = [-1] * (n + 1) [-1] * (n + 1) color n = int(input()) int(input()) n def bfs(s):
    global color
    q = deque()
    q.append(s)
    color[s] = 0
    while q:
        i = q.popleft()
        for g in G[i]:
            if color[g[0]] == -1:
                if g[1] % 2 == 0:
                    color[g[0]] = color[i]
                else:
                    color[g[0]] = 1 - color[i]
                q.append(g[0])
    return def bfs(s):
    global color
    q = deque()
    q.append(s)
    color[s] = 0
    while q:
        i = q.popleft()
        for g in G[i]:
            if color[g[0]] == -1:
                if g[1] % 2 == 0:
                    color[g[0]] = color[i]
                else:
                    color[g[0]] = 1 - color[i]
                q.append(g[0])
    return bfs w = map(int, input().split()) map(int, input().split()) w G = [[] for _ in range(n + 1)] [[] for _ in range(n + 1)] G u, v, w = map(int, input().split()) map(int, input().split()) u
from collections import deque

def bfs(s):
    global color
    q = deque()
    q.append(s)
    color[s] = 0
    while q:
        i = q.popleft()
        for g in G[i]:
            if color[g[0]] == -1:
                if g[1] % 2 == 0:
                    color[g[0]] = color[i]
                else:
                    color[g[0]] = 1 - color[i]
                q.append(g[0])
    return

n = int(input())
G = [[] for _ in range(n + 1)]
color = [-1] * (n + 1)
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    G[u].append([v, w])
    G[v].append([u, w])
bfs(1)
for i in range(1, n + 1):
    print(color[i])