The first line contains the number of employees n and the number of initial praises m. Employees are numbered from 1 to n. (2≤n,m≤100000)
The second line contains the direct manager of employees 1 through n, in order. A manager's number is smaller than the employee's own number. Employee 1 is the president and has no manager, so −1 is given for employee 1.
Each of the next m lines contains an employee number i who was praised by their direct manager and the praise value w. (2≤i≤n, 1≤w≤1000) The same employee may be praised more than once.
The president has no manager, so the president receives no praise.