#import math
#import itertools
from collections import deque

INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

class Graph():
    def __init__(self, v):
        self.v = v
        self.graph = [[] for _ in range(v)]
        self.INF = 10 ** 9
    
    def addEdge(self, start, end, dist):
        self.graph[start].append((end, dist))
        self.graph[end].append((start, dist))

def do():
    n=INT()
    g=Graph(n)
    for i in range(n-1):
        u,v,d=INTM()
        u-=1
        v-=1
        g.addEdge(u,v,d)

    que=deque()
    check=[True]*n
    dists=[-1]*n
    check[0]=False
    dists[0]=0
    que.append([0,0])
    while que:
        now,dist_f=que.popleft()
        for next,dist in g.graph[now]:
            if check[next]:
                check[next]=False
                temp=dist_f+dist
                dists[next]=temp
                que.append([next,temp])

    for i in dists:
        if i%2==0:
            print(0)
        else:
            print(1)
    
if __name__=='__main__':
    do() from collections import deque INT = lambda: int(input()) INT lambda: int(input()) int(input()) int input() input INTM = lambda: map(int,input().split()) INTM lambda: map(int,input().split()) map(int,input().split()) map int input().split() ().split () input split STRM = lambda: map(str,input().split()) STRM lambda: map(str,input().split()) map(str,input().split()) map str input().split() ().split () input split STR = lambda: str(input()) STR lambda: str(input()) str(input()) str input() input LIST = lambda: list(map(int,input().split())) LIST lambda: list(map(int,input().split())) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split LISTS = lambda: list(map(str,input().split())) LISTS lambda: list(map(str,input().split())) list(map(str,input().split())) list map(str,input().split()) map str input().split() ().split () input split class Graph():
    def __init__(self, v):
        self.v = v
        self.graph = [[] for _ in range(v)]
        self.INF = 10 ** 9
    
    def addEdge(self, start, end, dist):
        self.graph[start].append((end, dist))
        self.graph[end].append((start, dist)) Graph def __init__(self, v):
        self.v = v
        self.graph = [[] for _ in range(v)]
        self.INF = 10 ** 9
    
     __init__ self.v = v self.v self v v [] for _ in range(v) for _ in range(v) _ range(v) range v for _ in range(v) [] self.graph = [[] for _ in range(v)] self.graph self graph [[] for _ in range(v)] self.INF = 10 ** 9 self.INF self INF 10 ** 9 10 9 self self v v def addEdge(self, start, end, dist):
        self.graph[start].append((end, dist))
        self.graph[end].append((start, dist)) addEdge self.graph[start].append((end, dist)) self.graph[start].append self.graph[start] self.graph self graph start append (end, dist) end dist self.graph[end].append((start, dist)) self.graph[end].append self.graph[end] self.graph self graph end append (start, dist) start dist self self start start end end dist dist def do():
    n=INT()
    g=Graph(n)
    for i in range(n-1):
        u,v,d=INTM()
        u-=1
        v-=1
        g.addEdge(u,v,d)

    que=deque()
    check=[True]*n
    dists=[-1]*n
    check[0]=False
    dists[0]=0
    que.append([0,0])
    while que:
        now,dist_f=que.popleft()
        for next,dist in g.graph[now]:
            if check[next]:
                check[next]=False
                temp=dist_f+dist
                dists[next]=temp
                que.append([next,temp])

    for i in dists:
        if i%2==0:
            print(0)
        else:
            print(1)
     do n=INT() n INT() INT g=Graph(n) g Graph(n) Graph n for i in range(n-1):
        u,v,d=INTM()
        u-=1
        v-=1
        g.addEdge(u,v,d)

     i range(n-1) range n-1 n 1 u,v,d=INTM() u INTM() INTM v d u-=1 u 1 v-=1 v 1 g.addEdge(u,v,d) g.addEdge g addEdge u v d que=deque() que deque() deque check=[True]*n check [True]*n [True] True n dists=[-1]*n dists [-1]*n [-1] -1 n check[0]=False check[0] check 0 False dists[0]=0 dists[0] dists 0 0 que.append([0,0]) que.append que append [0,0] 0 0 while que:
        now,dist_f=que.popleft()
        for next,dist in g.graph[now]:
            if check[next]:
                check[next]=False
                temp=dist_f+dist
                dists[next]=temp
                que.append([next,temp])

     que now,dist_f=que.popleft() now que.popleft() que.popleft que popleft dist_f for next,dist in g.graph[now]:
            if check[next]:
                check[next]=False
                temp=dist_f+dist
                dists[next]=temp
                que.append([next,temp])

     next dist g.graph[now] g.graph g graph now if check[next]:
                check[next]=False
                temp=dist_f+dist
                dists[next]=temp
                que.append([next,temp])

     check[next] check next check[next]=False check[next] check next False temp=dist_f+dist temp dist_f+dist dist_f dist dists[next]=temp dists[next] dists next temp que.append([next,temp]) que.append que append [next,temp] next temp for i in dists:
        if i%2==0:
            print(0)
        else:
            print(1)
     i dists if i%2==0:
            print(0)
        else:
            print(1)
     i%2==0 i%2 i 2 0 print(0) print 0 print(1) print 1 if __name__=='__main__':
    do() __name__=='__main__' __name__ '__main__' do() do STR = lambda: str(input()) lambda: str(input()) STR LISTS = lambda: list(map(str,input().split())) lambda: list(map(str,input().split())) LISTS INT = lambda: int(input()) lambda: int(input()) INT class Graph():
    def __init__(self, v):
        self.v = v
        self.graph = [[] for _ in range(v)]
        self.INF = 10 ** 9
    
    def addEdge(self, start, end, dist):
        self.graph[start].append((end, dist))
        self.graph[end].append((start, dist)) class Graph():
    def __init__(self, v):
        self.v = v
        self.graph = [[] for _ in range(v)]
        self.INF = 10 ** 9
    
    def addEdge(self, start, end, dist):
        self.graph[start].append((end, dist))
        self.graph[end].append((start, dist)) Graph STRM = lambda: map(str,input().split()) lambda: map(str,input().split()) STRM def do():
    n=INT()
    g=Graph(n)
    for i in range(n-1):
        u,v,d=INTM()
        u-=1
        v-=1
        g.addEdge(u,v,d)

    que=deque()
    check=[True]*n
    dists=[-1]*n
    check[0]=False
    dists[0]=0
    que.append([0,0])
    while que:
        now,dist_f=que.popleft()
        for next,dist in g.graph[now]:
            if check[next]:
                check[next]=False
                temp=dist_f+dist
                dists[next]=temp
                que.append([next,temp])

    for i in dists:
        if i%2==0:
            print(0)
        else:
            print(1)
     def do():
    n=INT()
    g=Graph(n)
    for i in range(n-1):
        u,v,d=INTM()
        u-=1
        v-=1
        g.addEdge(u,v,d)

    que=deque()
    check=[True]*n
    dists=[-1]*n
    check[0]=False
    dists[0]=0
    que.append([0,0])
    while que:
        now,dist_f=que.popleft()
        for next,dist in g.graph[now]:
            if check[next]:
                check[next]=False
                temp=dist_f+dist
                dists[next]=temp
                que.append([next,temp])

    for i in dists:
        if i%2==0:
            print(0)
        else:
            print(1)
     do INTM = lambda: map(int,input().split()) lambda: map(int,input().split()) INTM LIST = lambda: list(map(int,input().split())) lambda: list(map(int,input().split())) LIST
#import math
#import itertools
from collections import deque

INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

class Graph():
    def __init__(self, v):
        self.v = v
        self.graph = [[] for _ in range(v)]
        self.INF = 10 ** 9
    
    def addEdge(self, start, end, dist):
        self.graph[start].append((end, dist))
        self.graph[end].append((start, dist))

def do():
    n=INT()
    g=Graph(n)
    for i in range(n-1):
        u,v,d=INTM()
        u-=1
        v-=1
        g.addEdge(u,v,d)

    que=deque()
    check=[True]*n
    dists=[-1]*n
    check[0]=False
    dists[0]=0
    que.append([0,0])
    while que:
        now,dist_f=que.popleft()
        for next,dist in g.graph[now]:
            if check[next]:
                check[next]=False
                temp=dist_f+dist
                dists[next]=temp
                que.append([next,temp])

    for i in dists:
        if i%2==0:
            print(0)
        else:
            print(1)
    
if __name__=='__main__':
    do()