N = int(input())
D = {i: [] for i in range(N)}
distD = {}
for i in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    D[u].append(v)
    D[v].append(u)
    distD[u*N+v], distD[v*N+u] = w, w
clr = [-1 for _ in range(N)]
clr[0] = 0
s = [0]
pnt = 0
cnt = 1
while pnt < cnt:
    n = cnt
    for i in range(pnt, cnt):
        L = D[s[i]]
        for j in L:
            if clr[j] == -1:
                clr[j] = (clr[s[i]] + distD[s[i]*N+j]) % 2
                s.append(j)
                cnt += 1
    pnt = n
for i in range(N):
    print(clr[i]) N = int(input()) N int(input()) int input() input i: [] for i in range(N) for i in range(N) i range(N) range N for i in range(N) i [] D = {i: [] for i in range(N)} D {i: [] for i in range(N)} distD = {} distD {} for i in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    D[u].append(v)
    D[v].append(u)
    distD[u*N+v], distD[v*N+u] = w, 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 u -= 1 u 1 v -= 1 v 1 D[u].append(v) [u].append [u] D u append v D[v].append(u) [v].append [v] D v append u distD[u*N+v], distD[v*N+u] = w, w distD[u*N+v] distD u*N+v u*N u N v w distD[v*N+u] distD v*N+u v*N v N u w -1 for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) -1 clr = [-1 for _ in range(N)] clr [-1 for _ in range(N)] clr[0] = 0 clr[0] clr 0 0 s = [0] s [0] 0 pnt = 0 pnt 0 cnt = 1 cnt 1 while pnt < cnt:
    n = cnt
    for i in range(pnt, cnt):
        L = D[s[i]]
        for j in L:
            if clr[j] == -1:
                clr[j] = (clr[s[i]] + distD[s[i]*N+j]) % 2
                s.append(j)
                cnt += 1
    pnt = n pnt < cnt pnt cnt n = cnt n cnt for i in range(pnt, cnt):
        L = D[s[i]]
        for j in L:
            if clr[j] == -1:
                clr[j] = (clr[s[i]] + distD[s[i]*N+j]) % 2
                s.append(j)
                cnt += 1
     i range(pnt, cnt) range pnt cnt L = D[s[i]] L D[s[i]] D s[i] s i for j in L:
            if clr[j] == -1:
                clr[j] = (clr[s[i]] + distD[s[i]*N+j]) % 2
                s.append(j)
                cnt += 1
     j L if clr[j] == -1:
                clr[j] = (clr[s[i]] + distD[s[i]*N+j]) % 2
                s.append(j)
                cnt += 1
     clr[j] == -1 clr[j] clr j -1 clr[j] = (clr[s[i]] + distD[s[i]*N+j]) % 2 clr[j] clr j (clr[s[i]] + distD[s[i]*N+j]) % 2 clr[s[i]] + distD[s[i]*N+j] clr[s[i]] clr s[i] s i distD[s[i]*N+j] distD s[i]*N+j s[i]*N s[i] s i N j 2 s.append(j) s.append s append j cnt += 1 cnt 1 pnt = n pnt n for i in range(N):
    print(clr[i]) i range(N) range N print(clr[i]) print clr[i] clr i u -= 1 1 u distD = {} {} distD v -= 1 1 v cnt = 1 1 cnt pnt = n n pnt N = int(input()) int(input()) N u, v, w = map(int, input().split()) map(int, input().split()) u n = cnt cnt n clr = [-1 for _ in range(N)] [-1 for _ in range(N)] clr cnt += 1 1 cnt v, w = map(int, input().split()) map(int, input().split()) v pnt = 0 0 pnt D = {i: [] for i in range(N)} {i: [] for i in range(N)} D w = map(int, input().split()) map(int, input().split()) w s = [0] [0] s L = D[s[i]] D[s[i]] L
N = int(input())
D = {i: [] for i in range(N)}
distD = {}
for i in range(N-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    D[u].append(v)
    D[v].append(u)
    distD[u*N+v], distD[v*N+u] = w, w
clr = [-1 for _ in range(N)]
clr[0] = 0
s = [0]
pnt = 0
cnt = 1
while pnt < cnt:
    n = cnt
    for i in range(pnt, cnt):
        L = D[s[i]]
        for j in L:
            if clr[j] == -1:
                clr[j] = (clr[s[i]] + distD[s[i]*N+j]) % 2
                s.append(j)
                cnt += 1
    pnt = n
for i in range(N):
    print(clr[i])