import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N = int(readline())

nodes = [{} for i in range(N+1)]

for i in range(N-1):
    u,v,w = map(int,readline().split())
    nodes[u][v] = w
    nodes[v][u] = w

ans = [-1]*(N+1)
ans[1] = 0

def dfs(start,to,dist):
    ver = nodes[start][to]
    ans[to] = (dist + ver)%2
    for k in nodes[to].keys():
        if k != start:
            dfs(to,k,dist+ver)

for k in nodes[1].keys():
    dfs(1,k,0)

for i in range(N):
    print(ans[i+1]) import sys sys readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(10**8) sys.setrecursionlimit sys setrecursionlimit 10**8 10 8 mod = 10**9+7 mod 10**9+7 10**9 10 9 7 INF = 10**18 INF 10**18 10 18 eps = 10**-7 eps 10**-7 10 -7 N = int(readline()) N int(readline()) int readline() readline {} for i in range(N+1) for i in range(N+1) i range(N+1) range N+1 N 1 for i in range(N+1) {} nodes = [{} for i in range(N+1)] nodes [{} for i in range(N+1)] for i in range(N-1):
    u,v,w = map(int,readline().split())
    nodes[u][v] = w
    nodes[v][u] = w i range(N-1) range N-1 N 1 u,v,w = map(int,readline().split()) u map(int,readline().split()) map int readline().split() ().split () readline split v w nodes[u][v] = w nodes[u][v] [u] nodes u v w nodes[v][u] = w nodes[v][u] [v] nodes v u w ans = [-1]*(N+1) ans [-1]*(N+1) [-1] -1 N+1 N 1 ans[1] = 0 ans[1] ans 1 0 def dfs(start,to,dist):
    ver = nodes[start][to]
    ans[to] = (dist + ver)%2
    for k in nodes[to].keys():
        if k != start:
            dfs(to,k,dist+ver) dfs ver = nodes[start][to] ver nodes[start][to] [start] nodes start to ans[to] = (dist + ver)%2 ans[to] ans to (dist + ver)%2 dist + ver dist ver 2 for k in nodes[to].keys():
        if k != start:
            dfs(to,k,dist+ver) k nodes[to].keys() [to].keys [to] nodes to keys if k != start:
            dfs(to,k,dist+ver) k != start k start dfs(to,k,dist+ver) dfs to k dist+ver dist ver start start to to dist dist for k in nodes[1].keys():
    dfs(1,k,0) k nodes[1].keys() [1].keys [1] nodes 1 keys dfs(1,k,0) dfs 1 k 0 for i in range(N):
    print(ans[i+1]) i range(N) range N print(ans[i+1]) print ans[i+1] ans i+1 i 1 v,w = map(int,readline().split()) map(int,readline().split()) v eps = 10**-7 10**-7 eps u,v,w = map(int,readline().split()) map(int,readline().split()) u nodes = [{} for i in range(N+1)] [{} for i in range(N+1)] nodes ans = [-1]*(N+1) [-1]*(N+1) ans INF = 10**18 10**18 INF N = int(readline()) int(readline()) N w = map(int,readline().split()) map(int,readline().split()) w readline = sys.stdin.readline sys.stdin.readline readline def dfs(start,to,dist):
    ver = nodes[start][to]
    ans[to] = (dist + ver)%2
    for k in nodes[to].keys():
        if k != start:
            dfs(to,k,dist+ver) def dfs(start,to,dist):
    ver = nodes[start][to]
    ans[to] = (dist + ver)%2
    for k in nodes[to].keys():
        if k != start:
            dfs(to,k,dist+ver) dfs mod = 10**9+7 10**9+7 mod
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N = int(readline())

nodes = [{} for i in range(N+1)]

for i in range(N-1):
    u,v,w = map(int,readline().split())
    nodes[u][v] = w
    nodes[v][u] = w

ans = [-1]*(N+1)
ans[1] = 0

def dfs(start,to,dist):
    ver = nodes[start][to]
    ans[to] = (dist + ver)%2
    for k in nodes[to].keys():
        if k != start:
            dfs(to,k,dist+ver)

for k in nodes[1].keys():
    dfs(1,k,0)

for i in range(N):
    print(ans[i+1])
