#P7800. Deliver the Cake

Deliver the Cake

Deliver the Cake

Problem Description

It is Zhang3's birthday! Zhang3 has bought a birthday cake and now it's time to take it home. There are nn villages, labeled 1,2,,n1, 2, \ldots, n. There are mm bidirectional roads, the ithi^\mathrm{th} of which connects village aia_i, bib_i and it is did_i meter(s) long. The bakery locates at village ss and Zhang3's home locates at village tt. So Zhang3 wants to carry the cake from ss to tt. She can carry the cake either with her left hand or with her right hand. She can switch to the other hand during the trip, which takes extra xx second(s) each time (when she's performing this action, she must stay in her place). Switching is allowed at any place, including the middle of the roads. She can do this as many times as she like, or don't do it at all. Some villages are LEFT. When Zhang3 is at a LEFT village, she must carry the cake with her left hand at the moment. In the same way, some other villages are RIGHT, she must carry with her right hand when she's at these villages. The rest villages are called MIDDLE. There's no special rules at MIDDLE villages. Zhang3 can start and finish with any hand carrying the cake. However, if ss or tt is not MIDDLE, their special rules must be followed. Please help Zhang3 find a way to take the cake home, with the minimum amount of spent time.

Input

The first line of the input gives the number of test cases, T  (1T100)T \; (1 \le T \le 100). TT test cases follow. For each test case, the first line contains five integers $n, m, s, t, x \; (1 \le n \le 10^5, \; 1 \le m \le 2 \times 10^5, \; 1 \le x \le 10^9)$, representing the number of villages, the number of roads, the bakery's location, home's location, and the time spent for each switching. The next line contains a string of length nn, describing the type of each village. The ithi^\mathrm{th} character is either L\text{L} representing village ii is LEFT, or M\text{M} representing MIDDLE, or R\text{R} representing RIGHT. Finally, mm lines follow, the ithi^\mathrm{th} of which contains three integers ai,bi,di  (1di109)a_i, b_i, d_i \; (1 \le d_i \le 10^9), denoting a road connecting village aia_i and bib_i of length did_i. It is guaranteed that tt can be reached from ss. The sum of nn in all test cases doesn't exceed 2×1052 \times 10^5. The sum of mm doesn't exceed 4×1054 \times 10^5.

Output

For each test case, print a line with an integer, representing the minimum amount of spent time (in seconds).

Sample Input

1
3 3 1 3 100
LRM
1 2 10
2 3 10
1 3 100

Sample Output

100

Source

2020 Multi-University Training Contest 4