import sys
input = sys.stdin.readline
from collections import deque
def bfs(now):
    plan = deque()
    plan.append(now)
    while plan:
        now = plan.popleft()
        color = COLOR[now]
        for bady, l in LINK[now]:
            if COLOR[bady] != -1:
                continue
            plan.append(bady)
            if l%2:
                COLOR[bady] = 1 - color
            else:
                COLOR[bady] = color

if __name__ == '__main__':
    N = int(input())
    LINK = [[]*(N+1) for i in range(N+1)]
    # LINK = [deque()*(N+1) for i in range(N+1)]
    for i in range(N-1):
        a, b, l = map(int, input().split())
        LINK[a].append([b, l])
        LINK[b].append([a, l])
    # print(LINK)
    # print(LINK[1])
    # print(LINK[1][0])
    COLOR= [-1]*(N+1)
    COLOR[1] = 1
    bfs(1)
    for i in range(1,N+1):
        print(COLOR[i]) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline from collections import deque def bfs(now):
    plan = deque()
    plan.append(now)
    while plan:
        now = plan.popleft()
        color = COLOR[now]
        for bady, l in LINK[now]:
            if COLOR[bady] != -1:
                continue
            plan.append(bady)
            if l%2:
                COLOR[bady] = 1 - color
            else:
                COLOR[bady] = color bfs plan = deque() plan deque() deque plan.append(now) plan.append plan append now while plan:
        now = plan.popleft()
        color = COLOR[now]
        for bady, l in LINK[now]:
            if COLOR[bady] != -1:
                continue
            plan.append(bady)
            if l%2:
                COLOR[bady] = 1 - color
            else:
                COLOR[bady] = color plan now = plan.popleft() now plan.popleft() plan.popleft plan popleft color = COLOR[now] color COLOR[now] COLOR now for bady, l in LINK[now]:
            if COLOR[bady] != -1:
                continue
            plan.append(bady)
            if l%2:
                COLOR[bady] = 1 - color
            else:
                COLOR[bady] = color bady l LINK[now] LINK now if COLOR[bady] != -1:
                continue
             COLOR[bady] != -1 COLOR[bady] COLOR bady -1 continue plan.append(bady) plan.append plan append bady if l%2:
                COLOR[bady] = 1 - color
            else:
                COLOR[bady] = color l%2 l 2 COLOR[bady] = 1 - color COLOR[bady] COLOR bady 1 - color 1 color COLOR[bady] = color COLOR[bady] COLOR bady color now now if __name__ == '__main__':
    N = int(input())
    LINK = [[]*(N+1) for i in range(N+1)]
    # LINK = [deque()*(N+1) for i in range(N+1)]
    for i in range(N-1):
        a, b, l = map(int, input().split())
        LINK[a].append([b, l])
        LINK[b].append([a, l])
    # print(LINK)
    # print(LINK[1])
    # print(LINK[1][0])
    COLOR= [-1]*(N+1)
    COLOR[1] = 1
    bfs(1)
    for i in range(1,N+1):
        print(COLOR[i]) __name__ == '__main__' __name__ '__main__' N = int(input()) N int(input()) int input() input []*(N+1) for i in range(N+1) for i in range(N+1) i range(N+1) range N+1 N 1 for i in range(N+1) []*(N+1) [] N+1 N 1 LINK = [[]*(N+1) for i in range(N+1)] LINK [[]*(N+1) for i in range(N+1)] for i in range(N-1):
        a, b, l = map(int, input().split())
        LINK[a].append([b, l])
        LINK[b].append([a, l])
    # print(LINK)
    # print(LINK[1])
    # print(LINK[1][0])
     i range(N-1) range N-1 N 1 a, b, l = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b l LINK[a].append([b, l]) [a].append [a] LINK a append [b, l] b l LINK[b].append([a, l]) [b].append [b] LINK b append [a, l] a l COLOR= [-1]*(N+1) COLOR [-1]*(N+1) [-1] -1 N+1 N 1 COLOR[1] = 1 COLOR[1] COLOR 1 1 bfs(1) bfs 1 for i in range(1,N+1):
        print(COLOR[i]) i range(1,N+1) range 1 N+1 N 1 print(COLOR[i]) print COLOR[i] COLOR i COLOR= [-1]*(N+1) [-1]*(N+1) COLOR a, b, l = map(int, input().split()) map(int, input().split()) a input = sys.stdin.readline sys.stdin.readline input b, l = map(int, input().split()) map(int, input().split()) b def bfs(now):
    plan = deque()
    plan.append(now)
    while plan:
        now = plan.popleft()
        color = COLOR[now]
        for bady, l in LINK[now]:
            if COLOR[bady] != -1:
                continue
            plan.append(bady)
            if l%2:
                COLOR[bady] = 1 - color
            else:
                COLOR[bady] = color def bfs(now):
    plan = deque()
    plan.append(now)
    while plan:
        now = plan.popleft()
        color = COLOR[now]
        for bady, l in LINK[now]:
            if COLOR[bady] != -1:
                continue
            plan.append(bady)
            if l%2:
                COLOR[bady] = 1 - color
            else:
                COLOR[bady] = color bfs l = map(int, input().split()) map(int, input().split()) l N = int(input()) int(input()) N LINK = [[]*(N+1) for i in range(N+1)] [[]*(N+1) for i in range(N+1)] LINK
import sys
input = sys.stdin.readline
from collections import deque
def bfs(now):
    plan = deque()
    plan.append(now)
    while plan:
        now = plan.popleft()
        color = COLOR[now]
        for bady, l in LINK[now]:
            if COLOR[bady] != -1:
                continue
            plan.append(bady)
            if l%2:
                COLOR[bady] = 1 - color
            else:
                COLOR[bady] = color

if __name__ == '__main__':
    N = int(input())
    LINK = [[]*(N+1) for i in range(N+1)]
    # LINK = [deque()*(N+1) for i in range(N+1)]
    for i in range(N-1):
        a, b, l = map(int, input().split())
        LINK[a].append([b, l])
        LINK[b].append([a, l])
    # print(LINK)
    # print(LINK[1])
    # print(LINK[1][0])
    COLOR= [-1]*(N+1)
    COLOR[1] = 1
    bfs(1)
    for i in range(1,N+1):
        print(COLOR[i])