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())
node = [[] for i in range(n)]

for i in range(n-1):
    u,v,w = map(int,readline().split())
    node[u-1].append((v-1,w))
    node[v-1].append((u-1,w))
ans = [-1]*n
ans[0] = 0
def dfs(fro, to, dis):
    ans[to] = dis%2
    for nxt, dist in node[to]:
        if nxt == fro:
            continue
        dfs(to, nxt, (dis+dist)%2)

for to,dis in node[0]:
    dfs(0,to,dis)

print("\n".join(map(str,ans)))
 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) for i in range(n) i range(n) range n for i in range(n) [] node = [[] for i in range(n)] node [[] for i in range(n)] for i in range(n-1):
    u,v,w = map(int,readline().split())
    node[u-1].append((v-1,w))
    node[v-1].append((u-1,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 node[u-1].append((v-1,w)) [u-1].append [u-1] node u-1 u 1 append (v-1,w) v-1 v 1 w node[v-1].append((u-1,w)) [v-1].append [v-1] node v-1 v 1 append (u-1,w) u-1 u 1 w ans = [-1]*n ans [-1]*n [-1] -1 n ans[0] = 0 ans[0] ans 0 0 def dfs(fro, to, dis):
    ans[to] = dis%2
    for nxt, dist in node[to]:
        if nxt == fro:
            continue
        dfs(to, nxt, (dis+dist)%2) dfs ans[to] = dis%2 ans[to] ans to dis%2 dis 2 for nxt, dist in node[to]:
        if nxt == fro:
            continue
        dfs(to, nxt, (dis+dist)%2) nxt dist node[to] node to if nxt == fro:
            continue
         nxt == fro nxt fro continue dfs(to, nxt, (dis+dist)%2) dfs to nxt (dis+dist)%2 dis+dist dis dist 2 fro fro to to dis dis for to,dis in node[0]:
    dfs(0,to,dis) to dis node[0] node 0 dfs(0,to,dis) dfs 0 to dis print("\n".join(map(str,ans))) print "\n".join(map(str,ans)) "\n".join "\n" join map(str,ans) map str ans v,w = map(int,readline().split()) map(int,readline().split()) v INF = 10**18 10**18 INF u,v,w = map(int,readline().split()) map(int,readline().split()) u mod = 10**9+7 10**9+7 mod readline = sys.stdin.readline sys.stdin.readline readline n = int(readline()) int(readline()) n def dfs(fro, to, dis):
    ans[to] = dis%2
    for nxt, dist in node[to]:
        if nxt == fro:
            continue
        dfs(to, nxt, (dis+dist)%2) def dfs(fro, to, dis):
    ans[to] = dis%2
    for nxt, dist in node[to]:
        if nxt == fro:
            continue
        dfs(to, nxt, (dis+dist)%2) dfs node = [[] for i in range(n)] [[] for i in range(n)] node w = map(int,readline().split()) map(int,readline().split()) w eps = 10**-7 10**-7 eps ans = [-1]*n [-1]*n ans
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())
node = [[] for i in range(n)]

for i in range(n-1):
    u,v,w = map(int,readline().split())
    node[u-1].append((v-1,w))
    node[v-1].append((u-1,w))
ans = [-1]*n
ans[0] = 0
def dfs(fro, to, dis):
    ans[to] = dis%2
    for nxt, dist in node[to]:
        if nxt == fro:
            continue
        dfs(to, nxt, (dis+dist)%2)

for to,dis in node[0]:
    dfs(0,to,dis)

print("\n".join(map(str,ans)))

