While many claim that Richmond Hill High School is one of the most peaceful schools they've ever seen, their words aren't necessarily true. Enter mule wars, a devastating battle that has been going on for the past decade, right below the school. The mules run around trying to find jelly beans, shooting each other with deadly STRANGOs, all while trying their best not to get covfefed, the ultimate humiliation.
All of this started when the mule king, Mr. Lookinhere, learned about an escaped prisoner, which he dubbed the 'runaway jelly bean'. The king, being quite skilled in mathematics, decided that in order to maximize their chances of finding the runaway jelly bean, they needed to maximize the number of jelly beans they found. So, he fabricated a contest for his mule peasants to collect and store as many jelly beans as possible. His plan was to then search through all of the captured jelly beans every week. At the end of each week, he collects all of the jelly beans and destroys them.
You, being the supreme admiral general of programming for King Lookinhere, have been tasked to help him determine an optimal group of people to search for the following ~T~ weeks, before he gives up. In each of the ~T~ weeks, the king will provide you ~N~, the number of mules competing, which he numbers from ~1~ to ~N~ and ~C~, the number of actions that will happen, which includes the mules acquiring jelly beans, and the queries to determine the optimal group to search. Your program must respond to the following commands:
A n x: Mule ~x~ found ~n~ jelly beans.
Q x: Return the number of jelly beans mule ~x~ has.
G x: Return the number of jelly beans the first ~x~ mules have.
L x: Return the number of jelly beans the last ~x~ mules have.
Covfefe x: Mule ~x~ loses all of its jelly beans, and will be unable to collect any jelly beans given to it for the rest of the week.
The first line of input will contain ~T~ ~(1 \le T \le 1\,000)~, the number of weeks.
For each of the ~T~ weeks, the first line will contain two space separated integers, ~N~ ~(1 \le N \le 1000)~, and ~C~ ~(1 \le C \le 10\,000)~.
The next ~C~ lines will contain any of the commands specified above, followed by their targets.
For test cases worth 40 of 100 points, the input will only contain commands
L, you must output a single integer representing the number of jelly beans the specified group has in total, among all of its respective members, at the point in time the command is issued at.
Sample Input 1
1 1 2 A 100 1 Q 1
Sample Output 1
Explanation for Sample 1
There's one mule competing in the one week of competition. The first command dictates that mule 1 (the only mule in this competition) found 100 jelly beans. The second command asks for the number of jelly beans mule 1 has.
Sample Input 2
1 5 12 A 100 1 A 200 1 Q 1 Covfefe 1 A 500 1 A 375 2 Q 1 Q 2 G 2 A 500 3 G 3 L 3
Sample Output 2
300 0 375 375 875 500
Explanation for Sample 2
There is only one week of competition. There are 5 mules competing.
- Mule ~1~ finds ~100 \rightarrow [100, 0, 0, 0, 0]~
- Mule ~1~ finds ~200 \rightarrow [300, 0, 0, 0, 0]~
- Return value of mule ~1 \rightarrow 300~
- Mule ~1~ finds covfefed ~\rightarrow [x, 0, 0, 0, 0]~
- Mule ~1~ finds ~500~, but it's covfefed, so there's no impact ~\rightarrow [x, 0, 0, 0, 0]~
- Mule ~2~ finds ~375 \rightarrow [x, 375, 0, 0, 0]~
- Return value of mule ~1 \rightarrow~ covfefed ~= 0~
- Return value of mule ~2 \rightarrow 375~
- Return sum of first two mules ~\rightarrow 0 + 375 = 375~
- Mule ~3~ finds ~500 \rightarrow [x, 375, 500, 0, 0]~
- Return sum of first three mules ~\rightarrow 0 + 375 + 500 = 875~
- Return sum of last three mules ~\rightarrow 0 + 0 + 500 = 500~