import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    edge = [[] for i in range(N)]
    for i in range(N-1):#木の場合M=N-1
        a,b,w = map(int,input().split())
        edge[a-1].append((w,b-1))
        edge[b-1].append((w,a-1)) #有向のばあいコメントアウト

    def dfs():
        q=deque([(0,0)])
        visited=[False]*N
        while len(q):
            e,w=q.pop()#ここをpopleftにすると幅優先探索BFSになる
            if visited[e]:continue
            visited[e]=1 if w%2==0 else 2
            for dw,ne in edge[e]:
                q.append((ne,w+dw))
        return visited
    x=dfs()
    for xi in x:
        if xi==1:
            print(0)
        else:
            print(1)



if __name__ == "__main__":
    main() import sys sys sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 import math math from copy import copy, deepcopy from copy import deepcopy as dcp from operator import itemgetter from bisect import bisect_left, bisect, bisect_right from collections import deque from collections import Counter from itertools import accumulate,combinations,permutations from heapq import heapify,heappop,heappush from functools import lru_cache from decimal import Decimal def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x input x=sys.stdin.readline() x sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline return x[:-1] if x[-1]=="\n" else x x[:-1] if x[-1]=="\n" else x x[-1]=="\n" x[-1] x -1 "\n" x[:-1] x :-1 -1 x def printl(li): _=print(*li, sep="\n") if li else None printl li li def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds argsort inds=sorted(range(len(s)), key=lambda k: s[k]) inds sorted(range(len(s)), key=lambda k: s[k]) sorted range(len(s)) range len(s) len s key=lambda k: s[k] key lambda k: s[k] s[k] s k k s[i] for i in inds for i in inds i inds for i in inds s[i] s i if return_sorted: return inds, [s[i] for i in inds]
     return_sorted return inds inds s s return_sorted=False return_sorted False def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65 alp2num c c cap=False cap False def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65) num2alp i i cap=False cap False def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)] matmat K,N,M=len(B),len(A),len(B[0]) K len(B) len B N len(A) len A M len(B[0]) len B[0] B 0 [sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N) for i in range(N) i range(N) range N for i in range(N) [sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)] [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)] A A B B def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)] matvec N,size=len(v),len(M) N len(v) len v size len(M) len M sum([M[i][j]*v[j] for j in range(N)]) for i in range(size) for i in range(size) i range(size) range size for i in range(size) sum([M[i][j]*v[j] for j in range(N)]) sum [M[i][j]*v[j] for j in range(N)] return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)] [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)] M M v v def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)] T n,m=len(M),len(M[0]) n len(M) len M m len(M[0]) len M[0] M 0 [M[j][i] for j in range(n)] for i in range(m) for i in range(m) i range(m) range m for i in range(m) [M[j][i] for j in range(n)] return [[M[j][i] for j in range(n)] for i in range(m)] [[M[j][i] for j in range(n)] for i in range(m)] M M def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    edge = [[] for i in range(N)]
    for i in range(N-1):#木の場合M=N-1
        a,b,w = map(int,input().split())
        edge[a-1].append((w,b-1))
        edge[b-1].append((w,a-1)) #有向のばあいコメントアウト

    def dfs():
        q=deque([(0,0)])
        visited=[False]*N
        while len(q):
            e,w=q.pop()#ここをpopleftにすると幅優先探索BFSになる
            if visited[e]:continue
            visited[e]=1 if w%2==0 else 2
            for dw,ne in edge[e]:
                q.append((ne,w+dw))
        return visited
    x=dfs()
    for xi in x:
        if xi==1:
            print(0)
        else:
            print(1) main mod = 1000000007 mod 1000000007 N = int(input()) N int(input()) int input() input [] for i in range(N) for i in range(N) i range(N) range N for i in range(N) [] edge = [[] for i in range(N)] edge [[] for i in range(N)] for i in range(N-1):#木の場合M=N-1
        a,b,w = map(int,input().split())
        edge[a-1].append((w,b-1))
        edge[b-1].append((w,a-1)) #有向のばあいコメントアウト

     i range(N-1) range N-1 N 1 a,b,w = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b w edge[a-1].append((w,b-1)) [a-1].append [a-1] edge a-1 a 1 append (w,b-1) w b-1 b 1 edge[b-1].append((w,a-1)) [b-1].append [b-1] edge b-1 b 1 append (w,a-1) w a-1 a 1 def dfs():
        q=deque([(0,0)])
        visited=[False]*N
        while len(q):
            e,w=q.pop()#ここをpopleftにすると幅優先探索BFSになる
            if visited[e]:continue
            visited[e]=1 if w%2==0 else 2
            for dw,ne in edge[e]:
                q.append((ne,w+dw))
        return visited
     dfs q=deque([(0,0)]) q deque([(0,0)]) deque [(0,0)] (0,0) 0 0 visited=[False]*N visited [False]*N [False] False N while len(q):
            e,w=q.pop()#ここをpopleftにすると幅優先探索BFSになる
            if visited[e]:continue
            visited[e]=1 if w%2==0 else 2
            for dw,ne in edge[e]:
                q.append((ne,w+dw))
         len(q) len q e,w=q.pop() e q.pop() q.pop q pop w if visited[e]:continue
             visited[e] visited e visited[e]=1 if w%2==0 else 2 visited[e] visited e 1 if w%2==0 else 2 w%2==0 w%2 w 2 0 1 2 for dw,ne in edge[e]:
                q.append((ne,w+dw))
         dw ne edge[e] edge e q.append((ne,w+dw)) q.append q append (ne,w+dw) ne w+dw w dw return visited visited x=dfs() x dfs() dfs for xi in x:
        if xi==1:
            print(0)
        else:
            print(1) xi x if xi==1:
            print(0)
        else:
            print(1) xi==1 xi 1 print(0) print 0 print(1) print 1 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65 def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65 alp2num def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65) def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65) num2alp def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)] def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)] matvec def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)] def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)] T def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x input def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)] def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)] matmat def printl(li): _=print(*li, sep="\n") if li else None def printl(li): _=print(*li, sep="\n") if li else None printl def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    edge = [[] for i in range(N)]
    for i in range(N-1):#木の場合M=N-1
        a,b,w = map(int,input().split())
        edge[a-1].append((w,b-1))
        edge[b-1].append((w,a-1)) #有向のばあいコメントアウト

    def dfs():
        q=deque([(0,0)])
        visited=[False]*N
        while len(q):
            e,w=q.pop()#ここをpopleftにすると幅優先探索BFSになる
            if visited[e]:continue
            visited[e]=1 if w%2==0 else 2
            for dw,ne in edge[e]:
                q.append((ne,w+dw))
        return visited
    x=dfs()
    for xi in x:
        if xi==1:
            print(0)
        else:
            print(1) def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    edge = [[] for i in range(N)]
    for i in range(N-1):#木の場合M=N-1
        a,b,w = map(int,input().split())
        edge[a-1].append((w,b-1))
        edge[b-1].append((w,a-1)) #有向のばあいコメントアウト

    def dfs():
        q=deque([(0,0)])
        visited=[False]*N
        while len(q):
            e,w=q.pop()#ここをpopleftにすると幅優先探索BFSになる
            if visited[e]:continue
            visited[e]=1 if w%2==0 else 2
            for dw,ne in edge[e]:
                q.append((ne,w+dw))
        return visited
    x=dfs()
    for xi in x:
        if xi==1:
            print(0)
        else:
            print(1) main def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds argsort
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    edge = [[] for i in range(N)]
    for i in range(N-1):#木の場合M=N-1
        a,b,w = map(int,input().split())
        edge[a-1].append((w,b-1))
        edge[b-1].append((w,a-1)) #有向のばあいコメントアウト

    def dfs():
        q=deque([(0,0)])
        visited=[False]*N
        while len(q):
            e,w=q.pop()#ここをpopleftにすると幅優先探索BFSになる
            if visited[e]:continue
            visited[e]=1 if w%2==0 else 2
            for dw,ne in edge[e]:
                q.append((ne,w+dw))
        return visited
    x=dfs()
    for xi in x:
        if xi==1:
            print(0)
        else:
            print(1)



if __name__ == "__main__":
    main()