Disteibuting Integers atcoder Beginner Contest 160 help needed!

Atcoder begineer contest 160 problem F
Link:-DIstributing Integers.

Can you give the test case where I am getting Wrong Answer!
my submission link is:-
Atcoder submisssion link
and what changes shall I adopt to convert it to full AC.
Thanks in advance !

Solved using rerooting concept and tree dp