Buggy python submission (verdict: Runtime Error):
N = int(input())
paths = {}
for i in range(N-1):
    u, v, w = map(int,input().split())
    paths.setdefault(u, {})
    paths[u][v] = w
    paths.setdefault(v, {})
    paths[v][u] = w

node_colors = [-1] * (N+1)

def route(last, now, dist):
    for next_node, next_distance in zip(paths[now].keys(), paths[now].values()):
        node_colors[next_node] = (dist + next_distance) % 2
        if next_node != last:
            route(now, next_node, dist + next_distance)

node_colors[1] = 0

route(0, 1, 0)

for i in range(N):
    print(node_colors[i+1])


Fixed submission:
import sys
sys.setrecursionlimit(10**6)

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

node_colors = [-1] * (N+1)

def route(last, now, dist):
    for next_node, next_distance in zip(paths[now].keys(), paths[now].values()):
        node_colors[next_node] = (dist + next_distance) % 2
        if next_node != last:
            route(now, next_node, dist + next_distance)

node_colors[1] = 0

route(0, 1, 0)

for i in range(N):
    print(node_colors[i+1])

Buggy python submission (verdict: Runtime Error):
def p_color(here, previous):
    color_here = colors[here]
    next_candidates = []
    for u, v, w in paths:
        if here == u and v != previous:
            next_candidates.append(v)
            if color_here == 0:
                if w % 2 == 0:
                    colors[v] = 0
                else:
                    colors[v] = 1
            else:
                if w % 2 == 0:
                    colors[v] = 1
                else:
                    colors[v] = 0
        elif here == v and u != previous:
            next_candidates.append(u)
            if color_here == 0:
                if w % 2 == 0:
                    colors[u] = 0
                else:
                    colors[u] = 1
            else:
                if w % 2 == 0:
                    colors[u] = 1
                else:
                    colors[u] = 0
    if len(next_candidates) == 0:
        return
    else:
        for p in next_candidates:
            p_color(p, here)

n = int(input())
colors = [0,] * n

paths = []
while True:
    try:
        u, v, w = map(int, input().split())
        paths.append([u - 1, v - 1, w])
    except:
        break

p_color(0, -1)

for c in colors:
    print(c)


Fixed submission:
import sys
sys.setrecursionlimit(10**6)

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

node_colors = [-1] * (N+1)

def route(last, now, dist):
    for next_node, next_distance in zip(paths[now].keys(), paths[now].values()):
        node_colors[next_node] = (dist + next_distance) % 2
        if next_node != last:
            route(now, next_node, dist + next_distance)

node_colors[1] = 0

route(0, 1, 0)

for i in range(N):
    print(node_colors[i+1])

Buggy python submission (verdict: Time Limit Exceeded):
class Point:
    def __init__(self):
        self.color = None
        self.paths = {}
    def nextp(self):
        return list(self.paths.keys())
    def d_to_p(self, p):
        return self.paths[p]

n = int(input())
pts = [Point() for i in range(n)]

while True:
    try:
        u, v, w = map(int, input().split())
        pts[u-1].paths[v-1] = w
        pts[v-1].paths[u-1] = w
    except:
        break

pts[0].color = 0
done = 1
candy = [0]

while done != n:
    t_c = []
    for now in candy:
        tmpl = pts[now].nextp()
        for p in tmpl:
            if pts[p].color == None:
                if pts[now].color == 0:
                    if pts[now].d_to_p(p) % 2 == 0:
                        pts[p].color = 0
                    else:
                        pts[p].color = 1
                else:
                    if pts[now].d_to_p(p) % 2 == 0:
                        pts[p].color = 1
                    else:
                        pts[p].color = 0
                done += 1
            if p not in t_c:
                t_c.append(p)
    candy = t_c

for i in range(n):
    print(pts[i].color)


Fixed submission:
import sys
sys.setrecursionlimit(10**6)

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

node_colors = [-1] * (N+1)

def route(last, now, dist):
    for next_node, next_distance in zip(paths[now].keys(), paths[now].values()):
        node_colors[next_node] = (dist + next_distance) % 2
        if next_node != last:
            route(now, next_node, dist + next_distance)

node_colors[1] = 0

route(0, 1, 0)

for i in range(N):
    print(node_colors[i+1])