Buggy python submission (verdict: Runtime Error):
n=int(input())
graph=[[] for i in range(n)]
color=[-1]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append([b-1,c%2])
    graph[b-1].append([a-1,c%2])
def coloring(pre,c):
  color[pre]=c
  for i,j in graph[pre]:
    if color[i]<0:
      coloring(i,color[pre]^j)
coloring(0,1)
for i in color:
  print(i)


Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n=int(input())
graph=[[] for i in range(n)]
color=[-1]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append([b-1,c%2])
    graph[b-1].append([a-1,c%2])
def coloring(pre,c):
  color[pre]=c
  for i,j in graph[pre]:
    if color[i]<0:
      coloring(i,color[pre]^j)
coloring(0,1)
for i in color:
  print(i)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10000000)
n=int(input())
graph=[[] for i in range(n)]
node=[[-1]*n for i in range(n)]
color=[0]*n
visited=[False]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append(b-1);node[a-1][b-1]=c%2
    graph[b-1].append(a-1);node[b-1][a-1]=c%2
search=[[0,i] for i in graph[0]]
while search!=[]:
  a=search.pop(0)
  if visited[a[1]]==True:continue
  search=search+[[a[1],i] for i in graph[a[1]]]
  color[a[1]]=color[a[0]]^node[a[0]][a[1]]
  visited[a[1]]=True
for i in color:
  print(i)


Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n=int(input())
graph=[[] for i in range(n)]
color=[-1]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append([b-1,c%2])
    graph[b-1].append([a-1,c%2])
def coloring(pre,c):
  color[pre]=c
  for i,j in graph[pre]:
    if color[i]<0:
      coloring(i,color[pre]^j)
coloring(0,1)
for i in color:
  print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
graph=[[] for i in range(n)]
node=[[-1]*n for i in range(n)]
color=[-1]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append([b-1,c%2])
    graph[b-1].append([a-1,c%2])
def coloring(pre,c):
  color[pre]=c
  for i,j in graph[pre]:
    if color[i]<0:
      coloring(i,color[pre]^j)
coloring(0,1)
for i in color:
  print(i)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n=int(input())
graph=[[] for i in range(n)]
color=[-1]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append([b-1,c%2])
    graph[b-1].append([a-1,c%2])
def coloring(pre,c):
  color[pre]=c
  for i,j in graph[pre]:
    if color[i]<0:
      coloring(i,color[pre]^j)
coloring(0,1)
for i in color:
  print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
graph=[[] for i in range(n)]
node=[[-1]*n for i in range(n)]
color=[0]*n
visited=[False]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append(b-1);node[a-1][b-1]=c%2
    graph[b-1].append(a-1);node[b-1][a-1]=c%2
search=[[0,i] for i in graph[0]]
while search!=[]:
  a=search.pop(0)
  if visited[a[1]]==True:continue
  search=search+[[a[1],i] for i in graph[a[1]]]
  color[a[1]]=color[a[0]]^node[a[0]][a[1]]
  visited[a[1]]=True
for i in color:
  print(i)


Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n=int(input())
graph=[[] for i in range(n)]
color=[-1]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append([b-1,c%2])
    graph[b-1].append([a-1,c%2])
def coloring(pre,c):
  color[pre]=c
  for i,j in graph[pre]:
    if color[i]<0:
      coloring(i,color[pre]^j)
coloring(0,1)
for i in color:
  print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
graph=[[] for i in range(n)]
node=[[-1]*n for i in range(n)]
color=[0]*n
visited=[False]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append(b-1);node[a-1][b-1]=c%2
    graph[b-1].append(a-1);node[b-1][a-1]=c%2
search=[[0,i] for i in graph[0]]
while search!=[]:
  a=search.pop(0)
  if visited[a[1]]==True:continue
  search=search+[[a[1],i] for i in graph[a[1]]]
  color[a[1]]=color[a[0]]^node[a[0]][a[1]]
  visited[a[1]]=True
for i in color:
  print(i)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n=int(input())
graph=[[] for i in range(n)]
color=[-1]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append([b-1,c%2])
    graph[b-1].append([a-1,c%2])
def coloring(pre,c):
  color[pre]=c
  for i,j in graph[pre]:
    if color[i]<0:
      coloring(i,color[pre]^j)
coloring(0,1)
for i in color:
  print(i)

