Problems
ACM Fail
ACM Fail
After ACM (Athletic Club de Milano) lost the game against ICPC (Internazionale Champion Phootball Club), the chiefs of ACM decided to reduce the budget of the club by the amount, equal to profits from sponsors, unobtained during the season.
How to calculate that amount? Mister S and mister A found a brilliant solution: accumulate the amounts, that the team unobtained in every game.
ACM has two types of sponsorship contracts:
\begin{enumerate}
\item Team gets \textbf{m_i} million euro for \textbf{k_i} consequent wins.
\item Team gets \textbf{m_i} million euro for \textbf{k_i} consequent games without any lose.
\end{enumerate}
If a successful sequence continues, payments are continued either - after every game of the sequence.
The amount of money, unobtained in lost/draw game, is calculated as the difference between the amount the club actually got at the end of the season, and the amount it would get at the end of the season if it wins that lost/draw game (without changing any other result).
\InputFile
First line contains integer number \textbf{c} (\textbf{1} ≤ \textbf{c} ≤ \textbf{10^4}) -- quantity of sponsorship contracts. Next \textbf{c} lines contain three integer numbers each, separated by spaces - contract type (\textbf{1} or \textbf{2}), \textbf{k} и \textbf{m} (\textbf{1} ≤ \textbf{k_i} ≤ \textbf{10^5}, \textbf{1} ≤ \textbf{m_i} ≤ \textbf{10^3}). Next line contains \textbf{g} (\textbf{1} ≤ \textbf{g} ≤ \textbf{10^5}) -- the quantity of games ACM participated in. Next line contains a string of \textbf{g} latin letters, representing the sequence of game results. \textbf{W} means win, \textbf{D} means draw, \textbf{L} means lose.
\OutputFile
Output the only number - the amount of money Mister S and Mister A will pick up from the club.
Input example #1
2 1 5 1 2 5 1 10 WWWWLWWWWW
Output example #1
10000000