from collections import deque
import sys
sys.setrecursionlimit(10**9)


def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()

def main():
    N = ii()

    u = 0
    graph = [[] for _ in range(10**5+10)]
    for i in range(N-1):
        u,v,w=mi()
        graph[u].append((v,w))
        graph[v].append((u,w))

    seen = set()
    stack = deque([u])

    ans=[[] for _ in range(N+1)]
    ans[u] = 0
    while stack:
        current = stack.popleft()

        for next, w in graph[current]:
            if next in seen: continue
            if w%2==0:
                ans[next] = ans[current]
            else:
                ans[next] = 0 if ans[current] == 1 else 1

            seen.add(next)
            stack.append(next)



    print(*ans[1:],sep='\n')




if __name__ == "__main__":
  main() from collections import deque import sys sys sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 def mi(): return map(int,input().split()) mi def ii(): return int(input()) ii def isp(): return input().split() isp def main():
    N = ii()

    u = 0
    graph = [[] for _ in range(10**5+10)]
    for i in range(N-1):
        u,v,w=mi()
        graph[u].append((v,w))
        graph[v].append((u,w))

    seen = set()
    stack = deque([u])

    ans=[[] for _ in range(N+1)]
    ans[u] = 0
    while stack:
        current = stack.popleft()

        for next, w in graph[current]:
            if next in seen: continue
            if w%2==0:
                ans[next] = ans[current]
            else:
                ans[next] = 0 if ans[current] == 1 else 1

            seen.add(next)
            stack.append(next)



    print(*ans[1:],sep='\n') main N = ii() N ii() ii u = 0 u 0 [] for _ in range(10**5+10) for _ in range(10**5+10) _ range(10**5+10) range 10**5+10 10**5 10 5 10 for _ in range(10**5+10) [] graph = [[] for _ in range(10**5+10)] graph [[] for _ in range(10**5+10)] for i in range(N-1):
        u,v,w=mi()
        graph[u].append((v,w))
        graph[v].append((u,w))

     i range(N-1) range N-1 N 1 u,v,w=mi() u mi() mi v w graph[u].append((v,w)) [u].append [u] graph u append (v,w) v w graph[v].append((u,w)) [v].append [v] graph v append (u,w) u w seen = set() seen set() set stack = deque([u]) stack deque([u]) deque [u] u [] for _ in range(N+1) for _ in range(N+1) _ range(N+1) range N+1 N 1 for _ in range(N+1) [] ans=[[] for _ in range(N+1)] ans [[] for _ in range(N+1)] ans[u] = 0 ans[u] ans u 0 while stack:
        current = stack.popleft()

        for next, w in graph[current]:
            if next in seen: continue
            if w%2==0:
                ans[next] = ans[current]
            else:
                ans[next] = 0 if ans[current] == 1 else 1

            seen.add(next)
            stack.append(next)



     stack current = stack.popleft() current stack.popleft() stack.popleft stack popleft for next, w in graph[current]:
            if next in seen: continue
            if w%2==0:
                ans[next] = ans[current]
            else:
                ans[next] = 0 if ans[current] == 1 else 1

            seen.add(next)
            stack.append(next)



     next w graph[current] graph current if next in seen: continue
             next in seen next seen if w%2==0:
                ans[next] = ans[current]
            else:
                ans[next] = 0 if ans[current] == 1 else 1

             w%2==0 w%2 w 2 0 ans[next] = ans[current] ans[next] ans next ans[current] ans current ans[next] = 0 if ans[current] == 1 else 1 ans[next] ans next 0 if ans[current] == 1 else 1 ans[current] == 1 ans[current] ans current 1 0 1 seen.add(next) seen.add seen add next stack.append(next) stack.append stack append next print(*ans[1:],sep='\n') print *ans[1:] ans[1:] ans 1: 1 sep='\n' sep '\n' if __name__ == "__main__":
  main() __name__ == "__main__" __name__ "__main__" main() main def ii(): return int(input()) def ii(): return int(input()) ii def mi(): return map(int,input().split()) def mi(): return map(int,input().split()) mi def main():
    N = ii()

    u = 0
    graph = [[] for _ in range(10**5+10)]
    for i in range(N-1):
        u,v,w=mi()
        graph[u].append((v,w))
        graph[v].append((u,w))

    seen = set()
    stack = deque([u])

    ans=[[] for _ in range(N+1)]
    ans[u] = 0
    while stack:
        current = stack.popleft()

        for next, w in graph[current]:
            if next in seen: continue
            if w%2==0:
                ans[next] = ans[current]
            else:
                ans[next] = 0 if ans[current] == 1 else 1

            seen.add(next)
            stack.append(next)



    print(*ans[1:],sep='\n') def main():
    N = ii()

    u = 0
    graph = [[] for _ in range(10**5+10)]
    for i in range(N-1):
        u,v,w=mi()
        graph[u].append((v,w))
        graph[v].append((u,w))

    seen = set()
    stack = deque([u])

    ans=[[] for _ in range(N+1)]
    ans[u] = 0
    while stack:
        current = stack.popleft()

        for next, w in graph[current]:
            if next in seen: continue
            if w%2==0:
                ans[next] = ans[current]
            else:
                ans[next] = 0 if ans[current] == 1 else 1

            seen.add(next)
            stack.append(next)



    print(*ans[1:],sep='\n') main def isp(): return input().split() def isp(): return input().split() isp
from collections import deque
import sys
sys.setrecursionlimit(10**9)


def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()

def main():
    N = ii()

    u = 0
    graph = [[] for _ in range(10**5+10)]
    for i in range(N-1):
        u,v,w=mi()
        graph[u].append((v,w))
        graph[v].append((u,w))

    seen = set()
    stack = deque([u])

    ans=[[] for _ in range(N+1)]
    ans[u] = 0
    while stack:
        current = stack.popleft()

        for next, w in graph[current]:
            if next in seen: continue
            if w%2==0:
                ans[next] = ans[current]
            else:
                ans[next] = 0 if ans[current] == 1 else 1

            seen.add(next)
            stack.append(next)



    print(*ans[1:],sep='\n')




if __name__ == "__main__":
  main()
