import sys
sys.setrecursionlimit(500*500)
n = int(input())
a = [[] for _ in range(n)]; b = [-1]*n; b[0] = 0
for i in range(n-1):
    u, v, w = map(int, input().split())
    a[u-1].append([v-1, w]); a[v-1].append([u-1, w])
def dfs(A, k):
    for i in A[k]:
        if b[i[0]] == -1:
            b[i[0]] = b[k]+i[1]
            dfs(A, i[0])
dfs(a, 0)
for i in b:
    print(0) if i%2 == 0 else print(1) import sys sys sys.setrecursionlimit(500*500) sys.setrecursionlimit sys setrecursionlimit 500*500 500 500 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) [] a = [[] for _ in range(n)] a [[] for _ in range(n)] b = [-1]*n b [-1]*n [-1] -1 n b[0] = 0 b[0] b 0 0 for i in range(n-1):
    u, v, w = map(int, input().split())
    a[u-1].append([v-1, w]); a[v-1].append([u-1, 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 a[u-1].append([v-1, w]) [u-1].append [u-1] a u-1 u 1 append [v-1, w] v-1 v 1 w a[v-1].append([u-1, w]) [v-1].append [v-1] a v-1 v 1 append [u-1, w] u-1 u 1 w def dfs(A, k):
    for i in A[k]:
        if b[i[0]] == -1:
            b[i[0]] = b[k]+i[1]
            dfs(A, i[0]) dfs for i in A[k]:
        if b[i[0]] == -1:
            b[i[0]] = b[k]+i[1]
            dfs(A, i[0]) i A[k] A k if b[i[0]] == -1:
            b[i[0]] = b[k]+i[1]
            dfs(A, i[0]) b[i[0]] == -1 b[i[0]] b i[0] i 0 -1 b[i[0]] = b[k]+i[1] b[i[0]] b i[0] i 0 b[k]+i[1] b[k] b k i[1] i 1 dfs(A, i[0]) dfs A i[0] i 0 A A k k dfs(a, 0) dfs a 0 for i in b:
    print(0) if i%2 == 0 else print(1) i b print(0) if i%2 == 0 else print(1) i%2 == 0 i%2 i 2 0 print(0) print 0 print(1) print 1 n = int(input()) int(input()) n a = [[] for _ in range(n)] [[] for _ in range(n)] a v, w = map(int, input().split()) map(int, input().split()) v w = map(int, input().split()) map(int, input().split()) w u, v, w = map(int, input().split()) map(int, input().split()) u def dfs(A, k):
    for i in A[k]:
        if b[i[0]] == -1:
            b[i[0]] = b[k]+i[1]
            dfs(A, i[0]) def dfs(A, k):
    for i in A[k]:
        if b[i[0]] == -1:
            b[i[0]] = b[k]+i[1]
            dfs(A, i[0]) dfs b = [-1]*n [-1]*n b
import sys
sys.setrecursionlimit(500*500)
n = int(input())
a = [[] for _ in range(n)]; b = [-1]*n; b[0] = 0
for i in range(n-1):
    u, v, w = map(int, input().split())
    a[u-1].append([v-1, w]); a[v-1].append([u-1, w])
def dfs(A, k):
    for i in A[k]:
        if b[i[0]] == -1:
            b[i[0]] = b[k]+i[1]
            dfs(A, i[0])
dfs(a, 0)
for i in b:
    print(0) if i%2 == 0 else print(1)