import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    n=int(input())
    graph=[[]for _ in range(n)]
    for _ in range(n-1):
        u,v,w=map(int,input().split())
        graph[u-1].append((v-1,w))
        graph[v-1].append((u-1,w))
    D=[-1]*n
    D[0]=0
    que=deque([0])
    while que:
        q=que.popleft()
        qw=D[q]
        for nn,w in graph[q]:
            if D[nn]==-1:
                D[nn]=qw+w
                que.append(nn)
    for d in D:
        if d%2==0:
            print(0)
        else:
            print(1)


if __name__=='__main__':
    main() import sys sys def input(): return sys.stdin.readline().rstrip() input from collections import deque def main():
    n=int(input())
    graph=[[]for _ in range(n)]
    for _ in range(n-1):
        u,v,w=map(int,input().split())
        graph[u-1].append((v-1,w))
        graph[v-1].append((u-1,w))
    D=[-1]*n
    D[0]=0
    que=deque([0])
    while que:
        q=que.popleft()
        qw=D[q]
        for nn,w in graph[q]:
            if D[nn]==-1:
                D[nn]=qw+w
                que.append(nn)
    for d in D:
        if d%2==0:
            print(0)
        else:
            print(1) main 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) [] graph=[[]for _ in range(n)] graph [[]for _ in range(n)] for _ in range(n-1):
        u,v,w=map(int,input().split())
        graph[u-1].append((v-1,w))
        graph[v-1].append((u-1,w))
     _ 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 graph[u-1].append((v-1,w)) [u-1].append [u-1] graph u-1 u 1 append (v-1,w) v-1 v 1 w graph[v-1].append((u-1,w)) [v-1].append [v-1] graph v-1 v 1 append (u-1,w) u-1 u 1 w D=[-1]*n D [-1]*n [-1] -1 n D[0]=0 D[0] D 0 0 que=deque([0]) que deque([0]) deque [0] 0 while que:
        q=que.popleft()
        qw=D[q]
        for nn,w in graph[q]:
            if D[nn]==-1:
                D[nn]=qw+w
                que.append(nn)
     que q=que.popleft() q que.popleft() que.popleft que popleft qw=D[q] qw D[q] D q for nn,w in graph[q]:
            if D[nn]==-1:
                D[nn]=qw+w
                que.append(nn)
     nn w graph[q] graph q if D[nn]==-1:
                D[nn]=qw+w
                que.append(nn)
     D[nn]==-1 D[nn] D nn -1 D[nn]=qw+w D[nn] D nn qw+w qw w que.append(nn) que.append que append nn for d in D:
        if d%2==0:
            print(0)
        else:
            print(1) d D if d%2==0:
            print(0)
        else:
            print(1) d%2==0 d%2 d 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())
    graph=[[]for _ in range(n)]
    for _ in range(n-1):
        u,v,w=map(int,input().split())
        graph[u-1].append((v-1,w))
        graph[v-1].append((u-1,w))
    D=[-1]*n
    D[0]=0
    que=deque([0])
    while que:
        q=que.popleft()
        qw=D[q]
        for nn,w in graph[q]:
            if D[nn]==-1:
                D[nn]=qw+w
                que.append(nn)
    for d in D:
        if d%2==0:
            print(0)
        else:
            print(1) def main():
    n=int(input())
    graph=[[]for _ in range(n)]
    for _ in range(n-1):
        u,v,w=map(int,input().split())
        graph[u-1].append((v-1,w))
        graph[v-1].append((u-1,w))
    D=[-1]*n
    D[0]=0
    que=deque([0])
    while que:
        q=que.popleft()
        qw=D[q]
        for nn,w in graph[q]:
            if D[nn]==-1:
                D[nn]=qw+w
                que.append(nn)
    for d in D:
        if d%2==0:
            print(0)
        else:
            print(1) main def input(): return sys.stdin.readline().rstrip() def input(): return sys.stdin.readline().rstrip() input
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    n=int(input())
    graph=[[]for _ in range(n)]
    for _ in range(n-1):
        u,v,w=map(int,input().split())
        graph[u-1].append((v-1,w))
        graph[v-1].append((u-1,w))
    D=[-1]*n
    D[0]=0
    que=deque([0])
    while que:
        q=que.popleft()
        qw=D[q]
        for nn,w in graph[q]:
            if D[nn]==-1:
                D[nn]=qw+w
                que.append(nn)
    for d in D:
        if d%2==0:
            print(0)
        else:
            print(1)


if __name__=='__main__':
    main()