import heapq

def dijkstra(G, s, dist):
    dist[s] = 0
    Q = [[0,s]]
    heapq.heapify(Q)

    while(len(Q) > 0):
        cur_d, cur_v = heapq.heappop(Q)
        cur_d *= -1
        
        if(cur_d > dist[cur_v]): continue

        for e in G[cur_v]:
            to, cost = e[0], e[1]
            if(dist[cur_v] + cost < dist[to]):
                dist[to] = dist[cur_v] + cost
                heapq.heappush(Q, [-dist[to], to])

N = int(input())

G = [[] for _ in range(N)]
for _ in range(N-1):
    u, v, w = map(int,input().split())
    u, v = u-1, v-1
    G[u].append([v,w])
    G[v].append([u,w])

dist = [1e18] * N
dijkstra(G,0,dist)

for d in dist:
    if d % 2 == 0:
        print(0)
    if d % 2 == 1:
        print(1)
 import heapq heapq def dijkstra(G, s, dist):
    dist[s] = 0
    Q = [[0,s]]
    heapq.heapify(Q)

    while(len(Q) > 0):
        cur_d, cur_v = heapq.heappop(Q)
        cur_d *= -1
        
        if(cur_d > dist[cur_v]): continue

        for e in G[cur_v]:
            to, cost = e[0], e[1]
            if(dist[cur_v] + cost < dist[to]):
                dist[to] = dist[cur_v] + cost
                heapq.heappush(Q, [-dist[to], to]) dijkstra dist[s] = 0 dist[s] dist s 0 Q = [[0,s]] Q [[0,s]] [0,s] 0 s heapq.heapify(Q) heapq.heapify heapq heapify Q while(len(Q) > 0):
        cur_d, cur_v = heapq.heappop(Q)
        cur_d *= -1
        
        if(cur_d > dist[cur_v]): continue

        for e in G[cur_v]:
            to, cost = e[0], e[1]
            if(dist[cur_v] + cost < dist[to]):
                dist[to] = dist[cur_v] + cost
                heapq.heappush(Q, [-dist[to], to]) len(Q) > 0 len(Q) len Q 0 cur_d, cur_v = heapq.heappop(Q) cur_d heapq.heappop(Q) heapq.heappop heapq heappop Q cur_v cur_d *= -1 cur_d -1 if(cur_d > dist[cur_v]): continue

         cur_d > dist[cur_v] cur_d dist[cur_v] dist cur_v for e in G[cur_v]:
            to, cost = e[0], e[1]
            if(dist[cur_v] + cost < dist[to]):
                dist[to] = dist[cur_v] + cost
                heapq.heappush(Q, [-dist[to], to]) e G[cur_v] G cur_v to, cost = e[0], e[1] to e[0] e 0 cost e[1] e 1 if(dist[cur_v] + cost < dist[to]):
                dist[to] = dist[cur_v] + cost
                heapq.heappush(Q, [-dist[to], to]) dist[cur_v] + cost < dist[to] dist[cur_v] + cost dist[cur_v] dist cur_v cost dist[to] dist to dist[to] = dist[cur_v] + cost dist[to] dist to dist[cur_v] + cost dist[cur_v] dist cur_v cost heapq.heappush(Q, [-dist[to], to]) heapq.heappush heapq heappush Q [-dist[to], to] -dist[to] dist[to] dist to to G G s s dist dist 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) [] G = [[] for _ in range(N)] G [[] for _ in range(N)] for _ in range(N-1):
    u, v, w = map(int,input().split())
    u, v = u-1, v-1
    G[u].append([v,w])
    G[v].append([u,w]) _ 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, v = u-1, v-1 u u-1 u 1 v v-1 v 1 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 dist = [1e18] * N dist [1e18] * N [1e18] 1e18 N dijkstra(G,0,dist) dijkstra G 0 dist for d in dist:
    if d % 2 == 0:
        print(0)
    if d % 2 == 1:
        print(1) d dist if d % 2 == 0:
        print(0)
     d % 2 == 0 d % 2 d 2 0 print(0) print 0 if d % 2 == 1:
        print(1) d % 2 == 1 d % 2 d 2 1 print(1) print 1 G = [[] for _ in range(N)] [[] for _ in range(N)] G v, w = map(int,input().split()) map(int,input().split()) v u, v = u-1, v-1 u-1 u v = u-1, v-1 v-1 v def dijkstra(G, s, dist):
    dist[s] = 0
    Q = [[0,s]]
    heapq.heapify(Q)

    while(len(Q) > 0):
        cur_d, cur_v = heapq.heappop(Q)
        cur_d *= -1
        
        if(cur_d > dist[cur_v]): continue

        for e in G[cur_v]:
            to, cost = e[0], e[1]
            if(dist[cur_v] + cost < dist[to]):
                dist[to] = dist[cur_v] + cost
                heapq.heappush(Q, [-dist[to], to]) def dijkstra(G, s, dist):
    dist[s] = 0
    Q = [[0,s]]
    heapq.heapify(Q)

    while(len(Q) > 0):
        cur_d, cur_v = heapq.heappop(Q)
        cur_d *= -1
        
        if(cur_d > dist[cur_v]): continue

        for e in G[cur_v]:
            to, cost = e[0], e[1]
            if(dist[cur_v] + cost < dist[to]):
                dist[to] = dist[cur_v] + cost
                heapq.heappush(Q, [-dist[to], to]) dijkstra N = int(input()) int(input()) N u, v, w = map(int,input().split()) map(int,input().split()) u w = map(int,input().split()) map(int,input().split()) w dist = [1e18] * N [1e18] * N dist
import heapq

def dijkstra(G, s, dist):
    dist[s] = 0
    Q = [[0,s]]
    heapq.heapify(Q)

    while(len(Q) > 0):
        cur_d, cur_v = heapq.heappop(Q)
        cur_d *= -1
        
        if(cur_d > dist[cur_v]): continue

        for e in G[cur_v]:
            to, cost = e[0], e[1]
            if(dist[cur_v] + cost < dist[to]):
                dist[to] = dist[cur_v] + cost
                heapq.heappush(Q, [-dist[to], to])

N = int(input())

G = [[] for _ in range(N)]
for _ in range(N-1):
    u, v, w = map(int,input().split())
    u, v = u-1, v-1
    G[u].append([v,w])
    G[v].append([u,w])

dist = [1e18] * N
dijkstra(G,0,dist)

for d in dist:
    if d % 2 == 0:
        print(0)
    if d % 2 == 1:
        print(1)

