import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N = int(input())
tree = [[] for _ in range(N)]
for _ in range(N-1):
    u,v,w = map(int,(input().split()))
    tree[u-1].append((v-1,w))
    tree[v-1].append((u-1,w))
color = [-1]*N
black = 0
white = 1
color[0] = white
def dfs(cur,parent):
    li = tree[cur]
    for chi,dis in li:
        if chi == parent:
            continue
        if dis % 2 == 0:
            color[chi] = color[cur]
            dfs(chi,cur)
        else:
            if color[cur] == black:
                color[chi] = white
            else:
                color[chi] = black
            dfs(chi,cur)
dfs(0,-1)
for i in color:
    print(i) import sys sys input=sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 from itertools import accumulate from itertools import permutations from itertools import combinations from collections import defaultdict from collections import Counter import fractions fractions import math math from collections import deque from bisect import bisect_left from bisect import insort_left import itertools itertools from heapq import heapify from heapq import heappop from heapq import heappush import heapq heapq import numpy as np numpy INF = float("inf") INF float("inf") float "inf" 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) [] tree = [[] for _ in range(N)] tree [[] for _ in range(N)] for _ in range(N-1):
    u,v,w = map(int,(input().split()))
    tree[u-1].append((v-1,w))
    tree[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 tree[u-1].append((v-1,w)) [u-1].append [u-1] tree u-1 u 1 append (v-1,w) v-1 v 1 w tree[v-1].append((u-1,w)) [v-1].append [v-1] tree v-1 v 1 append (u-1,w) u-1 u 1 w color = [-1]*N color [-1]*N [-1] -1 N black = 0 black 0 white = 1 white 1 color[0] = white color[0] color 0 white def dfs(cur,parent):
    li = tree[cur]
    for chi,dis in li:
        if chi == parent:
            continue
        if dis % 2 == 0:
            color[chi] = color[cur]
            dfs(chi,cur)
        else:
            if color[cur] == black:
                color[chi] = white
            else:
                color[chi] = black
            dfs(chi,cur) dfs li = tree[cur] li tree[cur] tree cur for chi,dis in li:
        if chi == parent:
            continue
        if dis % 2 == 0:
            color[chi] = color[cur]
            dfs(chi,cur)
        else:
            if color[cur] == black:
                color[chi] = white
            else:
                color[chi] = black
            dfs(chi,cur) chi dis li if chi == parent:
            continue
         chi == parent chi parent continue if dis % 2 == 0:
            color[chi] = color[cur]
            dfs(chi,cur)
        else:
            if color[cur] == black:
                color[chi] = white
            else:
                color[chi] = black
            dfs(chi,cur) dis % 2 == 0 dis % 2 dis 2 0 color[chi] = color[cur] color[chi] color chi color[cur] color cur dfs(chi,cur) dfs chi cur if color[cur] == black:
                color[chi] = white
            else:
                color[chi] = black
             color[cur] == black color[cur] color cur black color[chi] = white color[chi] color chi white color[chi] = black color[chi] color chi black dfs(chi,cur) dfs chi cur cur cur parent parent dfs(0,-1) dfs 0 -1 for i in color:
    print(i) i color print(i) print i tree = [[] for _ in range(N)] [[] for _ in range(N)] tree v,w = map(int,(input().split())) map(int,(input().split())) v color = [-1]*N [-1]*N color white = 1 1 white def dfs(cur,parent):
    li = tree[cur]
    for chi,dis in li:
        if chi == parent:
            continue
        if dis % 2 == 0:
            color[chi] = color[cur]
            dfs(chi,cur)
        else:
            if color[cur] == black:
                color[chi] = white
            else:
                color[chi] = black
            dfs(chi,cur) def dfs(cur,parent):
    li = tree[cur]
    for chi,dis in li:
        if chi == parent:
            continue
        if dis % 2 == 0:
            color[chi] = color[cur]
            dfs(chi,cur)
        else:
            if color[cur] == black:
                color[chi] = white
            else:
                color[chi] = black
            dfs(chi,cur) dfs input=sys.stdin.readline sys.stdin.readline input N = int(input()) int(input()) N u,v,w = map(int,(input().split())) map(int,(input().split())) u w = map(int,(input().split())) map(int,(input().split())) w INF = float("inf") float("inf") INF black = 0 0 black
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N = int(input())
tree = [[] for _ in range(N)]
for _ in range(N-1):
    u,v,w = map(int,(input().split()))
    tree[u-1].append((v-1,w))
    tree[v-1].append((u-1,w))
color = [-1]*N
black = 0
white = 1
color[0] = white
def dfs(cur,parent):
    li = tree[cur]
    for chi,dis in li:
        if chi == parent:
            continue
        if dis % 2 == 0:
            color[chi] = color[cur]
            dfs(chi,cur)
        else:
            if color[cur] == black:
                color[chi] = white
            else:
                color[chi] = black
            dfs(chi,cur)
dfs(0,-1)
for i in color:
    print(i)