n = int(input())
g = [[]for i in range(n)]
def swap(n):
    if n == 1:
        return 0
    else:
        return 1
for i in range(n-1):
    u,v,w = map(int,input().split())
    u = u-1
    v = v-1
    w = w%2
    g[u].append([v,w])
    g[v].append([u,w])
ans = [-1 for i in range(n)]
from collections import deque
d = deque([[0,0]]) #左は頂点の数字、右は塗った色
while d:
    p,q = d.pop()
    ans[p] = q
    for j,w in g[p]:
        if ans[j] != -1:
            continue
        else:
            if w == 1:
                d.append([j,swap(q)])
            else:
                d.append([j,q])
for i in range(n):
    print(ans[i]) n = int(input()) n int(input()) int input() input []for i in range(n) for i in range(n) i range(n) range n for i in range(n) [] g = [[]for i in range(n)] g [[]for i in range(n)] def swap(n):
    if n == 1:
        return 0
    else:
        return 1 swap if n == 1:
        return 0
    else:
        return 1 n == 1 n 1 return 0 0 return 1 1 n n for i in range(n-1):
    u,v,w = map(int,input().split())
    u = u-1
    v = v-1
    w = w%2
    g[u].append([v,w])
    g[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 u = u-1 u u-1 u 1 v = v-1 v v-1 v 1 w = w%2 w w%2 w 2 g[u].append([v,w]) [u].append [u] g u append [v,w] v w g[v].append([u,w]) [v].append [v] g v append [u,w] u w -1 for i in range(n) for i in range(n) i range(n) range n for i in range(n) -1 ans = [-1 for i in range(n)] ans [-1 for i in range(n)] from collections import deque d = deque([[0,0]]) d deque([[0,0]]) deque [[0,0]] [0,0] 0 0 while d:
    p,q = d.pop()
    ans[p] = q
    for j,w in g[p]:
        if ans[j] != -1:
            continue
        else:
            if w == 1:
                d.append([j,swap(q)])
            else:
                d.append([j,q]) d p,q = d.pop() p d.pop() d.pop d pop q ans[p] = q ans[p] ans p q for j,w in g[p]:
        if ans[j] != -1:
            continue
        else:
            if w == 1:
                d.append([j,swap(q)])
            else:
                d.append([j,q]) j w g[p] g p if ans[j] != -1:
            continue
        else:
            if w == 1:
                d.append([j,swap(q)])
            else:
                d.append([j,q]) ans[j] != -1 ans[j] ans j -1 continue if w == 1:
                d.append([j,swap(q)])
            else:
                d.append([j,q]) w == 1 w 1 d.append([j,swap(q)]) d.append d append [j,swap(q)] j swap(q) swap q d.append([j,q]) d.append d append [j,q] j q for i in range(n):
    print(ans[i]) i range(n) range n print(ans[i]) print ans[i] ans i u = u-1 u-1 u v,w = map(int,input().split()) map(int,input().split()) v u,v,w = map(int,input().split()) map(int,input().split()) u w = map(int,input().split()) map(int,input().split()) w v = v-1 v-1 v d = deque([[0,0]]) deque([[0,0]]) d q = d.pop() d.pop() q p,q = d.pop() d.pop() p ans = [-1 for i in range(n)] [-1 for i in range(n)] ans n = int(input()) int(input()) n w = w%2 w%2 w def swap(n):
    if n == 1:
        return 0
    else:
        return 1 def swap(n):
    if n == 1:
        return 0
    else:
        return 1 swap g = [[]for i in range(n)] [[]for i in range(n)] g
n = int(input())
g = [[]for i in range(n)]
def swap(n):
    if n == 1:
        return 0
    else:
        return 1
for i in range(n-1):
    u,v,w = map(int,input().split())
    u = u-1
    v = v-1
    w = w%2
    g[u].append([v,w])
    g[v].append([u,w])
ans = [-1 for i in range(n)]
from collections import deque
d = deque([[0,0]]) #左は頂点の数字、右は塗った色
while d:
    p,q = d.pop()
    ans[p] = q
    for j,w in g[p]:
        if ans[j] != -1:
            continue
        else:
            if w == 1:
                d.append([j,swap(q)])
            else:
                d.append([j,q])
for i in range(n):
    print(ans[i])