Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(50000)

n=int(input())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]
for i in range(n-1):
        a,b,c=map(int,input().split())
        kilist[a-1].append((b,c))
        kilist[b-1].append((a,c))
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        else:
            pass

        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==-1:
                    search(k[0])
search(2)
for i in anslist:
    print(i%2)


Fixed submission:
import sys
sys.setrecursionlimit(100000)

n=int(input())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]
for i in range(n-1):
        a,b,c=map(int,input().split())
        kilist[a-1].append((b,c))
        kilist[b-1].append((a,c))
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        else:
            pass

        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==-1:
                    search(k[0])
search(2)
for i in anslist:
    print(i%2)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

n=int(input())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]
for i in range(n-1):
        a,b,c=map(int,input().split())
        kilist[a-1].append((b,c))
        kilist[b-1].append((a,c))
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        else:
            pass

        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==-1:
                    search(k[0])
search(2)
for i in anslist:
    print(i%2)


Fixed submission:
import sys
sys.setrecursionlimit(100000)

n=int(input())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]
for i in range(n-1):
        a,b,c=map(int,input().split())
        kilist[a-1].append((b,c))
        kilist[b-1].append((a,c))
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        else:
            pass

        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==-1:
                    search(k[0])
search(2)
for i in anslist:
    print(i%2)

Buggy python submission (verdict: Runtime Error):
n=int(input())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]

for i in range(n-1):
        a,b,c=map(int,input().split())
        kilist[a-1].append((b,c))
        kilist[b-1].append((a,c))
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        else:
            pass

        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==-1:
                    search(k[0])
search(2)
for i in anslist:
	print(i%2)


Fixed submission:
import sys
sys.setrecursionlimit(100000)

n=int(input())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]
for i in range(n-1):
        a,b,c=map(int,input().split())
        kilist[a-1].append((b,c))
        kilist[b-1].append((a,c))
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        else:
            pass

        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==-1:
                    search(k[0])
search(2)
for i in anslist:
    print(i%2)

Buggy python submission (verdict: Runtime Error):
#d-even relation
n=int(input())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]

for i in range(n-1):
        a,b,c=map(int,input().split())
        kilist[a-1].append((b,c))
        kilist[b-1].append((a,c))
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=(anslist[i-1]+j[1])
        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==-1:

                    search(k[0])
                else:
                    return
                   
        else:
            return 

search(1)
for i in anslist:
    print(i%2)


Fixed submission:
import sys
sys.setrecursionlimit(100000)

n=int(input())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]
for i in range(n-1):
        a,b,c=map(int,input().split())
        kilist[a-1].append((b,c))
        kilist[b-1].append((a,c))
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        else:
            pass

        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==-1:
                    search(k[0])
search(2)
for i in anslist:
    print(i%2)

Buggy python submission (verdict: Runtime Error):
#d-even relation
n=int(input())
visitedlist=[-1 for  i in range(n)]
lists=[tuple(map(int,input().split())) for i in range(n-1)]
kilist=[[] for i in range(n)]
for i in lists:
    kilist[i[0]-1].append([i[1],i[2]])
    kilist[i[1]-1].append([i[0],i[2]])   
anslist=[0 for i in range(n)]
searchedlist=[0 for i in range(n)]
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=(anslist[i-1]+j[1])%2
        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==0:
                    search(k[0])
        else:
            return 

search(1)
for i in anslist:
    print(i%2)


Fixed submission:
import sys
sys.setrecursionlimit(100000)

n=int(input())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]
for i in range(n-1):
        a,b,c=map(int,input().split())
        kilist[a-1].append((b,c))
        kilist[b-1].append((a,c))
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        else:
            pass

        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==-1:
                    search(k[0])
search(2)
for i in anslist:
    print(i%2)

Buggy python submission (verdict: Runtime Error):
#d-even relation
n=int(input())
visitedlist=[-1 for  i in range(n)]
lists=[tuple(map(int,input().split())) for i in range(n-1)]
kilist=[[] for i in range(n)]
for i in lists:
    kilist[i[0]-1].append([i[1],i[2]])
    kilist[i[1]-1].append([i[0],i[2]])   
