from _collections import deque
N = int(input())
T = [[] for _ in range(N)]
for i in range(N-1):
    u,v,w = map(int,input().split())
    T[u-1].append([v-1,w%2])
    T[v-1].append([u-1,w%2])

ans = [0]*N
used_1 = [0]*N
used_2 = [0]*N
for i in range(N):
    if used_1[i] == 0:
        used_1[i] = 1
        u = i
        P = deque([])
        for j in range(len(T[i])):
            v = T[u][j][0]
            w = T[u][j][1]
            P.append(v)
            if used_2[v] == 1:
                k = ans[v]
                if k == 1:
                    if w == 1:
                        ans[u] = 0
                    else:
                        ans[u] = 1
                else:
                    if w == 1:
                        ans[u] = 1
                    else:
                        ans[u] = 0
                used_2[u] = 1
            elif used_2[u] == 1:
                k = ans[u]
                if k == 1:
                    if w == 1:
                        ans[v] = 0
                    else:
                        ans[v] = 1
                else:
                    if w == 1:
                        ans[v] = 1
                    else:
                        ans[v] = 0
                used_2[v] = 1
            else:
                if w == 1:
                    ans[v] = 1
                else:
                    pass
                used_2[u] = 1
                used_2[v] = 1
        while(True):
            i = P.popleft()
            if used_1[i] == 0:
                used_1[i] = 1
                u = i
                for j in range(len(T[i])):
                    v = T[u][j][0]
                    w = T[u][j][1]
                    P.append(v)
                    if used_2[v] == 1:
                        k = ans[v]
                        if k == 1:
                            if w == 1:
                                ans[u] = 0
                            else:
                                ans[u] = 1
                        else:
                            if w == 1:
                                ans[u] = 1
                            else:
                                ans[u] = 0
                        used_2[u] = 1
                    elif used_2[u] == 1:
                        k = ans[u]
                        if k == 1:
                            if w == 1:
                                ans[v] = 0
                            else:
                                ans[v] = 1
                        else:
                            if w == 1:
                                ans[v] = 1
                            else:
                                ans[v] = 0
                        used_2[v] = 1
                    else:
                        if w == 1:
                            ans[v] = 1
                        else:
                            pass
                        used_2[u] = 1
                        used_2[v] = 1
            if len(P) == 0:
                break

