In preparation for the party, you have been filling water balloons with such enthusiasm that you have not realized that almost none of them have the same amount of water. Instead of starting from scratch, you've decided to continue with your frenetic method, filling the balloons with an arbitrary amount of water, then discarding (and popping) those that are too big or too small.
For example, if you have inflated balloons with quantities of 16, 10, 9, 12 and 11 units of water, and you decide to discard the largest balloon and the two smallest ones, you will discard the balloons with quantities 9, 10 and 16, which will make you waste 35 units of water.
There will be several test cases, represented by a number $$$C$$$ in the first line. Each test case contains the values $$$E$$$, $$$A$$$, and $$$B$$$. The number $$$E$$$ of events that will take place, and the values $$$A$$$ and $$$B$$$, representing the number of smallest and largest balloons to pop, respectively ($$$0\leq A+B \lt E$$$). $$$E$$$ lines appear below, each describing an event in chronological order with two possible formats:
All test cases start with at least $$$A+B$$$ events of type H, and contain at least one event of type Q.
For each event of type Q, write on a separate line the sum of the water that would be spent if the balloons were popped at that moment. As the sum can be very large, the result will be written modulo 1,000,000,009.
At the end of each test case write three dashes '—'.
2 8 1 1 H 1 H 2 H 3 P H 4 P H 5 P 8 2 3 H 1 H 1 H 1 H 1 H 2 P H 100 P
4 5 6 --- 6 105 ---