Salary Inequity

No attempts yetTime limit10sMemory limit256 MB

Problem

A company has NN employees. Every employee except one has a direct supervisor. The employee with no direct supervisor is an indirect supervisor of every other employee in the company. Employee XX is a subordinate of employee YY if YY is the direct supervisor of XX, or if the direct supervisor of XX is a subordinate of YY.

The HR department wants to measure salary inequity. The inequity of an employee is the largest salary among that employee and all of that employee's subordinates, minus the smallest salary among the same group.

An employee sometimes raises the salary of that employee and all of that employee's subordinates by the same amount. Process the raises and the inequity queries in the order they are given.

Input

The first line contains the number of companies TT. TT is at most 20.

Each company is given as follows. The first line contains the number of employees NN. Employees are numbered with distinct integers from 1 to NN. The next line contains N1N-1 integers, and the KKth of them is the number of the direct supervisor of employee K+1K+1. The next line contains NN integers, and the KKth of them is the salary of employee KK. The next line contains the number of events QQ. Each of the following QQ lines holds one event. A raise starts with the letter R, followed by an employee number and the amount added to the salary of that employee and all of that employee's subordinates. An inequity query starts with the letter Q, followed by the number of the employee whose inequity you must report.

  • 2N10000002 \le N \le 1\,000\,000
  • 1Q100001 \le Q \le 10\,000

For every employee KK, the number of the direct supervisor of KK is smaller than KK. Initial salaries are between 1 and 1000. Every raise amount is between 1 and 1000.

Output

For each inequity query, print the inequity of that employee on its own line.