for i in ans:
    print(i) from _collections import deque 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) [] T = [[] for _ in range(N)] T [[] for _ in range(N)] for i in range(N-1):
    u,v,w = map(int,input().split())
    T[u-1].append([v-1,w%2])
    T[v-1].append([u-1,w%2]) 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 T[u-1].append([v-1,w%2]) [u-1].append [u-1] T u-1 u 1 append [v-1,w%2] v-1 v 1 w%2 w 2 T[v-1].append([u-1,w%2]) [v-1].append [v-1] T v-1 v 1 append [u-1,w%2] u-1 u 1 w%2 w 2 ans = [0]*N ans [0]*N [0] 0 N used_1 = [0]*N used_1 [0]*N [0] 0 N used_2 = [0]*N used_2 [0]*N [0] 0 N for i in range(N):
    if used_1[i] == 0:
        used_1[i] = 1
        u = i
        P = deque([])
        for j in range(len(T[i])):
            v = T[u][j][0]
            w = T[u][j][1]
            P.append(v)
            if used_2[v] == 1:
                k = ans[v]
                if k == 1:
                    if w == 1:
                        ans[u] = 0
                    else:
                        ans[u] = 1
                else:
                    if w == 1:
                        ans[u] = 1
                    else:
                        ans[u] = 0
                used_2[u] = 1
            elif used_2[u] == 1:
                k = ans[u]
                if k == 1:
                    if w == 1:
                        ans[v] = 0
                    else:
                        ans[v] = 1
                else:
                    if w == 1:
                        ans[v] = 1
                    else:
                        ans[v] = 0
                used_2[v] = 1
            else:
                if w == 1:
                    ans[v] = 1
                else:
                    pass
                used_2[u] = 1
                used_2[v] = 1
        while(True):
            i = P.popleft()
            if used_1[i] == 0:
                used_1[i] = 1
                u = i
                for j in range(len(T[i])):
                    v = T[u][j][0]
                    w = T[u][j][1]
                    P.append(v)
                    if used_2[v] == 1:
                        k = ans[v]
                        if k == 1:
                            if w == 1:
                                ans[u] = 0
                            else:
                                ans[u] = 1
                        else:
                            if w == 1:
                                ans[u] = 1
                            else:
                                ans[u] = 0
                        used_2[u] = 1
                    elif used_2[u] == 1:
                        k = ans[u]
                        if k == 1:
                            if w == 1:
                                ans[v] = 0
                            else:
                                ans[v] = 1
                        else:
                            if w == 1:
                                ans[v] = 1
                            else:
                                ans[v] = 0
                        used_2[v] = 1
                    else:
                        if w == 1:
                            ans[v] = 1
                        else:
                            pass
                        used_2[u] = 1
                        used_2[v] = 1
            if len(P) == 0:
                break i range(N) range N if used_1[i] == 0:
        used_1[i] = 1
        u = i
        P = deque([])
        for j in range(len(T[i])):
            v = T[u][j][0]
            w = T[u][j][1]
            P.append(v)
            if used_2[v] == 1:
                k = ans[v]
                if k == 1:
                    if w == 1:
                        ans[u] = 0
                    else:
                        ans[u] = 1
                else:
                    if w == 1:
                        ans[u] = 1
                    else:
                        ans[u] = 0
                used_2[u] = 1
            elif used_2[u] == 1:
                k = ans[u]
                if k == 1:
                    if w == 1:
                        ans[v] = 0
                    else:
                        ans[v] = 1
                else:
                    if w == 1:
                        ans[v] = 1
                    else:
                        ans[v] = 0
                used_2[v] = 1
            else:
                if w == 1:
                    ans[v] = 1
                else:
                    pass
                used_2[u] = 1
                used_2[v] = 1
        while(True):
            i = P.popleft()
            if used_1[i] == 0:
                used_1[i] = 1
                u = i
                for j in range(len(T[i])):
                    v = T[u][j][0]
                    w = T[u][j][1]
                    P.append(v)
                    if used_2[v] == 1:
                        k = ans[v]
                        if k == 1:
                            if w == 1:
                                ans[u] = 0
                            else:
                                ans[u] = 1
                        else:
                            if w == 1:
                                ans[u] = 1
                            else:
                                ans[u] = 0
                        used_2[u] = 1
                    elif used_2[u] == 1:
                        k = ans[u]
                        if k == 1:
                            if w == 1:
                                ans[v] = 0
                            else:
                                ans[v] = 1
                        else:
                            if w == 1:
                                ans[v] = 1
                            else:
                                ans[v] = 0
                        used_2[v] = 1
                    else:
                        if w == 1:
                            ans[v] = 1
                        else:
                            pass
                        used_2[u] = 1
                        used_2[v] = 1
            if len(P) == 0:
                break used_1[i] == 0 used_1[i] used_1 i 0 used_1[i] = 1 used_1[i] used_1 i 1 u = i u i P = deque([]) P deque([]) deque [] for j in range(len(T[i])):
            v = T[u][j][0]
            w = T[u][j][1]
            P.append(v)
            if used_2[v] == 1:
                k = ans[v]
                if k == 1:
                    if w == 1:
                        ans[u] = 0
                    else:
                        ans[u] = 1
                else:
                    if w == 1:
                        ans[u] = 1
                    else:
                        ans[u] = 0
                used_2[u] = 1
            elif used_2[u] == 1:
                k = ans[u]
                if k == 1:
                    if w == 1:
                        ans[v] = 0
                    else:
                        ans[v] = 1
                else:
                    if w == 1:
                        ans[v] = 1
                    else:
                        ans[v] = 0
                used_2[v] = 1
            else:
                if w == 1:
                    ans[v] = 1
                else:
                    pass
                used_2[u] = 1
                used_2[v] = 1
         j range(len(T[i])) range len(T[i]) len T[i] T i v = T[u][j][0] v T[u][j][0] [j] [u] T u j 0 w = T[u][j][1] w T[u][j][1] [j] [u] T u j 1 P.append(v) P.append P append v if used_2[v] == 1:
                k = ans[v]
                if k == 1:
                    if w == 1:
                        ans[u] = 0
                    else:
                        ans[u] = 1
                else:
                    if w == 1:
                        ans[u] = 1
                    else:
                        ans[u] = 0
                used_2[u] = 1
            elif used_2[u] == 1:
                k = ans[u]
                if k == 1:
                    if w == 1:
                        ans[v] = 0
                    else:
                        ans[v] = 1
                else:
                    if w == 1:
                        ans[v] = 1
                    else:
                        ans[v] = 0
                used_2[v] = 1
            else:
                if w == 1:
                    ans[v] = 1
                else:
                    pass
                used_2[u] = 1
                used_2[v] = 1
         used_2[v] == 1 used_2[v] used_2 v 1 k = ans[v] k ans[v] ans v if k == 1:
                    if w == 1:
                        ans[u] = 0
                    else:
                        ans[u] = 1
                else:
                    if w == 1:
                        ans[u] = 1
                    else:
                        ans[u] = 0
                 k == 1 k 1 if w == 1:
                        ans[u] = 0
                    else:
                        ans[u] = 1
                 w == 1 w 1 ans[u] = 0 ans[u] ans u 0 ans[u] = 1 ans[u] ans u 1 if w == 1:
                        ans[u] = 1
                    else:
                        ans[u] = 0
                 w == 1 w 1 ans[u] = 1 ans[u] ans u 1 ans[u] = 0 ans[u] ans u 0 used_2[u] = 1 used_2[u] used_2 u 1 elif used_2[u] == 1:
                k = ans[u]
                if k == 1:
                    if w == 1:
                        ans[v] = 0
                    else:
                        ans[v] = 1
                else:
                    if w == 1:
                        ans[v] = 1
                    else:
                        ans[v] = 0
                used_2[v] = 1
             used_2[u] == 1 used_2[u] used_2 u 1 k = ans[u] k ans[u] ans u if k == 1:
                    if w == 1:
                        ans[v] = 0
                    else:
                        ans[v] = 1
                else:
                    if w == 1:
                        ans[v] = 1
                    else:
                        ans[v] = 0
                 k == 1 k 1 if w == 1:
                        ans[v] = 0
                    else:
                        ans[v] = 1
                 w == 1 w 1 ans[v] = 0 ans[v] ans v 0 ans[v] = 1 ans[v] ans v 1 if w == 1:
                        ans[v] = 1
                    else:
                        ans[v] = 0
                 w == 1 w 1 ans[v] = 1 ans[v] ans v 1 ans[v] = 0 ans[v] ans v 0 used_2[v] = 1 used_2[v] used_2 v 1 if w == 1:
                    ans[v] = 1
                else:
                    pass
                 w == 1 w 1 ans[v] = 1 ans[v] ans v 1 used_2[u] = 1 used_2[u] used_2 u 1 used_2[v] = 1 used_2[v] used_2 v 1 while(True):
            i = P.popleft()
            if used_1[i] == 0:
                used_1[i] = 1
                u = i
                for j in range(len(T[i])):
                    v = T[u][j][0]
                    w = T[u][j][1]
                    P.append(v)
                    if used_2[v] == 1:
                        k = ans[v]
                        if k == 1:
                            if w == 1:
                                ans[u] = 0
                            else:
                                ans[u] = 1
                        else:
                            if w == 1:
                                ans[u] = 1
                            else:
                                ans[u] = 0
                        used_2[u] = 1
                    elif used_2[u] == 1:
                        k = ans[u]
                        if k == 1:
                            if w == 1:
                                ans[v] = 0
                            else:
                                ans[v] = 1
                        else:
                            if w == 1:
                                ans[v] = 1
                            else:
                                ans[v] = 0
                        used_2[v] = 1
                    else:
                        if w == 1:
                            ans[v] = 1
                        else:
                            pass
                        used_2[u] = 1
                        used_2[v] = 1
            if len(P) == 0:
                break True i = P.popleft() i P.popleft() P.popleft P popleft if used_1[i] == 0:
                used_1[i] = 1
                u = i
                for j in range(len(T[i])):
                    v = T[u][j][0]
                    w = T[u][j][1]
                    P.append(v)
                    if used_2[v] == 1:
                        k = ans[v]
                        if k == 1:
                            if w == 1:
                                ans[u] = 0
                            else:
                                ans[u] = 1
                        else:
                            if w == 1:
                                ans[u] = 1
                            else:
                                ans[u] = 0
                        used_2[u] = 1
                    elif used_2[u] == 1:
                        k = ans[u]
                        if k == 1:
                            if w == 1:
                                ans[v] = 0
                            else:
                                ans[v] = 1
                        else:
                            if w == 1:
                                ans[v] = 1
                            else:
                                ans[v] = 0
                        used_2[v] = 1
                    else:
                        if w == 1:
                            ans[v] = 1
                        else:
                            pass
                        used_2[u] = 1
                        used_2[v] = 1
             used_1[i] == 0 used_1[i] used_1 i 0 used_1[i] = 1 used_1[i] used_1 i 1 u = i u i for j in range(len(T[i])):
                    v = T[u][j][0]
                    w = T[u][j][1]
                    P.append(v)
                    if used_2[v] == 1:
                        k = ans[v]
                        if k == 1:
                            if w == 1:
                                ans[u] = 0
                            else:
                                ans[u] = 1
                        else:
                            if w == 1:
                                ans[u] = 1
                            else:
                                ans[u] = 0
                        used_2[u] = 1
                    elif used_2[u] == 1:
                        k = ans[u]
                        if k == 1:
                            if w == 1:
                                ans[v] = 0
                            else:
                                ans[v] = 1
                        else:
                            if w == 1:
                                ans[v] = 1
                            else:
                                ans[v] = 0
                        used_2[v] = 1
                    else:
                        if w == 1:
                            ans[v] = 1
                        else:
                            pass
                        used_2[u] = 1
                        used_2[v] = 1
             j range(len(T[i])) range len(T[i]) len T[i] T i v = T[u][j][0] v T[u][j][0] [j] [u] T u j 0 w = T[u][j][1] w T[u][j][1] [j] [u] T u j 1 P.append(v) P.append P append v if used_2[v] == 1:
                        k = ans[v]
                        if k == 1:
                            if w == 1:
                                ans[u] = 0
                            else:
                                ans[u] = 1
                        else:
                            if w == 1:
                                ans[u] = 1
                            else:
                                ans[u] = 0
                        used_2[u] = 1
                    elif used_2[u] == 1:
                        k = ans[u]
                        if k == 1:
                            if w == 1:
                                ans[v] = 0
                            else:
                                ans[v] = 1
                        else:
                            if w == 1:
                                ans[v] = 1
                            else:
                                ans[v] = 0
                        used_2[v] = 1
                    else:
                        if w == 1:
                            ans[v] = 1
                        else:
                            pass
                        used_2[u] = 1
                        used_2[v] = 1
             used_2[v] == 1 used_2[v] used_2 v 1 k = ans[v] k ans[v] ans v if k == 1:
                            if w == 1:
                                ans[u] = 0
                            else:
                                ans[u] = 1
                        else:
                            if w == 1:
                                ans[u] = 1
                            else:
                                ans[u] = 0
                         k == 1 k 1 if w == 1:
                                ans[u] = 0
                            else:
                                ans[u] = 1
                         w == 1 w 1 ans[u] = 0 ans[u] ans u 0 ans[u] = 1 ans[u] ans u 1 if w == 1:
                                ans[u] = 1
                            else:
                                ans[u] = 0
                         w == 1 w 1 ans[u] = 1 ans[u] ans u 1 ans[u] = 0 ans[u] ans u 0 used_2[u] = 1 used_2[u] used_2 u 1 elif used_2[u] == 1:
                        k = ans[u]
                        if k == 1:
                            if w == 1:
                                ans[v] = 0
                            else:
                                ans[v] = 1
                        else:
                            if w == 1:
                                ans[v] = 1
                            else:
                                ans[v] = 0
                        used_2[v] = 1
                     used_2[u] == 1 used_2[u] used_2 u 1 k = ans[u] k ans[u] ans u if k == 1:
                            if w == 1:
                                ans[v] = 0
                            else:
                                ans[v] = 1
                        else:
                            if w == 1:
                                ans[v] = 1
                            else:
                                ans[v] = 0
                         k == 1 k 1 if w == 1:
                                ans[v] = 0
                            else:
                                ans[v] = 1
                         w == 1 w 1 ans[v] = 0 ans[v] ans v 0 ans[v] = 1 ans[v] ans v 1 if w == 1:
                                ans[v] = 1
                            else:
                                ans[v] = 0
                         w == 1 w 1 ans[v] = 1 ans[v] ans v 1 ans[v] = 0 ans[v] ans v 0 used_2[v] = 1 used_2[v] used_2 v 1 if w == 1:
                            ans[v] = 1
                        else:
                            pass
                         w == 1 w 1 ans[v] = 1 ans[v] ans v 1 used_2[u] = 1 used_2[u] used_2 u 1 used_2[v] = 1 used_2[v] used_2 v 1 if len(P) == 0:
                break len(P) == 0 len(P) len P 0 break for i in ans:
    print(i) i ans print(i) print i used_1 = [0]*N [0]*N used_1 w = T[u][j][1] T[u][j][1] w u = i i u used_2 = [0]*N [0]*N used_2 v = T[u][j][0] T[u][j][0] v k = ans[u] ans[u] k v,w = map(int,input().split()) map(int,input().split()) v w = T[u][j][1] T[u][j][1] w k = ans[v] ans[v] k T = [[] for _ in range(N)] [[] for _ in range(N)] T u,v,w = map(int,input().split()) map(int,input().split()) u ans = [0]*N [0]*N ans v = T[u][j][0] T[u][j][0] v w = map(int,input().split()) map(int,input().split()) w i = P.popleft() P.popleft() i u = i i u k = ans[v] ans[v] k N = int(input()) int(input()) N k = ans[u] ans[u] k P = deque([]) deque([]) P
