There are multiply test case . For each case , first line contains a integer n (3 < = n < = 40000) the number of node is from 0 to n-1. next line contains n integers a0,a2…an-1 ( 1<= ai <= 100000 ) . Ai is the money of bribery for the solider whose ID is i . next line contains n-1 integers f1, f2 …fn-1 ( 0 <= fi < n ) . fi is the boss of solider i. next line contains a integer m (1<= m<=40000). Next q lines contain 3 integers l ,r ,p (0 < l < = r < n,p < l or p>r),l,r means that AFA bribe soliders whose Id are between l and r.p is ZJiaQ's ID Now.