anslist=[0 for i in range(n)]
#開始地点1のところは0を基準としている
#1には初めに訪れる
searchedlist=[0 for i in range(n)]
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==0:
                    search(k[0])
                else:
                    pass
        else:
            pass

search(1)
for i in anslist:
    print(i%2)


Fixed submission:
import sys
sys.setrecursionlimit(100000)

n=int(input())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]
for i in range(n-1):
        a,b,c=map(int,input().split())
        kilist[a-1].append((b,c))
        kilist[b-1].append((a,c))
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        else:
            pass

        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==-1:
                    search(k[0])
search(2)
for i in anslist:
    print(i%2)

Buggy python submission (verdict: Runtime Error):
#d-even relation
#ふかさ優先探索の実装
#再起関数の実装を行う
n=int(input())
visitedlist=[-1 for  i in range(n)]
lists=[tuple(map(int,input().split())) for i in range(n-1)]
kilist=[[] for i in range(n)]
for i in lists:
    kilist[i[0]-1].append([i[1],i[2]])
    kilist[i[1]-1].append([i[0],i[2]])   
anslist=[0 for i in range(n)]
#開始地点1のところは0を基準としている
#1には初めに訪れる
def search(i):
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        if flag>0:    
            for k in kilist[i-1]:
              search(k[0])   	
        else:
            pass

search(3)
for i in anslist:
  print(i%2)

Fixed submission:
import sys
sys.setrecursionlimit(100000)

n=int(input())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]
for i in range(n-1):
        a,b,c=map(int,input().split())
        kilist[a-1].append((b,c))
        kilist[b-1].append((a,c))
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        else:
            pass

        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==-1:
                    search(k[0])
search(2)
for i in anslist:
    print(i%2)

Buggy python submission (verdict: Runtime Error):
#d-even relation
#ふかさ優先探索の実装
#再起関数の実装を行う
n=int(input())
visitedlist=[-1 for  i in range(n)]
lists=[tuple(map(int,input().split())) for i in range(n-1)]
kilist=[[] for i in range(n)]
for i in lists:
    kilist[i[0]-1].append(i[1:])
    kilist[i[1]-1].append(i[0:3:2])
visitedlist[0]=1
anslist=[0 for i in range(n)]
#開始地点1のところは0を基準としている
#1には初めに訪れる
def search(i):
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        if flag>0:    
            for k in kilist[i-1]:
                return search(k[0])           
search(1)
print(anslist)

Fixed submission:
import sys
sys.setrecursionlimit(100000)

n=int(input())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]
for i in range(n-1):
        a,b,c=map(int,input().split())
        kilist[a-1].append((b,c))
        kilist[b-1].append((a,c))
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        else:
            pass

        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==-1:
                    search(k[0])
search(2)
for i in anslist:
    print(i%2)

Buggy python submission (verdict: Runtime Error):
#d-even relation
#ふかさ優先探索の実装
#再起関数の実装を行う
n=int(input())
visitedlist=[-1 for  i in range(n)]
lists=[tuple(map(int,input().split())) for i in range(n-1)]
kilist=[[] for i in range(n)]
for i in lists:
    kilist[i[0]-1].append(i[1:])
    kilist[i[1]-1].append(i[0:3:2])
visitedlist[0]=1
anslist=[0 for i in range(n)]
#開始地点1のところは0を基準としている
#1には初めに訪れる
def search(i):
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                
                if j[1]%2==0:
                    anslist[j[0]-1]=anslist[i-1]
                elif j[1]%2!=0:
                    anslist[j[0]-1]=1-anslist[i-1]      
        if flag>0:    
            for j in kilist[i-1]:
                return search(j[0])
        else:
            pass
            
search(1)
for k in anslist:
    print(k)


Fixed submission:
import sys
sys.setrecursionlimit(100000)

