Buggy python submission (verdict: Runtime Error):
n=int(input())
node=[-1 for i in range(n)]
g=[[] for i in range(n)]
def color(par,i,ini):
  if node[i]>-1:
    return
  else:
    if par==-1:
      node[i]=0
    else:
      node[i]=node[par]^ini
  for j in range(len(g[i])):
    color(i,g[i][j][0],g[i][j][1])
  return
for i in range(n-1):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  w%=2
  g[u].append([v,w])
  g[v].append([u,w])
color(-1,0,0)
for i in range(n):
  if node[i]==-1:
    node[i]=0
  print(node[i])

Fixed submission:
n=int(input())
node=[-1 for i in range(n)]
g=[[] for i in range(n)]
for i in range(n-1):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  w%=2
  g[u].append([v,w])
  g[v].append([u,w])
queue=[0]
node[0]=0
while len(queue)>0:
  t=queue.pop()
  for v,w in g[t]:
    if node[v]>-1:
      continue
    node[v]=node[t]^w
    queue.append(v)
for i in range(n):
  print(node[i])

Buggy python submission (verdict: Runtime Error):
n=int(input())
node=[-1 for i in range(n)]
g=[[] for i in range(n)]
def color(par,i,ini):
  if node[i]>-1:
    return
  else:
    if par==-1:
      node[i]=0
    else:
      node[i]=abs(node[par]-ini)
  for j in range(len(g[i])):
    color(i,g[i][j][0],g[i][j][1])
  return
for i in range(n-1):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  w%=2
  g[u].append([v,w])
  g[v].append([u,w])
color(-1,0,0)
for i in range(n):
  if node[i]==-1:
    node[i]=0
  print(node[i])

Fixed submission:
n=int(input())
node=[-1 for i in range(n)]
g=[[] for i in range(n)]
for i in range(n-1):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  w%=2
  g[u].append([v,w])
  g[v].append([u,w])
queue=[0]
node[0]=0
while len(queue)>0:
  t=queue.pop()
  for v,w in g[t]:
    if node[v]>-1:
      continue
    node[v]=node[t]^w
    queue.append(v)
for i in range(n):
  print(node[i])

Buggy python submission (verdict: Runtime Error):
n=int(input())
node=[-1 for i in range(n)]
g=[[] for i in range(n)]
def color(par,i,ini):
  if node[i]>-1:
    return
  else:
    if par==-1:
      node[i]=0
    else:
      node[i]=abs(node[par]-ini)
  for j in range(len(g[i])):
    color(i,g[i][j][0],g[i][j][1])
  return
for i in range(n-1):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  w%=2
  g[u].append([v,w])
  g[v].append([u,w])
for i in range(n):
  color(-1,i,0)
for i in range(n):
  print(node[i])

Fixed submission:
n=int(input())
node=[-1 for i in range(n)]
g=[[] for i in range(n)]
for i in range(n-1):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  w%=2
  g[u].append([v,w])
  g[v].append([u,w])
queue=[0]
node[0]=0
while len(queue)>0:
  t=queue.pop()
  for v,w in g[t]:
    if node[v]>-1:
      continue
    node[v]=node[t]^w
    queue.append(v)
for i in range(n):
  print(node[i])

Buggy python submission (verdict: Runtime Error):
n=int(input())
node=[-1 for i in range(n)]
g=[[]for i in range(n)]
def color(par,i,ini):
  if node[i]>-1:
    return
  else:
    if par==-1:
      node[i]=0
    else:
      node[i]=abs(node[par]-ini)
    for j in range(len(g[i])):
      color(i,g[i][j][0],g[i][j][1])
for i in range(n-1):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  w%=2
  g[u].append([v,w])
  g[v].append([u,w])

for i in range(n):
  color(-1,i,0)
for i in range(n):
  if node[i]==-1:
    node[i]=0
  print(node[i])

Fixed submission:
n=int(input())
node=[-1 for i in range(n)]
g=[[] for i in range(n)]
for i in range(n-1):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  w%=2
  g[u].append([v,w])
  g[v].append([u,w])
queue=[0]
node[0]=0
while len(queue)>0:
  t=queue.pop()
  for v,w in g[t]:
    if node[v]>-1:
      continue
    node[v]=node[t]^w
    queue.append(v)
for i in range(n):
  print(node[i])

Buggy python submission (verdict: Runtime Error):
n=int(input())
node=[0 for i in range(n)]
chil=[[] for i in range(n)]
change=[True for i in range(n)]
def renew(i):
  if chil[i]==[]:
    node[i]=abs(node[i]-1)
  else:
    for j in chil[i]:
      if change[j]:
        node[j]=abs(node[j]-1)
        change[j]=False
        renew(j)
  return
for i in range(n-1):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  t=w%2
  if t:
    if node[u]==node[v]:
      renew(v)
    else:
      pass
  else:
    if node[u]!=node[v]:
      renew(v)
    else:
      pass
  chil[u].append(v)
  chil[v].append(u)
  change=[True for i in range(n)]
for i in node:
  print(i)

Fixed submission:
n=int(input())
node=[-1 for i in range(n)]
g=[[] for i in range(n)]
for i in range(n-1):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  w%=2
  g[u].append([v,w])
  g[v].append([u,w])
queue=[0]
node[0]=0
while len(queue)>0:
  t=queue.pop()
  for v,w in g[t]:
    if node[v]>-1:
      continue
    node[v]=node[t]^w
    queue.append(v)
for i in range(n):
  print(node[i])