from _collections import deque
N = int(input())
T = [[] for _ in range(N)]
for i in range(N-1):
    u,v,w = map(int,input().split())
    T[u-1].append([v-1,w%2])
    T[v-1].append([u-1,w%2])

ans = [0]*N
used_1 = [0]*N
used_2 = [0]*N
for i in range(N):
    if used_1[i] == 0:
        used_1[i] = 1
        u = i
        P = deque([])
        for j in range(len(T[i])):
            v = T[u][j][0]
            w = T[u][j][1]
            P.append(v)
            if used_2[v] == 1:
                k = ans[v]
                if k == 1:
                    if w == 1:
                        ans[u] = 0
                    else:
                        ans[u] = 1
                else:
                    if w == 1:
                        ans[u] = 1
                    else:
                        ans[u] = 0
                used_2[u] = 1
            elif used_2[u] == 1:
                k = ans[u]
                if k == 1:
                    if w == 1:
                        ans[v] = 0
                    else:
                        ans[v] = 1
                else:
                    if w == 1:
                        ans[v] = 1
                    else:
                        ans[v] = 0
                used_2[v] = 1
            else:
                if w == 1:
                    ans[v] = 1
                else:
                    pass
                used_2[u] = 1
                used_2[v] = 1
        while(True):
            i = P.popleft()
            if used_1[i] == 0:
                used_1[i] = 1
                u = i
                for j in range(len(T[i])):
                    v = T[u][j][0]
                    w = T[u][j][1]
                    P.append(v)
                    if used_2[v] == 1:
                        k = ans[v]
                        if k == 1:
                            if w == 1:
                                ans[u] = 0
                            else:
                                ans[u] = 1
                        else:
                            if w == 1:
                                ans[u] = 1
                            else:
                                ans[u] = 0
                        used_2[u] = 1
                    elif used_2[u] == 1:
                        k = ans[u]
                        if k == 1:
                            if w == 1:
                                ans[v] = 0
                            else:
                                ans[v] = 1
                        else:
                            if w == 1:
                                ans[v] = 1
                            else:
                                ans[v] = 0
                        used_2[v] = 1
                    else:
                        if w == 1:
                            ans[v] = 1
                        else:
                            pass
                        used_2[u] = 1
                        used_2[v] = 1
            if len(P) == 0:
                break

for i in ans:
    print(i)