n = int(input())
uv = [[] for _ in range(n+1)]
for i in range(n-1):
    u,v,w = map(int, input().split())
    uv[u].append([v,w])
    uv[v].append([u,w])
stack = [1]
ans = [-1]*(n+1)
ans[1]=0
while stack:
    x = stack.pop()
    for j,k in uv[x]:
        if ans[j] == -1:
            if k % 2 ==0:
                ans[j] = ans[x]
            else:
                ans[j] = (ans[x]+1)%2
            stack.append(j)
for m in range(n):
    print(ans[m+1]) n = int(input()) n int(input()) int input() input [] for _ in range(n+1) for _ in range(n+1) _ range(n+1) range n+1 n 1 for _ in range(n+1) [] uv = [[] for _ in range(n+1)] uv [[] for _ in range(n+1)] for i in range(n-1):
    u,v,w = map(int, input().split())
    uv[u].append([v,w])
    uv[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 uv[u].append([v,w]) [u].append [u] uv u append [v,w] v w uv[v].append([u,w]) [v].append [v] uv v append [u,w] u w stack = [1] stack [1] 1 ans = [-1]*(n+1) ans [-1]*(n+1) [-1] -1 n+1 n 1 ans[1]=0 ans[1] ans 1 0 while stack:
    x = stack.pop()
    for j,k in uv[x]:
        if ans[j] == -1:
            if k % 2 ==0:
                ans[j] = ans[x]
            else:
                ans[j] = (ans[x]+1)%2
            stack.append(j) stack x = stack.pop() x stack.pop() stack.pop stack pop for j,k in uv[x]:
        if ans[j] == -1:
            if k % 2 ==0:
                ans[j] = ans[x]
            else:
                ans[j] = (ans[x]+1)%2
            stack.append(j) j k uv[x] uv x if ans[j] == -1:
            if k % 2 ==0:
                ans[j] = ans[x]
            else:
                ans[j] = (ans[x]+1)%2
            stack.append(j) ans[j] == -1 ans[j] ans j -1 if k % 2 ==0:
                ans[j] = ans[x]
            else:
                ans[j] = (ans[x]+1)%2
             k % 2 ==0 k % 2 k 2 0 ans[j] = ans[x] ans[j] ans j ans[x] ans x ans[j] = (ans[x]+1)%2 ans[j] ans j (ans[x]+1)%2 ans[x]+1 ans[x] ans x 1 2 stack.append(j) stack.append stack append j for m in range(n):
    print(ans[m+1]) m range(n) range n print(ans[m+1]) print ans[m+1] ans m+1 m 1 n = int(input()) int(input()) n stack = [1] [1] stack ans = [-1]*(n+1) [-1]*(n+1) ans uv = [[] for _ in range(n+1)] [[] for _ in range(n+1)] uv x = stack.pop() stack.pop() x u,v,w = map(int, input().split()) map(int, input().split()) u w = map(int, input().split()) map(int, input().split()) w v,w = map(int, input().split()) map(int, input().split()) v
n = int(input())
uv = [[] for _ in range(n+1)]
for i in range(n-1):
    u,v,w = map(int, input().split())
    uv[u].append([v,w])
    uv[v].append([u,w])
stack = [1]
ans = [-1]*(n+1)
ans[1]=0
while stack:
    x = stack.pop()
    for j,k in uv[x]:
        if ans[j] == -1:
            if k % 2 ==0:
                ans[j] = ans[x]
            else:
                ans[j] = (ans[x]+1)%2
            stack.append(j)
for m in range(n):
    print(ans[m+1])