https://www.codechef.com/APRIL19B/problems/SUBREM

wrong-answer

#1

https://www.codechef.com/APRIL19B/problems/SUBREM
cant figure out why my solution is wrong
import sys
sys.setrecursionlimit(100010)
t=int(input())
lis1=list()
dic=dict()
#dic=dict()
#sum=[]
k=0
def maxi(i):
return max(-k,lis1[i-1]+sum(map(maxi,dic[i])))

while t!=0:
n,k=map(int,input().split())
lis1=list(map(int,input().split()))
dic=dict()
for i in range(1,n+1):
dic[i]=[]
for i in range(n-1):
a,b=map(int,input().split())
if a in dic:
dic[a].append(b)
else:
dic[a]=[]
dic[a].append(b)

print(maxi(1))
t=t-1