Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())

edge = np.zeros((N,N))
color = [-1] * (N)

for i in range(N-1) :
    u , v , w = map(int,input().split())
    edge[u-1,v-1] = w
    edge[v-1,u-1] = w

stack = [(0,0)] # (頂点 , 距離)

while len(stack) > 0 :
    v , d = stack.pop()

    if d % 2 == 0 :
        color[v] = '1'
    else :
        color[v] = '0'

    for u , w in enumerate(edge[v]) :
        if w > 0 and color[u] == -1 :
            color[u] = -2
            stack.append((u,d+w))

for i in color :
    print(i)

Fixed submission:
from collections import deque

N = int(input())

edge = [[] for _ in range(N)]
check = [False] * N
dist = [0] * N

for i in range(N-1) :
    u , v , w = map(int,input().split())
    edge[u-1].append((v-1,w))
    edge[v-1].append((u-1,w))

q = deque([0])

while q :
    current = q.popleft()
    if check[current] :
        continue

    check[current] = True
    for ad , w in edge[current] :
        if not check[ad] :
            q.append(ad)
            dist[ad] = dist[current] + w

for w in dist :
    print(w % 2)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())

edge = np.zeros((N,N))
color = [-1] * (N)

for i in range(N-1) :
    u , v , w = map(int,input().split())
    edge[u-1,v-1] = w
    edge[v-1,u-1] = w

stack = [(0,0)] # (頂点 , 距離)

while len(stack) > 0 :
    v , d = stack.pop()

    if d % 2 == 0 :
        color[v] = '1'
    else :
        color[v] = '0'

    for u , w in enumerate(edge[v]) :
        if w > 0 and color[u] == -1 :
            stack.append((u,d+w))

for i in color :
    print(i)

Fixed submission:
from collections import deque

N = int(input())

edge = [[] for _ in range(N)]
check = [False] * N
dist = [0] * N

for i in range(N-1) :
    u , v , w = map(int,input().split())
    edge[u-1].append((v-1,w))
    edge[v-1].append((u-1,w))

q = deque([0])

while q :
    current = q.popleft()
    if check[current] :
        continue

    check[current] = True
    for ad , w in edge[current] :
        if not check[ad] :
            q.append(ad)
            dist[ad] = dist[current] + w

for w in dist :
    print(w % 2)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())

edge = np.zeros((N,N))
color = [0] * (N)

for i in range(N-1) :
    u , v , w = map(int,input().split())
    edge[u-1,v-1] = w
    edge[v-1,u-1] = w

stack = [(0,0)] # (頂点 , 距離)

while len(stack) > 0 :
    v , d = stack.pop()

    print(v+1)

    if d % 2 == 0 :
        color[v] = 1
    else :
        color[v] = 0

    for u , w in enumerate(edge[v]) :
        if w > 0 and color[u] == 0 :
            stack.append((u,d+w))

for i in color :
    print(i)

Fixed submission:
from collections import deque

N = int(input())

edge = [[] for _ in range(N)]
check = [False] * N
dist = [0] * N

for i in range(N-1) :
    u , v , w = map(int,input().split())
    edge[u-1].append((v-1,w))
    edge[v-1].append((u-1,w))

q = deque([0])

while q :
    current = q.popleft()
    if check[current] :
        continue

    check[current] = True
    for ad , w in edge[current] :
        if not check[ad] :
            q.append(ad)
            dist[ad] = dist[current] + w

for w in dist :
    print(w % 2)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())

edge = np.zeros((N,N))
color = [0] * (N)

for i in range(N-1) :
    u , v , w = map(int,input().split())
    edge[u-1,v-1] = w
    edge[v-1,u-1] = w

stack = [(0,0)] # (頂点 , 距離)

while len(stack) > 0 :
    v , d = stack.pop()

    if d % 2 == 0 :
        color[v] = '1'
    else :
        color[v] = '0'

    for u , w in enumerate(edge[v]) :
        if w > 0 and color[u] == 0 :
            stack.append((u,d+w))

for i in color :
    print(i)

Fixed submission:
from collections import deque

N = int(input())

edge = [[] for _ in range(N)]
check = [False] * N
dist = [0] * N

for i in range(N-1) :
    u , v , w = map(int,input().split())
    edge[u-1].append((v-1,w))
    edge[v-1].append((u-1,w))

q = deque([0])

while q :
    current = q.popleft()
    if check[current] :
        continue

    check[current] = True
    for ad , w in edge[current] :
        if not check[ad] :
            q.append(ad)
            dist[ad] = dist[current] + w

for w in dist :
    print(w % 2)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())

edge = np.zeros((N,N))
color = [0] * (N)

for i in range(N-1) :
    u , v , w = map(int,input().split())
    edge[u-1,v-1] = w
    edge[v-1,u-1] = w

color[0] = 1
stack = [0]

while len(stack) > 0 :
    v = stack.pop() # 現在の頂点

    for i in range(N) :
        if edge[v][i] > 0 and color[i] == 0 : # 辺があり，色がついていない場合
            if edge[v][i] % 2 == 0 :
                color[i] = color[v]
            else :
                color[i] = color[v] * -1
            stack.append(i)

for i in range(N) :
    if color[i] == 1 :
        print('1')
    else :
        print('0')

Fixed submission:
from collections import deque

N = int(input())

edge = [[] for _ in range(N)]
check = [False] * N
dist = [0] * N

for i in range(N-1) :
    u , v , w = map(int,input().split())
    edge[u-1].append((v-1,w))
    edge[v-1].append((u-1,w))

q = deque([0])

while q :
    current = q.popleft()
    if check[current] :
        continue

    check[current] = True
    for ad , w in edge[current] :
        if not check[ad] :
            q.append(ad)
            dist[ad] = dist[current] + w

for w in dist :
    print(w % 2)