n = int(input())
e = [list() for _ in range(n)]
for i in range(n-1):
    u,v,w = map(int,input().split())
    e[u-1] += [[v,w]]
    e[v-1] += [[u,w]]

visited = [-1]*n
stack = [0]
visited[0]=0
while stack:
    z = stack.pop()
    for v,w in e[z]:
        if visited[v-1]==-1:
            stack.append(v-1)
            if w%2==0:
                visited[v-1]=visited[z]
            else:
                visited[v-1]=1-visited[z]
        else:
            continue
print(*visited,sep="\n")  n = int(input()) n int(input()) int input() input list() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) list() list e = [list() for _ in range(n)] e [list() for _ in range(n)] for i in range(n-1):
    u,v,w = map(int,input().split())
    e[u-1] += [[v,w]]
    e[v-1] += [[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 e[u-1] += [[v,w]] e[u-1] e u-1 u 1 [[v,w]] [v,w] v w e[v-1] += [[u,w]] e[v-1] e v-1 v 1 [[u,w]] [u,w] u w visited = [-1]*n visited [-1]*n [-1] -1 n stack = [0] stack [0] 0 visited[0]=0 visited[0] visited 0 0 while stack:
    z = stack.pop()
    for v,w in e[z]:
        if visited[v-1]==-1:
            stack.append(v-1)
            if w%2==0:
                visited[v-1]=visited[z]
            else:
                visited[v-1]=1-visited[z]
        else:
            continue stack z = stack.pop() z stack.pop() stack.pop stack pop for v,w in e[z]:
        if visited[v-1]==-1:
            stack.append(v-1)
            if w%2==0:
                visited[v-1]=visited[z]
            else:
                visited[v-1]=1-visited[z]
        else:
            continue v w e[z] e z if visited[v-1]==-1:
            stack.append(v-1)
            if w%2==0:
                visited[v-1]=visited[z]
            else:
                visited[v-1]=1-visited[z]
        else:
            continue visited[v-1]==-1 visited[v-1] visited v-1 v 1 -1 stack.append(v-1) stack.append stack append v-1 v 1 if w%2==0:
                visited[v-1]=visited[z]
            else:
                visited[v-1]=1-visited[z]
         w%2==0 w%2 w 2 0 visited[v-1]=visited[z] visited[v-1] visited v-1 v 1 visited[z] visited z visited[v-1]=1-visited[z] visited[v-1] visited v-1 v 1 1-visited[z] 1 visited[z] visited z continue print(*visited,sep="\n") print *visited visited sep="\n" sep "\n" u,v,w = map(int,input().split()) map(int,input().split()) u v,w = map(int,input().split()) map(int,input().split()) v z = stack.pop() stack.pop() z e = [list() for _ in range(n)] [list() for _ in range(n)] e w = map(int,input().split()) map(int,input().split()) w n = int(input()) int(input()) n visited = [-1]*n [-1]*n visited stack = [0] [0] stack
n = int(input())
e = [list() for _ in range(n)]
for i in range(n-1):
    u,v,w = map(int,input().split())
    e[u-1] += [[v,w]]
    e[v-1] += [[u,w]]

visited = [-1]*n
stack = [0]
visited[0]=0
while stack:
    z = stack.pop()
    for v,w in e[z]:
        if visited[v-1]==-1:
            stack.append(v-1)
            if w%2==0:
                visited[v-1]=visited[z]
            else:
                visited[v-1]=1-visited[z]
        else:
            continue
print(*visited,sep="\n") 