from collections import deque

N = int(input())

edge = [[int(s) - 1 for s in input().split()] for _ in range(N-1)]
graph = [[] for _ in range(N)]
weight_odd = {}

for i, j, w in edge:
    graph[i].append(j)
    graph[j].append(i)
    weight_odd[(i, j)] = (w % 2 != 0)
    weight_odd[(j, i)] = (w % 2 != 0)

dq = deque([0])
visited = [False] * N
color = [1] * N
while(dq):
    search_obj = dq.pop()
    col1 = color[search_obj]
    col2 = 0 if col1 == 1 else 1
    for candidate_obj in graph[search_obj]:
        if not visited[candidate_obj]:
            if weight_odd[(candidate_obj, search_obj)]:
                color[candidate_obj] = col1
            else:
                color[candidate_obj] = col2
            dq.appendleft(candidate_obj)
            visited[candidate_obj] = True

for c in color:
    print(c) from collections import deque N = int(input()) N int(input()) int input() input [int(s) - 1 for s in input().split()] for _ in range(N-1) for _ in range(N-1) _ range(N-1) range N-1 N 1 for _ in range(N-1) [int(s) - 1 for s in input().split()] edge = [[int(s) - 1 for s in input().split()] for _ in range(N-1)] edge [[int(s) - 1 for s in input().split()] for _ in range(N-1)] [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] graph = [[] for _ in range(N)] graph [[] for _ in range(N)] weight_odd = {} weight_odd {} for i, j, w in edge:
    graph[i].append(j)
    graph[j].append(i)
    weight_odd[(i, j)] = (w % 2 != 0)
    weight_odd[(j, i)] = (w % 2 != 0) i j w edge graph[i].append(j) [i].append [i] graph i append j graph[j].append(i) [j].append [j] graph j append i weight_odd[(i, j)] = (w % 2 != 0) weight_odd[(i, j)] weight_odd (i, j) i j w % 2 != 0 w % 2 w 2 0 weight_odd[(j, i)] = (w % 2 != 0) weight_odd[(j, i)] weight_odd (j, i) j i w % 2 != 0 w % 2 w 2 0 dq = deque([0]) dq deque([0]) deque [0] 0 visited = [False] * N visited [False] * N [False] False N color = [1] * N color [1] * N [1] 1 N while(dq):
    search_obj = dq.pop()
    col1 = color[search_obj]
    col2 = 0 if col1 == 1 else 1
    for candidate_obj in graph[search_obj]:
        if not visited[candidate_obj]:
            if weight_odd[(candidate_obj, search_obj)]:
                color[candidate_obj] = col1
            else:
                color[candidate_obj] = col2
            dq.appendleft(candidate_obj)
            visited[candidate_obj] = True dq search_obj = dq.pop() search_obj dq.pop() dq.pop dq pop col1 = color[search_obj] col1 color[search_obj] color search_obj col2 = 0 if col1 == 1 else 1 col2 0 if col1 == 1 else 1 col1 == 1 col1 1 0 1 for candidate_obj in graph[search_obj]:
        if not visited[candidate_obj]:
            if weight_odd[(candidate_obj, search_obj)]:
                color[candidate_obj] = col1
            else:
                color[candidate_obj] = col2
            dq.appendleft(candidate_obj)
            visited[candidate_obj] = True candidate_obj graph[search_obj] graph search_obj if not visited[candidate_obj]:
            if weight_odd[(candidate_obj, search_obj)]:
                color[candidate_obj] = col1
            else:
                color[candidate_obj] = col2
            dq.appendleft(candidate_obj)
            visited[candidate_obj] = True not visited[candidate_obj] visited[candidate_obj] visited candidate_obj if weight_odd[(candidate_obj, search_obj)]:
                color[candidate_obj] = col1
            else:
                color[candidate_obj] = col2
             weight_odd[(candidate_obj, search_obj)] weight_odd (candidate_obj, search_obj) candidate_obj search_obj color[candidate_obj] = col1 color[candidate_obj] color candidate_obj col1 color[candidate_obj] = col2 color[candidate_obj] color candidate_obj col2 dq.appendleft(candidate_obj) dq.appendleft dq appendleft candidate_obj visited[candidate_obj] = True visited[candidate_obj] visited candidate_obj True for c in color:
    print(c) c color print(c) print c N = int(input()) int(input()) N visited = [False] * N [False] * N visited graph = [[] for _ in range(N)] [[] for _ in range(N)] graph col1 = color[search_obj] color[search_obj] col1 dq = deque([0]) deque([0]) dq col2 = 0 if col1 == 1 else 1 0 if col1 == 1 else 1 col2 edge = [[int(s) - 1 for s in input().split()] for _ in range(N-1)] [[int(s) - 1 for s in input().split()] for _ in range(N-1)] edge weight_odd = {} {} weight_odd search_obj = dq.pop() dq.pop() search_obj color = [1] * N [1] * N color
from collections import deque

N = int(input())

edge = [[int(s) - 1 for s in input().split()] for _ in range(N-1)]
graph = [[] for _ in range(N)]
weight_odd = {}

for i, j, w in edge:
    graph[i].append(j)
    graph[j].append(i)
    weight_odd[(i, j)] = (w % 2 != 0)
    weight_odd[(j, i)] = (w % 2 != 0)

dq = deque([0])
visited = [False] * N
color = [1] * N
while(dq):
    search_obj = dq.pop()
    col1 = color[search_obj]
    col2 = 0 if col1 == 1 else 1
    for candidate_obj in graph[search_obj]:
        if not visited[candidate_obj]:
            if weight_odd[(candidate_obj, search_obj)]:
                color[candidate_obj] = col1
            else:
                color[candidate_obj] = col2
            dq.appendleft(candidate_obj)
            visited[candidate_obj] = True

for c in color:
    print(c)