def main():
    n = int(input())
    ki = {}
    for i in range(1,n+1):
        ki[i] = []
    for i in range(n-1):
        u,v,w = map(int,input().split())
        ki[u] += [[v,w%2]]
        ki[v] += [[u,w%2]]
    cl = [-1 for i in range(n)]
    cl[0] = 0
    que = [0]
    while len(que)>0:
        q = que.pop(0)
        for v in ki[q+1]:
            if cl[v[0]-1] != -1:
                continue
            if v[1]==1:
                cl[v[0]-1] = (cl[q]+1)%2
                que.append(v[0]-1)
            else:
                cl[v[0]-1] = cl[q]
                que.append(v[0]-1)
    for i in range(n):
        print(cl[i])

if __name__ == "__main__":
    main() def main():
    n = int(input())
    ki = {}
    for i in range(1,n+1):
        ki[i] = []
    for i in range(n-1):
        u,v,w = map(int,input().split())
        ki[u] += [[v,w%2]]
        ki[v] += [[u,w%2]]
    cl = [-1 for i in range(n)]
    cl[0] = 0
    que = [0]
    while len(que)>0:
        q = que.pop(0)
        for v in ki[q+1]:
            if cl[v[0]-1] != -1:
                continue
            if v[1]==1:
                cl[v[0]-1] = (cl[q]+1)%2
                que.append(v[0]-1)
            else:
                cl[v[0]-1] = cl[q]
                que.append(v[0]-1)
    for i in range(n):
        print(cl[i]) main n = int(input()) n int(input()) int input() input ki = {} ki {} for i in range(1,n+1):
        ki[i] = []
     i range(1,n+1) range 1 n+1 n 1 ki[i] = [] ki[i] ki i [] for i in range(n-1):
        u,v,w = map(int,input().split())
        ki[u] += [[v,w%2]]
        ki[v] += [[u,w%2]]
     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 ki[u] += [[v,w%2]] ki[u] ki u [[v,w%2]] [v,w%2] v w%2 w 2 ki[v] += [[u,w%2]] ki[v] ki v [[u,w%2]] [u,w%2] u w%2 w 2 -1 for i in range(n) for i in range(n) i range(n) range n for i in range(n) -1 cl = [-1 for i in range(n)] cl [-1 for i in range(n)] cl[0] = 0 cl[0] cl 0 0 que = [0] que [0] 0 while len(que)>0:
        q = que.pop(0)
        for v in ki[q+1]:
            if cl[v[0]-1] != -1:
                continue
            if v[1]==1:
                cl[v[0]-1] = (cl[q]+1)%2
                que.append(v[0]-1)
            else:
                cl[v[0]-1] = cl[q]
                que.append(v[0]-1)
     len(que)>0 len(que) len que 0 q = que.pop(0) q que.pop(0) que.pop que pop 0 for v in ki[q+1]:
            if cl[v[0]-1] != -1:
                continue
            if v[1]==1:
                cl[v[0]-1] = (cl[q]+1)%2
                que.append(v[0]-1)
            else:
                cl[v[0]-1] = cl[q]
                que.append(v[0]-1)
     v ki[q+1] ki q+1 q 1 if cl[v[0]-1] != -1:
                continue
             cl[v[0]-1] != -1 cl[v[0]-1] cl v[0]-1 v[0] v 0 1 -1 continue if v[1]==1:
                cl[v[0]-1] = (cl[q]+1)%2
                que.append(v[0]-1)
            else:
                cl[v[0]-1] = cl[q]
                que.append(v[0]-1)
     v[1]==1 v[1] v 1 1 cl[v[0]-1] = (cl[q]+1)%2 cl[v[0]-1] cl v[0]-1 v[0] v 0 1 (cl[q]+1)%2 cl[q]+1 cl[q] cl q 1 2 que.append(v[0]-1) que.append que append v[0]-1 v[0] v 0 1 cl[v[0]-1] = cl[q] cl[v[0]-1] cl v[0]-1 v[0] v 0 1 cl[q] cl q que.append(v[0]-1) que.append que append v[0]-1 v[0] v 0 1 for i in range(n):
        print(cl[i]) i range(n) range n print(cl[i]) print cl[i] cl i if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n = int(input())
    ki = {}
    for i in range(1,n+1):
        ki[i] = []
    for i in range(n-1):
        u,v,w = map(int,input().split())
        ki[u] += [[v,w%2]]
        ki[v] += [[u,w%2]]
    cl = [-1 for i in range(n)]
    cl[0] = 0
    que = [0]
    while len(que)>0:
        q = que.pop(0)
        for v in ki[q+1]:
            if cl[v[0]-1] != -1:
                continue
            if v[1]==1:
                cl[v[0]-1] = (cl[q]+1)%2
                que.append(v[0]-1)
            else:
                cl[v[0]-1] = cl[q]
                que.append(v[0]-1)
    for i in range(n):
        print(cl[i]) def main():
    n = int(input())
    ki = {}
    for i in range(1,n+1):
        ki[i] = []
    for i in range(n-1):
        u,v,w = map(int,input().split())
        ki[u] += [[v,w%2]]
        ki[v] += [[u,w%2]]
    cl = [-1 for i in range(n)]
    cl[0] = 0
    que = [0]
    while len(que)>0:
        q = que.pop(0)
        for v in ki[q+1]:
            if cl[v[0]-1] != -1:
                continue
            if v[1]==1:
                cl[v[0]-1] = (cl[q]+1)%2
                que.append(v[0]-1)
            else:
                cl[v[0]-1] = cl[q]
                que.append(v[0]-1)
    for i in range(n):
        print(cl[i]) main
def main():
    n = int(input())
    ki = {}
    for i in range(1,n+1):
        ki[i] = []
    for i in range(n-1):
        u,v,w = map(int,input().split())
        ki[u] += [[v,w%2]]
        ki[v] += [[u,w%2]]
    cl = [-1 for i in range(n)]
    cl[0] = 0
    que = [0]
    while len(que)>0:
        q = que.pop(0)
        for v in ki[q+1]:
            if cl[v[0]-1] != -1:
                continue
            if v[1]==1:
                cl[v[0]-1] = (cl[q]+1)%2
                que.append(v[0]-1)
            else:
                cl[v[0]-1] = cl[q]
                que.append(v[0]-1)
    for i in range(n):
        print(cl[i])

if __name__ == "__main__":
    main()
