import java.util.*; public class _1005_2 { static int N, K, W; static int[] build_time, complete_time; static int[][] prev_build; static int build(int n) { if(complete_time[n] == -1) { int total_time = 0; for(int i=1; i<=prev_build[n][0]; i++) { int prev = prev_build[n][i]; total_time = Math.max(total_time, build(prev)); } complete_time[n] = total_time + build_time[n]; } return complete_time[n]; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); int[] ans = new int[T]; for(int t=0; t