Items and Heroes

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

There is a rooted tree of NN vertices. The vertices are numbered by integers from 11 to NN, with vertex 11 as the root. The parent of vertex ii (2iN2 \le i \le N) is denoted as P_iP\_i.

Each vertex has a box with items. Also, there is a hero in each vertex.

In the beginning, the box in vertex ii contains A_iA\_i items.

In each vertex ii, the hero from that vertex has the quest to collect C_iC\_i items. The hero in vertex ii can choose some vertices from the subtree rooted at vertex ii and take as many items as she wants from each of the selected vertices. One item cannot be taken by more than one hero.

Determine if it is possible for the heroes to act in such a way that all NN quests will be completed.

Additionally, QQ queries are given. In the jj-th query, the integers t_jt\_j, v_jv\_j, x_jx\_j are given, and the values are changed as follows:

  • If t_j=1t\_j=1, change the value of A_v_jA\_{v\_j} to x_jx\_j.
  • If t_j=2t\_j=2, change the value of C_v_jC\_{v\_j} to x_jx\_j.

The queries are applied sequentially. The changes made in each query remain for all the subsequent queries as well. After each query, determine if it is possible to complete all NN quests.

입력

The first line of input contains one integer NN (1N1051 \le N \le 10^5).

The second line contains N1N-1 integers P_2,P_3,,P_NP\_2, P\_3, \ldots, P\_N: the parents of vertices 2,3,,N2, 3, \ldots, N (1P_i<i1 \le P\_i < i).

The third line contains NN integers A_1,A_2,,A_NA\_1, A\_2, \ldots, A\_N (1A_i1091 \le A\_i \le 10^9).

The fourth line contains NN integers C_1,C_2,,C_NC\_1, C\_2, \ldots, C\_N (1C_i1091 \le C\_i \le 10^9).

The fifth line contains one integer QQ (1Q1051 \le Q \le 10^5).

Each of the following QQ lines contains one query described by three integers t_jt\_j, v_jv\_j and x_jx\_j (1t_i21 \le t\_i \le 2, 1v_iN1 \le v\_i \le N, 1x_i1091 \le x\_i \le 10^9): the type of the query, the number of vertex and the new value for A_v_iA\_{v\_i} (for the query of the first type) or C_v_iC\_{v\_i} (for the query of the second type), respectively.

출력

On the first line, print "Yes" if it is possible to complete all NN quests at once, or "No" otherwise.

On the following QQ lines, print the answers for the queries in the same format, one per line.

힌트

In Example 1, the hero from vertex 1 takes two items from the box at vertex 1 and one item from the box at vertex 3, the hero from vertex 2 takes an item from the box at vertex 2, and the hero from vertex 3 takes two items from the box at vertex 3. So, all three quests are completed.

The first query changes the number of items in the box at vertex 1 from two to one. In this case, there are not enough items to complete all three quests.

The second query changes the number of items to complete the quest for the hero at vertex 3 from two to one. In this case, the hero at vertex 1 takes one item from the box at vertex 1 and two items from the box at vertex 3, the hero at vertex 2 take one item from the box at vertex 2, the hero at vertex 3 takes one item from the box at vertex 3, and all three quests are again completed.