Buggy python submission (verdict: Runtime Error):
n=int(input())
graph=[[False]*n for i in range(n)] #点の隣接連結を示す
color=[0]*n
visited=[False]*n #dfsを書くときに訪問した点を記録する
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1][b-1][0],graph[b-1][a-1][0],graph[a-1][b-1][1],graph[b-1][a-1][1]=True,True,c,c
def dfs(v):
    visited[v]=True
    for i in range(n):
        if graph[v][i]==False:continue
        if visited[i]==True:continue
        color[i]=color[v]^(graph[v][i][1]%2)
        dfs(i)#訪問済みでなく辺によってつながれている頂点に対して同じ操作を繰り返す
for i in range(n):
  dfs(i)
print(ans)


Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n=int(input())
graph=[[] for i in range(n)]
color=[-1]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append([b-1,c%2])
    graph[b-1].append([a-1,c%2])
def coloring(pre,c):
  color[pre]=c
  for i,j in graph[pre]:
    if color[i]<0:
      coloring(i,color[pre]^j)
coloring(0,1)
for i in color:
  print(i)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
graph=[[False]*n for i in range(n)] #点の隣接連結を示す
color=[0]*n
visited=[False]*n #dfsを書くときに訪問した点を記録する
for i in range(m):
    a,b,c=map(int,input().split())
    graph[a-1][b-1][0],graph[b-1][a-1][0],graph[a-1][b-1][1],graph[b-1][a-1][1]=True,True,c,c
def dfs(v):
    visited[v]=True
    for i in range(n):
        if graph[v][i]==False:continue
        if visited[i]==True:continue
        color[i]=color[v]^(graph[v][i][1]%2)
        dfs(i)#訪問済みでなく辺によってつながれている頂点に対して同じ操作を繰り返す
for i in range(n):
  dfs(i)
print(ans)


Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n=int(input())
graph=[[] for i in range(n)]
color=[-1]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append([b-1,c%2])
    graph[b-1].append([a-1,c%2])
def coloring(pre,c):
  color[pre]=c
  for i,j in graph[pre]:
    if color[i]<0:
      coloring(i,color[pre]^j)
coloring(0,1)
for i in color:
  print(i)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
graph=[[False]*n for i in range(n)] #点の隣接連結を示す
color=[0]*n
visited=[False]*n #dfsを書くときに訪問した点を記録する
for i in range(m):
    a,b,c=map(int,input().split())
    graph[a-1][b-1][0],graph[b-1][a-1][0],graph[a-1][b-1][1],graph[b-1][a-1][1]=True,True,c,c
def dfs(v):
    visited[v]=True
    for i in range(n):
        if graph[v][i]==False:continue
        if visited[i]==True:continue
        color[i]=color[v]^(graph[v][i]%2)
        dfs(i)#訪問済みでなく辺によってつながれている頂点に対して同じ操作を繰り返す
for i in range(n):
  dfs(i)
print(ans)


Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n=int(input())
graph=[[] for i in range(n)]
color=[-1]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append([b-1,c%2])
    graph[b-1].append([a-1,c%2])
def coloring(pre,c):
  color[pre]=c
  for i,j in graph[pre]:
    if color[i]<0:
      coloring(i,color[pre]^j)
coloring(0,1)
for i in color:
  print(i)

Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = [0 for i in range (n)]
for i in range(n):
  a,b,c = map(int,input().split())
  if c % 2 == 1:
    if ans[a-1] == ans[b-1]:
      ans[b-1] = 1 - ans[b-1]
for i in range(n):
  print(ans[i])


Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n=int(input())
graph=[[] for i in range(n)]
color=[-1]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append([b-1,c%2])
    graph[b-1].append([a-1,c%2])
def coloring(pre,c):
  color[pre]=c
  for i,j in graph[pre]:
    if color[i]<0:
      coloring(i,color[pre]^j)
coloring(0,1)
for i in color:
  print(i)

Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = [0 for i in range (n)]
for i in range(n):
  a,b,c = map(int,input().split())
  if c % 2 == 1:
    if ans[a-1] == ans[b-1]:
      ans[b-1] = 1 - ans[b-1]
for i in range(n):
  print(ans[i])


Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n=int(input())
graph=[[] for i in range(n)]
color=[-1]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append([b-1,c%2])
    graph[b-1].append([a-1,c%2])
def coloring(pre,c):
  color[pre]=c
  for i,j in graph[pre]:
    if color[i]<0:
      coloring(i,color[pre]^j)
coloring(0,1)
for i in color:
  print(i)

Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = [0 for i in range (n)]
for i in range(n):
  a,b,c = map(int,input().split())
  if c % 2 == 1:
    if ans[a-1] == ans[b-1]:
      ans[b-1] = 1 - ans[b-1]
for i in range(n):
  print(ans[i])


Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n=int(input())
graph=[[] for i in range(n)]
color=[-1]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append([b-1,c%2])
    graph[b-1].append([a-1,c%2])