n=int(input())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]
for i in range(n-1):
        a,b,c=map(int,input().split())
        kilist[a-1].append((b,c))
        kilist[b-1].append((a,c))
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        else:
            pass

        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==-1:
                    search(k[0])
search(2)
for i in anslist:
    print(i%2)

Buggy python submission (verdict: Runtime Error):
n=int(input())

lists=[tuple(map(int,input().split())) for i in range(n-1)]
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
for i in lists:
    kilist[i[0]-1].append(i[1:])
    kilist[i[1]-1].append(i[0:3:2])
visitedlist[0]=1
anslist=[0 for i in range(n)]
#開始地点1のところは0を基準としている
#1には初めに訪れる
def search(i):
        flag=False
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag=True
                if j[1]%2==0:
                    anslist[j[0]-1]=anslist[i-1]
                elif j[1]%2!=0:
                    anslist[j[0]-1]=1-anslist[i-1]      
        if flag:    
            for j in kilist[i-1]:
                return search(j[0])
            
search(1)
for k in anslist:
    print(k)

Fixed submission:
import sys
sys.setrecursionlimit(100000)

n=int(input())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]
for i in range(n-1):
        a,b,c=map(int,input().split())
        kilist[a-1].append((b,c))
        kilist[b-1].append((a,c))
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        else:
            pass

        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==-1:
                    search(k[0])
search(2)
for i in anslist:
    print(i%2)

Buggy python submission (verdict: Runtime Error):
#d-even relation
#ふかさ優先探索の実装
#再起関数の実装を行う
n=int(input())
visitedlist=[-1 for  i in range(n)]
lists=[tuple(map(int,input().split())) for i in range(n-1)]
kilist=[[] for i in range(n)]
for i in lists:
    kilist[i[0]-1].append(i[1:])
    kilist[i[1]-1].append(i[0:3:2])
visitedlist[0]=1
anslist=[0 for i in range(n)]
#開始地点1のところは0を基準としている
#1には初めに訪れる
def search(i):
        flag=False
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag=True
                if j[1]%2==0:
                    anslist[j[0]-1]=anslist[i-1]
                elif j[1]%2!=0:
                    anslist[j[0]-1]=1-anslist[i-1]      
            else:
                pass  
        if flag:    
            for j in kilist[i-1]:
                return search(j[0])
        if not flag:
            pass
            
search(1)
for k in anslist:
    print(k)


Fixed submission:
import sys
sys.setrecursionlimit(100000)

n=int(input())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]
for i in range(n-1):
        a,b,c=map(int,input().split())
        kilist[a-1].append((b,c))
        kilist[b-1].append((a,c))
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        else:
            pass

        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==-1:
                    search(k[0])
search(2)
for i in anslist:
    print(i%2)

Buggy python submission (verdict: Runtime Error):
#d-even relation
#ふかさ優先探索の実装
#再起関数の実装を行う
visitedlist=[-1 for  i in range(n)]
n=int(input())
lists=[tuple(map(int,input().split())) for i in range(n-1)]

kilist=[[] for i in range(n)]
for i in lists:
    kilist[i[0]-1].append(i[1:])
    kilist[i[1]-1].append(i[0:3:2])

visitedlist[0]=1
anslist=[0 for i in range(n)]
#開始地点1のところは0を基準としている
#1には初めに訪れる
def search(i):
        flag=False
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag=True
                if j[1]%2==0:
                    anslist[j[0]-1]=anslist[i-1]
                elif j[1]%2!=0:
                    anslist[j[0]-1]=1-anslist[i-1]      
            else:
                pass  
        if flag:    
            for j in kilist[i-1]:
                return search(j[0])
        if not flag:
            pass
            
search(1)
for k in anslist:
    print(k)

Fixed submission:
import sys
sys.setrecursionlimit(100000)

n=int(input())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]
for i in range(n-1):
        a,b,c=map(int,input().split())
        kilist[a-1].append((b,c))
        kilist[b-1].append((a,c))
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        else:
            pass

        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==-1:
                    search(k[0])
search(2)
for i in anslist:
    print(i%2)