def f(G, not_searched, results={0: '0'}):
    stack = []
    while len(not_searched) > 0:
        if len(stack) > 0:
            i = stack.pop()
            not_searched.remove(i)
        else:
            i = not_searched.pop()

        for key, val in G[i].items():
            if not key in not_searched:
                continue

            if val % 2 == 1:
                if results[i] == '0':
                    results[key] = '1'
                else:
                    results[key] = '0'
            else:
                results[key] = results[i]

            stack.append(key)

    return results

N = int(input())
G = [{} for _ in range(N)]
not_searched = set([i for i in range(N)])

if N == 1:
    print(results[0])
else:
    for i in range(N-1):
        u, v, w = map(int, input().split())
        G[u-1][v-1] = w
        G[v-1][u-1] = w

    results = f(G, not_searched)
    for i in range(N):
        print(results[i]) def f(G, not_searched, results={0: '0'}):
    stack = []
    while len(not_searched) > 0:
        if len(stack) > 0:
            i = stack.pop()
            not_searched.remove(i)
        else:
            i = not_searched.pop()

        for key, val in G[i].items():
            if not key in not_searched:
                continue

            if val % 2 == 1:
                if results[i] == '0':
                    results[key] = '1'
                else:
                    results[key] = '0'
            else:
                results[key] = results[i]

            stack.append(key)

    return results f stack = [] stack [] while len(not_searched) > 0:
        if len(stack) > 0:
            i = stack.pop()
            not_searched.remove(i)
        else:
            i = not_searched.pop()

        for key, val in G[i].items():
            if not key in not_searched:
                continue

            if val % 2 == 1:
                if results[i] == '0':
                    results[key] = '1'
                else:
                    results[key] = '0'
            else:
                results[key] = results[i]

            stack.append(key)

     len(not_searched) > 0 len(not_searched) len not_searched 0 if len(stack) > 0:
            i = stack.pop()
            not_searched.remove(i)
        else:
            i = not_searched.pop()

         len(stack) > 0 len(stack) len stack 0 i = stack.pop() i stack.pop() stack.pop stack pop not_searched.remove(i) not_searched.remove not_searched remove i i = not_searched.pop() i not_searched.pop() not_searched.pop not_searched pop for key, val in G[i].items():
            if not key in not_searched:
                continue

            if val % 2 == 1:
                if results[i] == '0':
                    results[key] = '1'
                else:
                    results[key] = '0'
            else:
                results[key] = results[i]

            stack.append(key)

     key val G[i].items() [i].items [i] G i items if not key in not_searched:
                continue

             not key in not_searched key in not_searched key not_searched continue if val % 2 == 1:
                if results[i] == '0':
                    results[key] = '1'
                else:
                    results[key] = '0'
            else:
                results[key] = results[i]

             val % 2 == 1 val % 2 val 2 1 if results[i] == '0':
                    results[key] = '1'
                else:
                    results[key] = '0'
             results[i] == '0' results[i] results i '0' results[key] = '1' results[key] results key '1' results[key] = '0' results[key] results key '0' results[key] = results[i] results[key] results key results[i] results i stack.append(key) stack.append stack append key return results results G G not_searched not_searched results={0: '0'} results {0: '0'} 0 0 '0' 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)] i for i in range(N) for i in range(N) i range(N) range N for i in range(N) i not_searched = set([i for i in range(N)]) not_searched set([i for i in range(N)]) set [i for i in range(N)] if N == 1:
    print(results[0])
else:
    for i in range(N-1):
        u, v, w = map(int, input().split())
        G[u-1][v-1] = w
        G[v-1][u-1] = w

    results = f(G, not_searched)
    for i in range(N):
        print(results[i]) N == 1 N 1 print(results[0]) print results[0] results 0 for i in range(N-1):
        u, v, w = map(int, input().split())
        G[u-1][v-1] = w
        G[v-1][u-1] = w

     i 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 G[u-1][v-1] = w G[u-1][v-1] [u-1] G u-1 u 1 v-1 v 1 w G[v-1][u-1] = w G[v-1][u-1] [v-1] G v-1 v 1 u-1 u 1 w results = f(G, not_searched) results f(G, not_searched) f G not_searched for i in range(N):
        print(results[i]) i range(N) range N print(results[i]) print results[i] results i results = f(G, not_searched) f(G, not_searched) results def f(G, not_searched, results={0: '0'}):
    stack = []
    while len(not_searched) > 0:
        if len(stack) > 0:
            i = stack.pop()
            not_searched.remove(i)
        else:
            i = not_searched.pop()

        for key, val in G[i].items():
            if not key in not_searched:
                continue

            if val % 2 == 1:
                if results[i] == '0':
                    results[key] = '1'
                else:
                    results[key] = '0'
            else:
                results[key] = results[i]

            stack.append(key)

    return results def f(G, not_searched, results={0: '0'}):
    stack = []
    while len(not_searched) > 0:
        if len(stack) > 0:
            i = stack.pop()
            not_searched.remove(i)
        else:
            i = not_searched.pop()

        for key, val in G[i].items():
            if not key in not_searched:
                continue

            if val % 2 == 1:
                if results[i] == '0':
                    results[key] = '1'
                else:
                    results[key] = '0'
            else:
                results[key] = results[i]

            stack.append(key)

    return results f 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 not_searched = set([i for i in range(N)]) set([i for i in range(N)]) not_searched G = [{} for _ in range(N)] [{} for _ in range(N)] G v, w = map(int, input().split()) map(int, input().split()) v
def f(G, not_searched, results={0: '0'}):
    stack = []
    while len(not_searched) > 0:
        if len(stack) > 0:
            i = stack.pop()
            not_searched.remove(i)
        else:
            i = not_searched.pop()

        for key, val in G[i].items():
            if not key in not_searched:
                continue

            if val % 2 == 1:
                if results[i] == '0':
                    results[key] = '1'
                else:
                    results[key] = '0'
            else:
                results[key] = results[i]

            stack.append(key)

    return results

N = int(input())
G = [{} for _ in range(N)]
not_searched = set([i for i in range(N)])

if N == 1:
    print(results[0])
else:
    for i in range(N-1):
        u, v, w = map(int, input().split())
        G[u-1][v-1] = w
        G[v-1][u-1] = w

    results = f(G, not_searched)
    for i in range(N):
        print(results[i])