from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")
MOD = 1000000007


class Edge:
    def __init__(self, to, cost):
        self.to = to
        self.cost = cost


visited = []
vertex = []
def dfs(G, v, d):
    visited[v] = True
    if d % 2 == 0:
        vertex[v] = 0
    else:
        vertex[v] = 1

    for edge in G[v]:
        nv = edge.to
        if visited[nv]:
            continue
        nd = d + edge.cost
        dfs(G, nv, nd)


def main():
    N = int(input())
    G = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b, cost = map(int, input().split())
        a -= 1; b -= 1
        G[a].append(Edge(b, cost))
        G[b].append(Edge(a, cost))

    for _ in range(N):
        visited.append(False)
        vertex.append(0)
    
    dfs(G, 0, 0)

    for v in vertex:
        print(v)


if __name__ == '__main__':
    main() from functools import reduce from fractions import gcd import math math import bisect bisect import itertools itertools import sys sys sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline INF = float("inf") INF float("inf") float "inf" MOD = 1000000007 MOD 1000000007 class Edge:
    def __init__(self, to, cost):
        self.to = to
        self.cost = cost Edge def __init__(self, to, cost):
        self.to = to
        self.cost = cost __init__ self.to = to self.to self to to self.cost = cost self.cost self cost cost self self to to cost cost visited = [] visited [] vertex = [] vertex [] def dfs(G, v, d):
    visited[v] = True
    if d % 2 == 0:
        vertex[v] = 0
    else:
        vertex[v] = 1

    for edge in G[v]:
        nv = edge.to
        if visited[nv]:
            continue
        nd = d + edge.cost
        dfs(G, nv, nd) dfs visited[v] = True visited[v] visited v True if d % 2 == 0:
        vertex[v] = 0
    else:
        vertex[v] = 1

     d % 2 == 0 d % 2 d 2 0 vertex[v] = 0 vertex[v] vertex v 0 vertex[v] = 1 vertex[v] vertex v 1 for edge in G[v]:
        nv = edge.to
        if visited[nv]:
            continue
        nd = d + edge.cost
        dfs(G, nv, nd) edge G[v] G v nv = edge.to nv edge.to edge to if visited[nv]:
            continue
         visited[nv] visited nv continue nd = d + edge.cost nd d + edge.cost d edge.cost edge cost dfs(G, nv, nd) dfs G nv nd G G v v d d def main():
    N = int(input())
    G = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b, cost = map(int, input().split())
        a -= 1; b -= 1
        G[a].append(Edge(b, cost))
        G[b].append(Edge(a, cost))

    for _ in range(N):
        visited.append(False)
        vertex.append(0)
    
    dfs(G, 0, 0)

    for v in vertex:
        print(v) main 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):
        a, b, cost = map(int, input().split())
        a -= 1; b -= 1
        G[a].append(Edge(b, cost))
        G[b].append(Edge(a, cost))

     _ range(N-1) range N-1 N 1 a, b, cost = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b cost a -= 1 a 1 b -= 1 b 1 G[a].append(Edge(b, cost)) [a].append [a] G a append Edge(b, cost) Edge b cost G[b].append(Edge(a, cost)) [b].append [b] G b append Edge(a, cost) Edge a cost for _ in range(N):
        visited.append(False)
        vertex.append(0)
    
     _ range(N) range N visited.append(False) visited.append visited append False vertex.append(0) vertex.append vertex append 0 dfs(G, 0, 0) dfs G 0 0 for v in vertex:
        print(v) v vertex print(v) print v if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main INF = float("inf") float("inf") INF def main():
    N = int(input())
    G = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b, cost = map(int, input().split())
        a -= 1; b -= 1
        G[a].append(Edge(b, cost))
        G[b].append(Edge(a, cost))

    for _ in range(N):
        visited.append(False)
        vertex.append(0)
    
    dfs(G, 0, 0)

    for v in vertex:
        print(v) def main():
    N = int(input())
    G = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b, cost = map(int, input().split())
        a -= 1; b -= 1
        G[a].append(Edge(b, cost))
        G[b].append(Edge(a, cost))

    for _ in range(N):
        visited.append(False)
        vertex.append(0)
    
    dfs(G, 0, 0)

    for v in vertex:
        print(v) main input = sys.stdin.readline sys.stdin.readline input class Edge:
    def __init__(self, to, cost):
        self.to = to
        self.cost = cost class Edge:
    def __init__(self, to, cost):
        self.to = to
        self.cost = cost Edge visited = [] [] visited vertex = [] [] vertex def dfs(G, v, d):
    visited[v] = True
    if d % 2 == 0:
        vertex[v] = 0
    else:
        vertex[v] = 1

    for edge in G[v]:
        nv = edge.to
        if visited[nv]:
            continue
        nd = d + edge.cost
        dfs(G, nv, nd) def dfs(G, v, d):
    visited[v] = True
    if d % 2 == 0:
        vertex[v] = 0
    else:
        vertex[v] = 1

    for edge in G[v]:
        nv = edge.to
        if visited[nv]:
            continue
        nd = d + edge.cost
        dfs(G, nv, nd) dfs MOD = 1000000007 1000000007 MOD
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")
MOD = 1000000007


class Edge:
    def __init__(self, to, cost):
        self.to = to
        self.cost = cost


visited = []
vertex = []
def dfs(G, v, d):
    visited[v] = True
    if d % 2 == 0:
        vertex[v] = 0
    else:
        vertex[v] = 1

    for edge in G[v]:
        nv = edge.to
        if visited[nv]:
            continue
        nd = d + edge.cost
        dfs(G, nv, nd)


def main():
    N = int(input())
    G = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b, cost = map(int, input().split())
        a -= 1; b -= 1
        G[a].append(Edge(b, cost))
        G[b].append(Edge(a, cost))

    for _ in range(N):
        visited.append(False)
        vertex.append(0)
    
    dfs(G, 0, 0)

    for v in vertex:
        print(v)


if __name__ == '__main__':
    main()