import sys
import collections
def input():
    return sys.stdin.readline()[:-1]
sys.setrecursionlimit(10000000)

n = int(input())
g = [[]for i in range(n)]
for i in range(n-1):
    u,v,w = map(int,input().split())
    u-=1
    v-=1
    g[u].append([v,w])
    g[v].append([u,w])
lis = [-1 for i in range(n)]
def dfs(i,j,color):
    for nec,leng in g[i]:
        if nec==j:continue
        if leng%2==0:
            lis[nec] = color
            dfs(nec,i,color)
        else:
            lis[nec] = 1-color
            dfs(nec,i,1-color)
lis[0]=0
dfs(0,-1,0)

for i in range(n):
    print(lis[i]) import sys sys import collections collections def input():
    return sys.stdin.readline()[:-1] input return sys.stdin.readline()[:-1] sys.stdin.readline()[:-1] sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline :-1 -1 sys.setrecursionlimit(10000000) sys.setrecursionlimit sys setrecursionlimit 10000000 n = int(input()) n int(input()) int input() input []for i in range(n) for i in range(n) i range(n) range n for i in range(n) [] g = [[]for i in range(n)] g [[]for i in range(n)] for i in range(n-1):
    u,v,w = map(int,input().split())
    u-=1
    v-=1
    g[u].append([v,w])
    g[v].append([u,w]) i 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 u-=1 u 1 v-=1 v 1 g[u].append([v,w]) [u].append [u] g u append [v,w] v w g[v].append([u,w]) [v].append [v] g v append [u,w] u w -1 for i in range(n) for i in range(n) i range(n) range n for i in range(n) -1 lis = [-1 for i in range(n)] lis [-1 for i in range(n)] def dfs(i,j,color):
    for nec,leng in g[i]:
        if nec==j:continue
        if leng%2==0:
            lis[nec] = color
            dfs(nec,i,color)
        else:
            lis[nec] = 1-color
            dfs(nec,i,1-color) dfs for nec,leng in g[i]:
        if nec==j:continue
        if leng%2==0:
            lis[nec] = color
            dfs(nec,i,color)
        else:
            lis[nec] = 1-color
            dfs(nec,i,1-color) nec leng g[i] g i if nec==j:continue
         nec==j nec j if leng%2==0:
            lis[nec] = color
            dfs(nec,i,color)
        else:
            lis[nec] = 1-color
            dfs(nec,i,1-color) leng%2==0 leng%2 leng 2 0 lis[nec] = color lis[nec] lis nec color dfs(nec,i,color) dfs nec i color lis[nec] = 1-color lis[nec] lis nec 1-color 1 color dfs(nec,i,1-color) dfs nec i 1-color 1 color i i j j color color lis[0]=0 lis[0] lis 0 0 dfs(0,-1,0) dfs 0 -1 0 for i in range(n):
    print(lis[i]) i range(n) range n print(lis[i]) print lis[i] lis i g = [[]for i in range(n)] [[]for i in range(n)] g w = map(int,input().split()) map(int,input().split()) w lis = [-1 for i in range(n)] [-1 for i in range(n)] lis def dfs(i,j,color):
    for nec,leng in g[i]:
        if nec==j:continue
        if leng%2==0:
            lis[nec] = color
            dfs(nec,i,color)
        else:
            lis[nec] = 1-color
            dfs(nec,i,1-color) def dfs(i,j,color):
    for nec,leng in g[i]:
        if nec==j:continue
        if leng%2==0:
            lis[nec] = color
            dfs(nec,i,color)
        else:
            lis[nec] = 1-color
            dfs(nec,i,1-color) dfs u-=1 1 u n = int(input()) int(input()) n v,w = map(int,input().split()) map(int,input().split()) v v-=1 1 v u,v,w = map(int,input().split()) map(int,input().split()) u def input():
    return sys.stdin.readline()[:-1] def input():
    return sys.stdin.readline()[:-1] input
import sys
import collections
def input():
    return sys.stdin.readline()[:-1]
sys.setrecursionlimit(10000000)

n = int(input())
g = [[]for i in range(n)]
for i in range(n-1):
    u,v,w = map(int,input().split())
    u-=1
    v-=1
    g[u].append([v,w])
    g[v].append([u,w])
lis = [-1 for i in range(n)]
def dfs(i,j,color):
    for nec,leng in g[i]:
        if nec==j:continue
        if leng%2==0:
            lis[nec] = color
            dfs(nec,i,color)
        else:
            lis[nec] = 1-color
            dfs(nec,i,1-color)
lis[0]=0
dfs(0,-1,0)

for i in range(n):
    print(lis[i])
