import sys
from collections import deque
readline = sys.stdin.readline
n = int(readline())
G = [[] for _ in range(n)]
for _ in range(n-1):
    u,v,w = map(int, readline().split())
    G[u-1].append((v-1,w))
    G[v-1].append((u-1,w))

V = [-1]*n
V[0] = 0
que = deque([0])
while que:
    nw = que.popleft()
    for nx,d in G[nw]:
        if V[nx]!=-1: continue
        V[nx] = (V[nw]+d)%2
        que.append(nx)

for v in V:
    print(v) import sys sys from collections import deque readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline n = int(readline()) n int(readline()) int readline() readline [] for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) [] G = [[] for _ in range(n)] G [[] for _ in range(n)] for _ in range(n-1):
    u,v,w = map(int, readline().split())
    G[u-1].append((v-1,w))
    G[v-1].append((u-1,w)) _ 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 G[u-1].append((v-1,w)) [u-1].append [u-1] G u-1 u 1 append (v-1,w) v-1 v 1 w G[v-1].append((u-1,w)) [v-1].append [v-1] G v-1 v 1 append (u-1,w) u-1 u 1 w V = [-1]*n V [-1]*n [-1] -1 n V[0] = 0 V[0] V 0 0 que = deque([0]) que deque([0]) deque [0] 0 while que:
    nw = que.popleft()
    for nx,d in G[nw]:
        if V[nx]!=-1: continue
        V[nx] = (V[nw]+d)%2
        que.append(nx) que nw = que.popleft() nw que.popleft() que.popleft que popleft for nx,d in G[nw]:
        if V[nx]!=-1: continue
        V[nx] = (V[nw]+d)%2
        que.append(nx) nx d G[nw] G nw if V[nx]!=-1: continue
         V[nx]!=-1 V[nx] V nx -1 V[nx] = (V[nw]+d)%2 V[nx] V nx (V[nw]+d)%2 V[nw]+d V[nw] V nw d 2 que.append(nx) que.append que append nx for v in V:
    print(v) v V print(v) print v w = map(int, readline().split()) map(int, readline().split()) w V = [-1]*n [-1]*n V nw = que.popleft() que.popleft() nw n = int(readline()) int(readline()) n que = deque([0]) deque([0]) que v,w = map(int, readline().split()) map(int, readline().split()) v readline = sys.stdin.readline sys.stdin.readline readline G = [[] for _ in range(n)] [[] for _ in range(n)] G u,v,w = map(int, readline().split()) map(int, readline().split()) u
import sys
from collections import deque
readline = sys.stdin.readline
n = int(readline())
G = [[] for _ in range(n)]
for _ in range(n-1):
    u,v,w = map(int, readline().split())
    G[u-1].append((v-1,w))
    G[v-1].append((u-1,w))

V = [-1]*n
V[0] = 0
que = deque([0])
while que:
    nw = que.popleft()
    for nx,d in G[nw]:
        if V[nx]!=-1: continue
        V[nx] = (V[nw]+d)%2
        que.append(nx)

for v in V:
    print(v)