#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    n=int(input())
    dis=[INFI for _ in range(n+1)]
    graph=[[] for _ in range(n+1)]
    for i in range(n-1):
        a,b,c=map(int,input().split())
        graph[a].append([b,c])
        graph[b].append([a,c])
    stack=[]
    visited=[0 for _ in range(n+1)]
    dis[0]=0
    dis[1]=0
    for i in graph[1]:
        stack.append(i[0])
        dis[i[0]]=i[1]
    while True:
        s=stack.pop()
        for i in graph[s]:
            if visited[i[0]]==0:
                stack.append(i[0])
                dis[i[0]]=dis[s]+i[1]
                visited[i[0]]=1
        if len(stack)==0:
            break
#    print(dis)
    for i in range(1,n+1):
        if dis[i]%2==0:
            print(0)
        else:
            print(1)




if __name__ == "__main__":

    main() MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 INFI = 10**10 INFI 10**10 10 10 import math math from collections import deque import itertools itertools import heapq heapq from fractions import Fraction import copy copy from functools import lru_cache from collections import defaultdict import pprint pprint def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True sosuhante for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
     k range(2, int(math.sqrt(n))+1) range 2 int(math.sqrt(n))+1 int(math.sqrt(n)) int math.sqrt(n) math.sqrt math sqrt n 1 if n% k ==0:
            return False
     n% k ==0 n% k n k 0 return False False return True True n n def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result cmb if n - r < r: r = n - r
     n - r < r n - r n r r if r == 0: return 1
     r == 0 r 0 if r == 1: return n

     r == 1 r 1 n - r + k + 1 for k in range(r) for k in range(r) k range(r) range r for k in range(r) n - r + k + 1 n - r + k n - r n r k 1 numerator = [n - r + k + 1 for k in range(r)] numerator [n - r + k + 1 for k in range(r)] k + 1 for k in range(r) for k in range(r) k range(r) range r for k in range(r) k + 1 k 1 denominator = [k + 1 for k in range(r)] denominator [k + 1 for k in range(r)] for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

     p range(2,r+1) range 2 r+1 r 1 pivot = denominator[p - 1] pivot denominator[p - 1] denominator p - 1 p 1 if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

     pivot > 1 pivot 1 offset = (n - r) % p offset (n - r) % p n - r n r p for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

     k range(p-1,r,p) range p-1 p 1 r p numerator[k - offset] /= pivot numerator[k - offset] numerator k - offset k offset pivot denominator[k] /= pivot denominator[k] denominator k pivot result = 1 result 1 for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

     k range(r) range r if numerator[k] > 1:
            result *= int(numerator[k])

     numerator[k] > 1 numerator[k] numerator k 1 result *= int(numerator[k]) result int(numerator[k]) int numerator[k] numerator k return result result n n r r def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta kingaku keta=len(str(n)) keta len(str(n)) len str(n) str n return a*n+b*keta a*n+b*keta a*n a n b*keta b keta a a b b n n def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)] my_index if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)] x in l x l return l.index(x) l.index(x) l.index l index x return default default l l x x default=False default False def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c) ret c=[None]*(len(a)-1) c [None]*(len(a)-1) [None] None len(a)-1 len(a) len a 1 if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
     len(a)==1 len(a) len a 1 return a[0] a[0] a 0 elif len(a)==0:
        return 0
     len(a)==0 len(a) len a 0 return 0 0 for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
     i range(1,len(a)) range 1 len(a) len a c[i-1]=abs(a[i]-a[i-1]) c[i-1] c i-1 i 1 abs(a[i]-a[i-1]) abs a[i]-a[i-1] a[i] a i a[i-1] a i-1 i 1 return ret(c) ret(c) ret c a a def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori soinsubunkai a = [] a [] i = 1 i 1 while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
     i*i <= n i*i i i n if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

         n % i == 0 and i!=1 n % i == 0 n % i n i 0 i!=1 i 1 a.append(i) a.append a append i n=n//i n n//i n i if n% i !=0 or i==1:
            i += 1
     n% i !=0 or i==1 n% i !=0 n% i n i 0 i==1 i 1 i += 1 i 1 nokori=[n] nokori [n] n return a + nokori a + nokori a nokori n n def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1] make_divisors lower_divisors , upper_divisors = [], [] lower_divisors [] upper_divisors [] i = 1 i 1 while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
     i*i <= n i*i i i n if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
         n % i == 0 n % i n i 0 lower_divisors.append(i) lower_divisors.append lower_divisors append i if i != n // i:
                upper_divisors.append(n//i)
         i != n // i i n // i n i upper_divisors.append(n//i) upper_divisors.append upper_divisors append n//i n i i += 1 i 1 return lower_divisors + upper_divisors[::-1] lower_divisors + upper_divisors[::-1] lower_divisors upper_divisors[::-1] upper_divisors ::-1 -1 n n def main():
    n=int(input())
    dis=[INFI for _ in range(n+1)]
    graph=[[] for _ in range(n+1)]
    for i in range(n-1):
        a,b,c=map(int,input().split())
        graph[a].append([b,c])
        graph[b].append([a,c])
    stack=[]
    visited=[0 for _ in range(n+1)]
    dis[0]=0
    dis[1]=0
    for i in graph[1]:
        stack.append(i[0])
        dis[i[0]]=i[1]
    while True:
        s=stack.pop()
        for i in graph[s]:
            if visited[i[0]]==0:
                stack.append(i[0])
                dis[i[0]]=dis[s]+i[1]
                visited[i[0]]=1
        if len(stack)==0:
            break
#    print(dis)
    for i in range(1,n+1):
        if dis[i]%2==0:
            print(0)
        else:
            print(1) main n=int(input()) n int(input()) int input() input INFI for _ in range(n+1) for _ in range(n+1) _ range(n+1) range n+1 n 1 for _ in range(n+1) INFI dis=[INFI for _ in range(n+1)] dis [INFI for _ in range(n+1)] [] for _ in range(n+1) for _ in range(n+1) _ range(n+1) range n+1 n 1 for _ in range(n+1) [] graph=[[] for _ in range(n+1)] graph [[] for _ in range(n+1)] for i in range(n-1):
        a,b,c=map(int,input().split())
        graph[a].append([b,c])
        graph[b].append([a,c])
     i range(n-1) range n-1 n 1 a,b,c=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b c graph[a].append([b,c]) [a].append [a] graph a append [b,c] b c graph[b].append([a,c]) [b].append [b] graph b append [a,c] a c stack=[] stack [] 0 for _ in range(n+1) for _ in range(n+1) _ range(n+1) range n+1 n 1 for _ in range(n+1) 0 visited=[0 for _ in range(n+1)] visited [0 for _ in range(n+1)] dis[0]=0 dis[0] dis 0 0 dis[1]=0 dis[1] dis 1 0 for i in graph[1]:
        stack.append(i[0])
        dis[i[0]]=i[1]
     i graph[1] graph 1 stack.append(i[0]) stack.append stack append i[0] i 0 dis[i[0]]=i[1] dis[i[0]] dis i[0] i 0 i[1] i 1 while True:
        s=stack.pop()
        for i in graph[s]:
            if visited[i[0]]==0:
                stack.append(i[0])
                dis[i[0]]=dis[s]+i[1]
                visited[i[0]]=1
        if len(stack)==0:
            break
#    print(dis)
     True s=stack.pop() s stack.pop() stack.pop stack pop for i in graph[s]:
            if visited[i[0]]==0:
                stack.append(i[0])
                dis[i[0]]=dis[s]+i[1]
                visited[i[0]]=1
         i graph[s] graph s if visited[i[0]]==0:
                stack.append(i[0])
                dis[i[0]]=dis[s]+i[1]
                visited[i[0]]=1
         visited[i[0]]==0 visited[i[0]] visited i[0] i 0 0 stack.append(i[0]) stack.append stack append i[0] i 0 dis[i[0]]=dis[s]+i[1] dis[i[0]] dis i[0] i 0 dis[s]+i[1] dis[s] dis s i[1] i 1 visited[i[0]]=1 visited[i[0]] visited i[0] i 0 1 if len(stack)==0:
            break
#    print(dis)
     len(stack)==0 len(stack) len stack 0 break for i in range(1,n+1):
        if dis[i]%2==0:
            print(0)
        else:
            print(1) i range(1,n+1) range 1 n+1 n 1 if dis[i]%2==0:
            print(0)
        else:
            print(1) dis[i]%2==0 dis[i]%2 dis[i] dis i 2 0 print(0) print 0 print(1) print 1 if __name__ == "__main__":

    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n=int(input())
    dis=[INFI for _ in range(n+1)]
    graph=[[] for _ in range(n+1)]
    for i in range(n-1):
        a,b,c=map(int,input().split())
        graph[a].append([b,c])
        graph[b].append([a,c])
    stack=[]
    visited=[0 for _ in range(n+1)]
    dis[0]=0
    dis[1]=0
    for i in graph[1]:
        stack.append(i[0])
        dis[i[0]]=i[1]
    while True:
        s=stack.pop()
        for i in graph[s]:
            if visited[i[0]]==0:
                stack.append(i[0])
                dis[i[0]]=dis[s]+i[1]
                visited[i[0]]=1
        if len(stack)==0:
            break
#    print(dis)
    for i in range(1,n+1):
        if dis[i]%2==0:
            print(0)
        else:
            print(1) def main():
    n=int(input())
    dis=[INFI for _ in range(n+1)]
    graph=[[] for _ in range(n+1)]
    for i in range(n-1):
        a,b,c=map(int,input().split())
        graph[a].append([b,c])
        graph[b].append([a,c])
    stack=[]
    visited=[0 for _ in range(n+1)]
    dis[0]=0
    dis[1]=0
    for i in graph[1]:
        stack.append(i[0])
        dis[i[0]]=i[1]
    while True:
        s=stack.pop()
        for i in graph[s]:
            if visited[i[0]]==0:
                stack.append(i[0])
                dis[i[0]]=dis[s]+i[1]
                visited[i[0]]=1
        if len(stack)==0:
            break
#    print(dis)
    for i in range(1,n+1):
        if dis[i]%2==0:
            print(0)
        else:
            print(1) main def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)] def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)] my_index def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1] def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1] make_divisors def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta kingaku def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True sosuhante def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori soinsubunkai def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c) def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c) ret MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD INFI = 10**10 10**10 INFI def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result cmb
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    n=int(input())
    dis=[INFI for _ in range(n+1)]
    graph=[[] for _ in range(n+1)]
    for i in range(n-1):
        a,b,c=map(int,input().split())
        graph[a].append([b,c])
        graph[b].append([a,c])
    stack=[]
    visited=[0 for _ in range(n+1)]
    dis[0]=0
    dis[1]=0
    for i in graph[1]:
        stack.append(i[0])
        dis[i[0]]=i[1]
    while True:
        s=stack.pop()
        for i in graph[s]:
            if visited[i[0]]==0:
                stack.append(i[0])
                dis[i[0]]=dis[s]+i[1]
                visited[i[0]]=1
        if len(stack)==0:
            break
#    print(dis)
    for i in range(1,n+1):
        if dis[i]%2==0:
            print(0)
        else:
            print(1)




if __name__ == "__main__":

    main()