g = {}
a = int(input())
for i in range(a - 1):
    c = [int(s) for s in input().split()]
    if c[0] not in g: g[c[0]] = [(c[1], c[2])]
    else: g[c[0]].append((c[1], c[2]))

    if c[1] not in g: g[c[1]] = [(c[0], c[2])]
    else: g[c[1]].append((c[0], c[2]))

c = {}
d = {i: False for i in range(1, a + 1)}
c[1], d[1] = 0, True
Q = [1]
while(Q != []):
    r = Q.pop(0)
    for i in g[r]:
        if d[i[0]] == False:
            d[i[0]] = True
            Q.append(i[0])
            if i[1] % 2 == 0: c[i[0]] = c[r]
            else: c[i[0]] = (c[r] + 1) % 2
for i in range(1, a + 1): print(c[i]) g = {} g {} a = int(input()) a int(input()) int input() input for i in range(a - 1):
    c = [int(s) for s in input().split()]
    if c[0] not in g: g[c[0]] = [(c[1], c[2])]
    else: g[c[0]].append((c[1], c[2]))

    if c[1] not in g: g[c[1]] = [(c[0], c[2])]
    else: g[c[1]].append((c[0], c[2])) i range(a - 1) range a - 1 a 1 int(s) for s in input().split() for s in input().split() s input().split() ().split () input split for s in input().split() int(s) int s c = [int(s) for s in input().split()] c [int(s) for s in input().split()] if c[0] not in g: g[c[0]] = [(c[1], c[2])]
    else: g[c[0]].append((c[1], c[2]))

     c[0] not in g c[0] c 0 g if c[1] not in g: g[c[1]] = [(c[0], c[2])]
    else: g[c[1]].append((c[0], c[2])) c[1] not in g c[1] c 1 g c = {} c {} i: False for i in range(1, a + 1) for i in range(1, a + 1) i range(1, a + 1) range 1 a + 1 a 1 for i in range(1, a + 1) i False d = {i: False for i in range(1, a + 1)} d {i: False for i in range(1, a + 1)} c[1], d[1] = 0, True c[1] c 1 0 d[1] d 1 True Q = [1] Q [1] 1 while(Q != []):
    r = Q.pop(0)
    for i in g[r]:
        if d[i[0]] == False:
            d[i[0]] = True
            Q.append(i[0])
            if i[1] % 2 == 0: c[i[0]] = c[r]
            else: c[i[0]] = (c[r] + 1) % 2 Q != [] Q [] r = Q.pop(0) r Q.pop(0) Q.pop Q pop 0 for i in g[r]:
        if d[i[0]] == False:
            d[i[0]] = True
            Q.append(i[0])
            if i[1] % 2 == 0: c[i[0]] = c[r]
            else: c[i[0]] = (c[r] + 1) % 2 i g[r] g r if d[i[0]] == False:
            d[i[0]] = True
            Q.append(i[0])
            if i[1] % 2 == 0: c[i[0]] = c[r]
            else: c[i[0]] = (c[r] + 1) % 2 d[i[0]] == False d[i[0]] d i[0] i 0 False d[i[0]] = True d[i[0]] d i[0] i 0 True Q.append(i[0]) Q.append Q append i[0] i 0 if i[1] % 2 == 0: c[i[0]] = c[r]
            else: c[i[0]] = (c[r] + 1) % 2 i[1] % 2 == 0 i[1] % 2 i[1] i 1 2 0 for i in range(1, a + 1): print(c[i]) i range(1, a + 1) range 1 a + 1 a 1 c = [int(s) for s in input().split()] [int(s) for s in input().split()] c r = Q.pop(0) Q.pop(0) r Q = [1] [1] Q a = int(input()) int(input()) a d = {i: False for i in range(1, a + 1)} {i: False for i in range(1, a + 1)} d g = {} {} g c = {} {} c
g = {}
a = int(input())
for i in range(a - 1):
    c = [int(s) for s in input().split()]
    if c[0] not in g: g[c[0]] = [(c[1], c[2])]
    else: g[c[0]].append((c[1], c[2]))

    if c[1] not in g: g[c[1]] = [(c[0], c[2])]
    else: g[c[1]].append((c[0], c[2]))

c = {}
d = {i: False for i in range(1, a + 1)}
c[1], d[1] = 0, True
Q = [1]
while(Q != []):
    r = Q.pop(0)
    for i in g[r]:
        if d[i[0]] == False:
            d[i[0]] = True
            Q.append(i[0])
            if i[1] % 2 == 0: c[i[0]] = c[r]
            else: c[i[0]] = (c[r] + 1) % 2
for i in range(1, a + 1): print(c[i])