Preparando MOJI
Railway network of one city consists of $$$n$$$ stations connected by $$$n-1$$$ roads. These stations and roads forms a tree. Station $$$1$$$ is a city center. For each road you know the time trains spend to pass this road. You can assume that trains don't spend time on stops. Let's define $$$dist(v)$$$ as the time that trains spend to get from the station $$$v$$$ to the station $$$1$$$.
This railway network is splitted into zones named by first $$$k$$$ capital latin letters. The zone of the $$$i$$$-th station is $$$z_i$$$. City center is in the zone A. For all other stations it is guaranteed that the first station on the road from this station to the city center is either in the same zone or in the zone with lexicographically smaller name. Any road is completely owned by the zone of the most distant end from the city center.
Tourist will arrive at the airport soon and then he will go to the city center. Here's how the trip from station $$$v$$$ to station $$$1$$$ happends:
Tourist always selects such way to buy tickets and pay fines that minimizes the total cost of trip. Let $$$f(v)$$$ be such cost for station $$$v$$$.
Unfortunately, tourist doesn't know the current values of $$$pass_i$$$ and $$$fine_i$$$ for different zones and he has forgot the location of the airport. He will ask you queries of $$$3$$$ types:
The first line contains the single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the number of stations.
Each of the next $$$n - 1$$$ lines contains three integers $$$v_i$$$, $$$u_i$$$, $$$t_i$$$ ($$$1 \leq v_i, u_i \leq n, 1 \leq t_i \leq 10^9$$$) — the ends of the $$$i$$$-th road and the time it takes a train to pass this road. It is guaranteed that this roads forms a tree.
The next line contains the single integer $$$k$$$ ($$$1 \leq k \leq 26$$$) — the number of zones.
The next line contains $$$n$$$ symbols $$$z_1z_2 \ldots z_n$$$ — $$$z_i$$$ is the name of the zone of the $$$i$$$-th station. It is guaranteed that the conditions from the second paragraph are satisfied.
The next line contains $$$k$$$ integers $$$pass_1$$$, $$$pass_2$$$, $$$\ldots$$$, $$$pass_k$$$ ($$$1 \leq pass_i \leq 10^9$$$) — initial costs of tickets.
The next line contains $$$k$$$ integers $$$fine_1$$$, $$$fine_2$$$, $$$\ldots$$$, $$$fine_k$$$ ($$$1 \leq fine_i \leq 10^9$$$) — initial fines.
The next line contains the single integer $$$T$$$ ($$$1 \leq T \leq 10^9$$$) — the time gap between scans of control system.
The next line contains the single integer $$$q$$$ ($$$1 \leq q \leq 2 \cdot 10^5$$$) — the number of queries.
Next $$$q$$$ lines contains queries as described in the statement. It is guaranteed that in the queries of the first and the second type $$$i$$$ is a correct name of the zone (one of the first $$$k$$$ capital latin letters) and $$$1 \leq c \leq 10^9$$$, and in the queries of the third type $$$1 \leq u \leq n$$$.
For each query of the third type print the answer to it.
8 1 2 7 2 3 4 2 4 3 4 5 1 5 6 6 4 7 10 6 8 6 4 AABABBDB 11 12 10 42 16 15 15 30 4 6 3 2 1 A 10 3 3 2 A 3 3 7 3 6
0 10 6 6
Note, that the fine can be cheaper than the pass.
In the first query, the airport can be located near the station $$$2$$$ or near the station $$$4$$$. During the trip, tourist will always stay in the zone A. He already has the pass for this zone so the answer is $$$0$$$.
After the second query, the cost of the pass in the zone A has become $$$10$$$.
In the third query, the airport can be located only near the station $$$3$$$. Optimal solution will be to buy the pass for zone A. During the first $$$3$$$ seconds of trip tourist will be in the zone B. Then he will move to the zone A and will be scanned there on the $$$4$$$-th and the $$$8$$$-th second of his ride. Since he have a pass for this zone, he won't pay fines.
After the forth query, the fine in the zone A has become $$$3$$$.
In the fifth query, the airport can be located only near the station $$$7$$$ and $$$f(7) = 6$$$.
In the sixth query, the airport can be located near the station $$$6$$$ or near the station $$$8$$$. Since $$$f(6)=9$$$ and $$$f(8)=6$$$ the answer is $$$6$$$.