n=int(input())
col=[-1]*n
e=[[[],[]]for i in range(n)]
for i in range(n-1):
    u,v,w=map(int,input().split())
    u-=1
    v-=1
    w%=2
    e[u][w].append(v)
    e[v][w].append(u)
col[0]=1
from collections import deque
dq=deque([])
#pop/append/(append,pop)_left/in/len/count/[]/index/rotate()(右へnずらす)
dq.append(0)
while dq:
    a=dq.pop()
    b=col[a]
    for i in range(2):
        for ne in e[a][i]:
            if col[ne]==-1:
                col[ne]=b^i
                dq.appendleft(ne)
print(*col,sep='\n') n=int(input()) n int(input()) int input() input col=[-1]*n col [-1]*n [-1] -1 n [[],[]]for i in range(n) for i in range(n) i range(n) range n for i in range(n) [[],[]] [] [] e=[[[],[]]for i in range(n)] e [[[],[]]for i in range(n)] for i in range(n-1):
    u,v,w=map(int,input().split())
    u-=1
    v-=1
    w%=2
    e[u][w].append(v)
    e[v][w].append(u) 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 w%=2 w 2 e[u][w].append(v) [w].append [w] [u] e u w append v e[v][w].append(u) [w].append [w] [v] e v w append u col[0]=1 col[0] col 0 1 from collections import deque dq=deque([]) dq deque([]) deque [] dq.append(0) dq.append dq append 0 while dq:
    a=dq.pop()
    b=col[a]
    for i in range(2):
        for ne in e[a][i]:
            if col[ne]==-1:
                col[ne]=b^i
                dq.appendleft(ne) dq a=dq.pop() a dq.pop() dq.pop dq pop b=col[a] b col[a] col a for i in range(2):
        for ne in e[a][i]:
            if col[ne]==-1:
                col[ne]=b^i
                dq.appendleft(ne) i range(2) range 2 for ne in e[a][i]:
            if col[ne]==-1:
                col[ne]=b^i
                dq.appendleft(ne) ne e[a][i] [a] e a i if col[ne]==-1:
                col[ne]=b^i
                dq.appendleft(ne) col[ne]==-1 col[ne] col ne -1 col[ne]=b^i col[ne] col ne b^i b i dq.appendleft(ne) dq.appendleft dq appendleft ne print(*col,sep='\n') print *col col sep='\n' sep '\n' w=map(int,input().split()) map(int,input().split()) w n=int(input()) int(input()) n col=[-1]*n [-1]*n col u-=1 1 u w%=2 2 w e=[[[],[]]for i in range(n)] [[[],[]]for i in range(n)] e a=dq.pop() dq.pop() a v,w=map(int,input().split()) map(int,input().split()) v dq=deque([]) deque([]) dq b=col[a] col[a] b u,v,w=map(int,input().split()) map(int,input().split()) u v-=1 1 v
n=int(input())
col=[-1]*n
e=[[[],[]]for i in range(n)]
for i in range(n-1):
    u,v,w=map(int,input().split())
    u-=1
    v-=1
    w%=2
    e[u][w].append(v)
    e[v][w].append(u)
col[0]=1
from collections import deque
dq=deque([])
#pop/append/(append,pop)_left/in/len/count/[]/index/rotate()(右へnずらす)
dq.append(0)
while dq:
    a=dq.pop()
    b=col[a]
    for i in range(2):
        for ne in e[a][i]:
            if col[ne]==-1:
                col[ne]=b^i
                dq.appendleft(ne)
print(*col,sep='\n')