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())
ver = [[] for i in range(N+1)]
for i in range(N-1):
    u,v,w = map(int,readline().split())
    ver[u].append((v,w))
    ver[v].append((u,w))
color = [-1]*(N+1)
color[1] = 0
def dfs(fro,to,d):
    color[to] = d%2
    for v in ver[to]:
        if v[0] == fro:
            continue
        dfs(to,v[0],d+v[1])


for v in ver[1]:
    dfs(1,v[0],v[1])

for i in range(1,N+1):
    print(color[i]) 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) [] ver = [[] for i in range(N+1)] ver [[] for i in range(N+1)] for i in range(N-1):
    u,v,w = map(int,readline().split())
    ver[u].append((v,w))
    ver[v].append((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 ver[u].append((v,w)) [u].append [u] ver u append (v,w) v w ver[v].append((u,w)) [v].append [v] ver v append (u,w) u w color = [-1]*(N+1) color [-1]*(N+1) [-1] -1 N+1 N 1 color[1] = 0 color[1] color 1 0 def dfs(fro,to,d):
    color[to] = d%2
    for v in ver[to]:
        if v[0] == fro:
            continue
        dfs(to,v[0],d+v[1]) dfs color[to] = d%2 color[to] color to d%2 d 2 for v in ver[to]:
        if v[0] == fro:
            continue
        dfs(to,v[0],d+v[1]) v ver[to] ver to if v[0] == fro:
            continue
         v[0] == fro v[0] v 0 fro continue dfs(to,v[0],d+v[1]) dfs to v[0] v 0 d+v[1] d v[1] v 1 fro fro to to d d for v in ver[1]:
    dfs(1,v[0],v[1]) v ver[1] ver 1 dfs(1,v[0],v[1]) dfs 1 v[0] v 0 v[1] v 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 ver = [[] for i in range(N+1)] [[] for i in range(N+1)] ver readline = sys.stdin.readline sys.stdin.readline readline N = int(readline()) int(readline()) N INF = 10**18 10**18 INF v,w = map(int,readline().split()) map(int,readline().split()) v mod = 10**9+7 10**9+7 mod w = map(int,readline().split()) map(int,readline().split()) w color = [-1]*(N+1) [-1]*(N+1) color u,v,w = map(int,readline().split()) map(int,readline().split()) u eps = 10**-7 10**-7 eps def dfs(fro,to,d):
    color[to] = d%2
    for v in ver[to]:
        if v[0] == fro:
            continue
        dfs(to,v[0],d+v[1]) def dfs(fro,to,d):
    color[to] = d%2
    for v in ver[to]:
        if v[0] == fro:
            continue
        dfs(to,v[0],d+v[1]) dfs
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())
ver = [[] for i in range(N+1)]
for i in range(N-1):
    u,v,w = map(int,readline().split())
    ver[u].append((v,w))
    ver[v].append((u,w))
color = [-1]*(N+1)
color[1] = 0
def dfs(fro,to,d):
    color[to] = d%2
    for v in ver[to]:
        if v[0] == fro:
            continue
        dfs(to,v[0],d+v[1])


for v in ver[1]:
    dfs(1,v[0],v[1])

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