import queue
N = int(input())
ans = [-1]*N
odd = [[] for _ in range(N)]
even = [[] for _ in range(N)]
for i in range(N-1):
    u,v,w = map(int,input().split())
    if w % 2 == 0:
        even[u-1].append(v-1)
        even[v-1].append(u-1)
    else:
        odd[u-1].append(v-1)
        odd[v-1].append(u-1)

q = queue.Queue()
q.put(0)
ans[0] = 0

while (not q.empty()):
    now = q.get()
    nowa = ans[now]
    for i in odd[now]:
        if ans[i] == -1:
            if nowa == 0:
                ans[i] = 1
            else:
                ans[i] = 0
            q.put(i)
    for j in even[now]:
        if ans[j] == -1:
            ans[j] = nowa
            q.put(j)

for i in ans:
    print(i) import queue queue N = int(input()) N int(input()) int input() input ans = [-1]*N ans [-1]*N [-1] -1 N [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] odd = [[] for _ in range(N)] odd [[] for _ in range(N)] [] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [] even = [[] for _ in range(N)] even [[] for _ in range(N)] for i in range(N-1):
    u,v,w = map(int,input().split())
    if w % 2 == 0:
        even[u-1].append(v-1)
        even[v-1].append(u-1)
    else:
        odd[u-1].append(v-1)
        odd[v-1].append(u-1) 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 if w % 2 == 0:
        even[u-1].append(v-1)
        even[v-1].append(u-1)
    else:
        odd[u-1].append(v-1)
        odd[v-1].append(u-1) w % 2 == 0 w % 2 w 2 0 even[u-1].append(v-1) [u-1].append [u-1] even u-1 u 1 append v-1 v 1 even[v-1].append(u-1) [v-1].append [v-1] even v-1 v 1 append u-1 u 1 odd[u-1].append(v-1) [u-1].append [u-1] odd u-1 u 1 append v-1 v 1 odd[v-1].append(u-1) [v-1].append [v-1] odd v-1 v 1 append u-1 u 1 q = queue.Queue() q queue.Queue() queue.Queue queue Queue q.put(0) q.put q put 0 ans[0] = 0 ans[0] ans 0 0 while (not q.empty()):
    now = q.get()
    nowa = ans[now]
    for i in odd[now]:
        if ans[i] == -1:
            if nowa == 0:
                ans[i] = 1
            else:
                ans[i] = 0
            q.put(i)
    for j in even[now]:
        if ans[j] == -1:
            ans[j] = nowa
            q.put(j) not q.empty() q.empty() q.empty q empty now = q.get() now q.get() q.get q get nowa = ans[now] nowa ans[now] ans now for i in odd[now]:
        if ans[i] == -1:
            if nowa == 0:
                ans[i] = 1
            else:
                ans[i] = 0
            q.put(i)
     i odd[now] odd now if ans[i] == -1:
            if nowa == 0:
                ans[i] = 1
            else:
                ans[i] = 0
            q.put(i)
     ans[i] == -1 ans[i] ans i -1 if nowa == 0:
                ans[i] = 1
            else:
                ans[i] = 0
             nowa == 0 nowa 0 ans[i] = 1 ans[i] ans i 1 ans[i] = 0 ans[i] ans i 0 q.put(i) q.put q put i for j in even[now]:
        if ans[j] == -1:
            ans[j] = nowa
            q.put(j) j even[now] even now if ans[j] == -1:
            ans[j] = nowa
            q.put(j) ans[j] == -1 ans[j] ans j -1 ans[j] = nowa ans[j] ans j nowa q.put(j) q.put q put j for i in ans:
    print(i) i ans print(i) print i odd = [[] for _ in range(N)] [[] for _ in range(N)] odd now = q.get() q.get() now q = queue.Queue() queue.Queue() q ans = [-1]*N [-1]*N ans v,w = map(int,input().split()) map(int,input().split()) v even = [[] for _ in range(N)] [[] for _ in range(N)] even u,v,w = map(int,input().split()) map(int,input().split()) u w = map(int,input().split()) map(int,input().split()) w nowa = ans[now] ans[now] nowa N = int(input()) int(input()) N
import queue
N = int(input())
ans = [-1]*N
odd = [[] for _ in range(N)]
even = [[] for _ in range(N)]
for i in range(N-1):
    u,v,w = map(int,input().split())
    if w % 2 == 0:
        even[u-1].append(v-1)
        even[v-1].append(u-1)
    else:
        odd[u-1].append(v-1)
        odd[v-1].append(u-1)

q = queue.Queue()
q.put(0)
ans[0] = 0

while (not q.empty()):
    now = q.get()
    nowa = ans[now]
    for i in odd[now]:
        if ans[i] == -1:
            if nowa == 0:
                ans[i] = 1
            else:
                ans[i] = 0
            q.put(i)
    for j in even[now]:
        if ans[j] == -1:
            ans[j] = nowa
            q.put(j)

for i in ans:
    print(i)