{"trustable":false,"sections":[{"title":"Statement","value":{"format":"MD","content":"Rock-Paper-Scissors is a two-player game, where each player chooses one of Rock, Paper, or Scissors. Here are the three cases in which a player gets one point:\n- Choosing Rock wins over a player choosing scissors. \n- Choosing Scissors wins over a player choosing Paper. \n- Choosing Paper wins over a player choosing Rock\n\nIn all other cases, the player doesn’t get any points. \n\n\nBahosain and his friend Bayashout played $N$ rounds of this game. Unlike Bayashout, Bahosain was too lazy to decide what to play next for each round, so before starting to play, he chose three integers **$X+Y+Z \u003d N $** and **$X, Y, Z ≥ 0$**, and then played Rock for the first $X$ rounds, Paper for the next $Y$ round, and Scissors for the last $Z$ rounds.\n\nBayashout got more points in the $N$ rounds and won. Given the moves played by Bayashout in each round, \nBahosain wants to know the number of ways in which he could have chosen $X, Y$ and $Z$ such that he wins in the $N$ rounds. \n\nThe winner of the $N$ rounds is the player that gets more total points in the $N$ rounds."}},{"title":"Input","value":{"format":"MD","content":"The first line of input contains $ T (1 ≤ T ≤ 64)$, where $T$ is the number of test cases. \n\n The first line of each test case contains an integer $N (1 ≤ N ≤ 1000)$ that represents the number of rounds. \n The next line contains a string of $N$ uppercase letters, the first letter represents the choice of Bayashout for the first round, the second letter represents his choice for the second round, and so on. \n\nEach letter in the string is one of the following: $R$ ( Rock), $P$ (Paper), or $S$ (Scissors). "}},{"title":"Output","value":{"format":"MD","content":"For each test case, print a single line with the number of ways in which Bahosain could have won. \n"}},{"title":"Test","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e\n4 \n3 \nRPS \n1 \nR \n5 \nPPRSR \n5 \nRPSPR\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e\n3 \n1 \n1 \n5\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}