Buggy python submission (verdict: Runtime Error):
import numpy as np


def calDistance_dfs(aList, d, node):
    for v in aList[node]:
        if d[v[0]] != -1:
            continue
        else:
            d[v[0]] = d[node] + v[1]
            calDistance_dfs(aList, d, v[0])


n = int(input())
adjacencyList = [[] for i in range(n)]
d = [-1] * n

for i in range(n - 1):
    s = list(map(int, input().split()))
    adjacencyList[s[0] - 1].append((s[1] - 1, s[2]))
    adjacencyList[s[1] - 1].append((s[0] - 1, s[2]))


d[0] = 0
calDistance_dfs(adjacencyList, d, 0)
for i in d:
    print(i % 2)


Fixed submission:
import numpy as np


def calDistance_dfs(aList, d, node):
    stack = [node]
    d[node] = 0
    while len(stack) != 0:
        current = stack.pop()
        for v in aList[current]:
            if d[v[0]] == -1:
                stack.append(v[0])
                d[v[0]] = d[current]+v[1]


n = int(input())
adjacencyList = [[] for i in range(n)]
d = [-1] * n

for i in range(n - 1):
    s = list(map(int, input().split()))
    adjacencyList[s[0] - 1].append((s[1] - 1, s[2]))
    adjacencyList[s[1] - 1].append((s[0] - 1, s[2]))


d[0] = 0
calDistance_dfs(adjacencyList, d, 0)
for i in d:
    print(i % 2)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())
c = np.array([[0] * n] * n, dtype=np.uint8)
for i in range(n - 1):
    s = list(map(int, input().split()))
    c[s[0] - 1, s[1] - 1] = s[2]
    c[s[1] - 1, s[0] - 1] = s[2]


def calDistance_dfs(c, d, start=0):
    d[start] = 0
    stack = []
    stack.append(start)
    while len(stack) != 0:
        current = stack.pop()
        for idx, val in enumerate(c[current, :]):
            if val != 0 and d[idx] == -1:
                stack.append(idx)
                d[idx] = d[current] + val



d = np.array([-1] * n)
calDistance_dfs(c, d, 0)

for i in d:
    print(i % 2)


Fixed submission:
import numpy as np


def calDistance_dfs(aList, d, node):
    stack = [node]
    d[node] = 0
    while len(stack) != 0:
        current = stack.pop()
        for v in aList[current]:
            if d[v[0]] == -1:
                stack.append(v[0])
                d[v[0]] = d[current]+v[1]


n = int(input())
adjacencyList = [[] for i in range(n)]
d = [-1] * n

for i in range(n - 1):
    s = list(map(int, input().split()))
    adjacencyList[s[0] - 1].append((s[1] - 1, s[2]))
    adjacencyList[s[1] - 1].append((s[0] - 1, s[2]))


d[0] = 0
calDistance_dfs(adjacencyList, d, 0)
for i in d:
    print(i % 2)

Buggy python submission (verdict: Runtime Error):
import numpy as np

n = int(input())
c = np.array([[0] * n] * n, dtype=np.uint8)
for i in range(n - 1):
    s = list(map(int, input().split()))
    c[s[0], s[1]] = s[2]
    c[s[1], s[0]] = s[2]



def calDistance_dfs(c, d, start=0):
    d[start] = 0
    stack = []
    stack.append(start)
    while len(stack) != 0:
        current = stack.pop()
        for idx, val in enumerate(c[current, :]):
            if val!=0 and d[idx]==-1:
                stack.append(idx)
                d[idx] = d[current] + val


d = np.array([-1] * n)
calDistance_dfs(c, d, 0)

for i in d:
    print(d%2)


Fixed submission:
import numpy as np


def calDistance_dfs(aList, d, node):
    stack = [node]
    d[node] = 0
    while len(stack) != 0:
        current = stack.pop()
        for v in aList[current]:
            if d[v[0]] == -1:
                stack.append(v[0])
                d[v[0]] = d[current]+v[1]


n = int(input())
adjacencyList = [[] for i in range(n)]
d = [-1] * n

for i in range(n - 1):
    s = list(map(int, input().split()))
    adjacencyList[s[0] - 1].append((s[1] - 1, s[2]))
    adjacencyList[s[1] - 1].append((s[0] - 1, s[2]))


d[0] = 0
calDistance_dfs(adjacencyList, d, 0)
for i in d:
    print(i % 2)