import sys
from collections import deque
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    tree = [[] for _ in range(N)]
    for i in range(N-1):
        u, v, w = map(int, readline().split())
        u, v = u-1, v-1
        tree[u].append((v,w))
        tree[v].append((u,w))
    color = [-1]*N
    color[0]=0

    que = deque([0])
    while que:
        index = que.popleft()
        for next_, weight in tree[index]:
            if color[next_]==-1:
                if weight%2==0:
                    color[next_] = color[index]
                else:
                    color[next_] = color[index]^1
                que.append(next_)
    for c in color:
        print(c)


if __name__ == '__main__':
    main() import sys sys from collections import deque readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline sys.setrecursionlimit(10 ** 8) sys.setrecursionlimit sys setrecursionlimit 10 ** 8 10 8 INF = float('inf') INF float('inf') float 'inf' MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 def main():
    N = int(readline())
    tree = [[] for _ in range(N)]
    for i in range(N-1):
        u, v, w = map(int, readline().split())
        u, v = u-1, v-1
        tree[u].append((v,w))
        tree[v].append((u,w))
    color = [-1]*N
    color[0]=0

    que = deque([0])
    while que:
        index = que.popleft()
        for next_, weight in tree[index]:
            if color[next_]==-1:
                if weight%2==0:
                    color[next_] = color[index]
                else:
                    color[next_] = color[index]^1
                que.append(next_)
    for c in color:
        print(c) main N = int(readline()) N int(readline()) int readline() readline [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] tree = [[] for _ in range(N)] tree [[] for _ in range(N)] for i in range(N-1):
        u, v, w = map(int, readline().split())
        u, v = u-1, v-1
        tree[u].append((v,w))
        tree[v].append((u,w))
     i range(N-1) range N-1 N 1 u, v, w = map(int, readline().split()) u map(int, readline().split()) map int readline().split() ().split () readline split v w u, v = u-1, v-1 u u-1 u 1 v v-1 v 1 tree[u].append((v,w)) [u].append [u] tree u append (v,w) v w tree[v].append((u,w)) [v].append [v] tree v append (u,w) u w color = [-1]*N color [-1]*N [-1] -1 N color[0]=0 color[0] color 0 0 que = deque([0]) que deque([0]) deque [0] 0 while que:
        index = que.popleft()
        for next_, weight in tree[index]:
            if color[next_]==-1:
                if weight%2==0:
                    color[next_] = color[index]
                else:
                    color[next_] = color[index]^1
                que.append(next_)
     que index = que.popleft() index que.popleft() que.popleft que popleft for next_, weight in tree[index]:
            if color[next_]==-1:
                if weight%2==0:
                    color[next_] = color[index]
                else:
                    color[next_] = color[index]^1
                que.append(next_)
     next_ weight tree[index] tree index if color[next_]==-1:
                if weight%2==0:
                    color[next_] = color[index]
                else:
                    color[next_] = color[index]^1
                que.append(next_)
     color[next_]==-1 color[next_] color next_ -1 if weight%2==0:
                    color[next_] = color[index]
                else:
                    color[next_] = color[index]^1
                 weight%2==0 weight%2 weight 2 0 color[next_] = color[index] color[next_] color next_ color[index] color index color[next_] = color[index]^1 color[next_] color next_ color[index]^1 color[index] color index 1 que.append(next_) que.append que append next_ for c in color:
        print(c) c color print(c) print c if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main INF = float('inf') float('inf') INF MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline def main():
    N = int(readline())
    tree = [[] for _ in range(N)]
    for i in range(N-1):
        u, v, w = map(int, readline().split())
        u, v = u-1, v-1
        tree[u].append((v,w))
        tree[v].append((u,w))
    color = [-1]*N
    color[0]=0

    que = deque([0])
    while que:
        index = que.popleft()
        for next_, weight in tree[index]:
            if color[next_]==-1:
                if weight%2==0:
                    color[next_] = color[index]
                else:
                    color[next_] = color[index]^1
                que.append(next_)
    for c in color:
        print(c) def main():
    N = int(readline())
    tree = [[] for _ in range(N)]
    for i in range(N-1):
        u, v, w = map(int, readline().split())
        u, v = u-1, v-1
        tree[u].append((v,w))
        tree[v].append((u,w))
    color = [-1]*N
    color[0]=0

    que = deque([0])
    while que:
        index = que.popleft()
        for next_, weight in tree[index]:
            if color[next_]==-1:
                if weight%2==0:
                    color[next_] = color[index]
                else:
                    color[next_] = color[index]^1
                que.append(next_)
    for c in color:
        print(c) main
import sys
from collections import deque
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    tree = [[] for _ in range(N)]
    for i in range(N-1):
        u, v, w = map(int, readline().split())
        u, v = u-1, v-1
        tree[u].append((v,w))
        tree[v].append((u,w))
    color = [-1]*N
    color[0]=0

    que = deque([0])
    while que:
        index = que.popleft()
        for next_, weight in tree[index]:
            if color[next_]==-1:
                if weight%2==0:
                    color[next_] = color[index]
                else:
                    color[next_] = color[index]^1
                que.append(next_)
    for c in color:
        print(c)


if __name__ == '__main__':
    main()