def coloring(pre,c):
  color[pre]=c
  for i,j in graph[pre]:
    if color[i]<0:
      coloring(i,color[pre]^j)
coloring(0,1)
for i in color:
  print(i)

Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = [0 for i in range (n)]
for i in range(n):
  a,b,c = map(int,input().split())
  if c % 2 == 1:
    if ans[a-1] == ans[b-1]:
      ans[b-1] = 1 - ans[b-1]
for i in range(n):
  print(ans[i])


Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n=int(input())
graph=[[] for i in range(n)]
color=[-1]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append([b-1,c%2])
    graph[b-1].append([a-1,c%2])
def coloring(pre,c):
  color[pre]=c
  for i,j in graph[pre]:
    if color[i]<0:
      coloring(i,color[pre]^j)
coloring(0,1)
for i in color:
  print(i)

Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = [0 for i in range (n)]
for i in range(n):
  a,b,c = map(int,input().split())
  if c % 2 == 1:
    if ans[a-1] == ans[b-1]:
      ans[b-1] = 1 - ans[b-1]
for i in range(n):
  print(ans[i])


Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n=int(input())
graph=[[] for i in range(n)]
color=[-1]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append([b-1,c%2])
    graph[b-1].append([a-1,c%2])
def coloring(pre,c):
  color[pre]=c
  for i,j in graph[pre]:
    if color[i]<0:
      coloring(i,color[pre]^j)
coloring(0,1)
for i in color:
  print(i)

Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = [0 for i in range (n)]
for i in range(n):
  a,b,c = map(int,input().split())
  if c % 2 == 1:
    if ans[a-1] == ans[b-1]:
      ans[b-1] = 1 - ans[b-1]
for i in range(n):
  print(ans[i])


Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n=int(input())
graph=[[] for i in range(n)]
color=[-1]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append([b-1,c%2])
    graph[b-1].append([a-1,c%2])
def coloring(pre,c):
  color[pre]=c
  for i,j in graph[pre]:
    if color[i]<0:
      coloring(i,color[pre]^j)
coloring(0,1)
for i in color:
  print(i)

Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = [0 for i in range (n)]
for i in range(n):
  a,b,c = map(int,input().split())
  if c % 2 == 1:
    if ans[a-1] == ans[b-1]:
      ans[b-1] = 1 - ans[b-1]
for i in range(n):
  print(ans[i])


Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n=int(input())
graph=[[] for i in range(n)]
color=[-1]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append([b-1,c%2])
    graph[b-1].append([a-1,c%2])
def coloring(pre,c):
  color[pre]=c
  for i,j in graph[pre]:
    if color[i]<0:
      coloring(i,color[pre]^j)
coloring(0,1)
for i in color:
  print(i)

Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = [0 for i in range (n)]
for i in range(n):
  a,b,c = map(int,input().split())
  if c % 2 == 1:
    if ans[a-1] == ans[b-1]:
      ans[b-1] = 1 - ans[b-1]
for i in range(n):
  print(ans[i])


Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n=int(input())
graph=[[] for i in range(n)]
color=[-1]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append([b-1,c%2])
    graph[b-1].append([a-1,c%2])
def coloring(pre,c):
  color[pre]=c
  for i,j in graph[pre]:
    if color[i]<0:
      coloring(i,color[pre]^j)
coloring(0,1)
for i in color:
  print(i)

Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = [0 for i in range (n)]
for i in range(n):
  a,b,c = map(int,input().split())
  if c % 2 == 1:
    if ans[a-1] == ans[b-1]:
      ans[b-1] = 1
for i in range(n):
  print(ans[i])
    


Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n=int(input())
graph=[[] for i in range(n)]
color=[-1]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append([b-1,c%2])
    graph[b-1].append([a-1,c%2])
def coloring(pre,c):
  color[pre]=c
  for i,j in graph[pre]:
    if color[i]<0:
      coloring(i,color[pre]^j)
coloring(0,1)
for i in color:
  print(i)

Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = [0 for i in range (n)]
for i in range(n):
  a,b,c = map(int,input().split())
  if c % 2 == 1:
    if ans[a-1] == ans[b-1]:
      ans[b-1] == 1
for i in range(n):
  print(ans[i])
    

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n=int(input())
graph=[[] for i in range(n)]
color=[-1]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append([b-1,c%2])
    graph[b-1].append([a-1,c%2])
def coloring(pre,c):
  color[pre]=c
  for i,j in graph[pre]:
    if color[i]<0:
      coloring(i,color[pre]^j)
coloring(0,1)
for i in color:
  print(i)