N = int(input())
link = [set() for i in range(N)]
for i in range(N-1):
    u, v, w = map(int,input().split())
    link[u-1] |= {(v-1,w)}
    link[v-1] |= {(u-1,w)}
check = [(0, 0, -1)]
ans = [-1 for i in range(N)]
while check:
    now, d, From = check.pop()
    ans[now] = d % 2
    for next, dist in link[now]:
        if next == From:
            continue
        else:
            check.append((next, d + dist, now))
print('\n'.join(map(str,ans))) N = int(input()) N int(input()) int input() input set() for i in range(N) for i in range(N) i range(N) range N for i in range(N) set() set link = [set() for i in range(N)] link [set() for i in range(N)] for i in range(N-1):
    u, v, w = map(int,input().split())
    link[u-1] |= {(v-1,w)}
    link[v-1] |= {(u-1,w)} 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 link[u-1] |= {(v-1,w)} link[u-1] link u-1 u 1 {(v-1,w)} link[v-1] |= {(u-1,w)} link[v-1] link v-1 v 1 {(u-1,w)} check = [(0, 0, -1)] check [(0, 0, -1)] (0, 0, -1) 0 0 -1 -1 for i in range(N) for i in range(N) i range(N) range N for i in range(N) -1 ans = [-1 for i in range(N)] ans [-1 for i in range(N)] while check:
    now, d, From = check.pop()
    ans[now] = d % 2
    for next, dist in link[now]:
        if next == From:
            continue
        else:
            check.append((next, d + dist, now)) check now, d, From = check.pop() now check.pop() check.pop check pop d From ans[now] = d % 2 ans[now] ans now d % 2 d 2 for next, dist in link[now]:
        if next == From:
            continue
        else:
            check.append((next, d + dist, now)) next dist link[now] link now if next == From:
            continue
        else:
            check.append((next, d + dist, now)) next == From next From continue check.append((next, d + dist, now)) check.append check append (next, d + dist, now) next d + dist d dist now print('\n'.join(map(str,ans))) print '\n'.join(map(str,ans)) '\n'.join '\n' join map(str,ans) map str ans u, v, w = map(int,input().split()) map(int,input().split()) u d, From = check.pop() check.pop() d From = check.pop() check.pop() From w = map(int,input().split()) map(int,input().split()) w N = int(input()) int(input()) N now, d, From = check.pop() check.pop() now check = [(0, 0, -1)] [(0, 0, -1)] check ans = [-1 for i in range(N)] [-1 for i in range(N)] ans link = [set() for i in range(N)] [set() for i in range(N)] link v, w = map(int,input().split()) map(int,input().split()) v
N = int(input())
link = [set() for i in range(N)]
for i in range(N-1):
    u, v, w = map(int,input().split())
    link[u-1] |= {(v-1,w)}
    link[v-1] |= {(u-1,w)}
check = [(0, 0, -1)]
ans = [-1 for i in range(N)]
while check:
    now, d, From = check.pop()
    ans[now] = d % 2
    for next, dist in link[now]:
        if next == From:
            continue
        else:
            check.append((next, d + dist, now))
print('\n'.join(map(str,ans)))