from sys import setrecursionlimit

setrecursionlimit(10 ** 6)

def dfs(now, prev):
    for nxt, w in edge[now]:
        if nxt == prev:
            continue
        
        dist[nxt] = dist[now] + w
        dfs(nxt, now)


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

dist = [0] * n
dfs(0, -1)

for d in dist:
    if d % 2 == 0:
        print(0)
    else:
        print(1) from sys import setrecursionlimit setrecursionlimit(10 ** 6) setrecursionlimit 10 ** 6 10 6 def dfs(now, prev):
    for nxt, w in edge[now]:
        if nxt == prev:
            continue
        
        dist[nxt] = dist[now] + w
        dfs(nxt, now) dfs for nxt, w in edge[now]:
        if nxt == prev:
            continue
        
        dist[nxt] = dist[now] + w
        dfs(nxt, now) nxt w edge[now] edge now if nxt == prev:
            continue
        
         nxt == prev nxt prev continue dist[nxt] = dist[now] + w dist[nxt] dist nxt dist[now] + w dist[now] dist now w dfs(nxt, now) dfs nxt now now now prev prev 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) [] edge = [[] for _ in range(n)] edge [[] for _ in range(n)] for _ in range(n-1):
    u, v, w = map(int, input().split())
    edge[u-1].append([v-1, w])
    edge[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 edge[u-1].append([v-1, w]) [u-1].append [u-1] edge u-1 u 1 append [v-1, w] v-1 v 1 w edge[v-1].append([u-1, w]) [v-1].append [v-1] edge v-1 v 1 append [u-1, w] u-1 u 1 w dist = [0] * n dist [0] * n [0] 0 n dfs(0, -1) dfs 0 -1 for d in dist:
    if d % 2 == 0:
        print(0)
    else:
        print(1) d dist if d % 2 == 0:
        print(0)
    else:
        print(1) d % 2 == 0 d % 2 d 2 0 print(0) print 0 print(1) print 1 w = map(int, input().split()) map(int, input().split()) w v, w = map(int, input().split()) map(int, input().split()) v n = int(input()) int(input()) n def dfs(now, prev):
    for nxt, w in edge[now]:
        if nxt == prev:
            continue
        
        dist[nxt] = dist[now] + w
        dfs(nxt, now) def dfs(now, prev):
    for nxt, w in edge[now]:
        if nxt == prev:
            continue
        
        dist[nxt] = dist[now] + w
        dfs(nxt, now) dfs edge = [[] for _ in range(n)] [[] for _ in range(n)] edge u, v, w = map(int, input().split()) map(int, input().split()) u dist = [0] * n [0] * n dist
from sys import setrecursionlimit

setrecursionlimit(10 ** 6)

def dfs(now, prev):
    for nxt, w in edge[now]:
        if nxt == prev:
            continue
        
        dist[nxt] = dist[now] + w
        dfs(nxt, now)


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

dist = [0] * n
dfs(0, -1)

for d in dist:
    if d % 2 == 0:
        print(0)
    else:
        print(1)