Codeforces Round 963 (Div. 2)
A
Question Marks
Codeforces
800
原题
←B →
翻译中…

Tim is doing a test consisting of $4n$ questions; each question has $4$ options: 'A', 'B', 'C', and 'D'. For each option, there are exactly $n$ correct answers corresponding to that option — meaning there are $n$ questions with the answer 'A', $n$ questions with the answer 'B', $n$ questions with the answer 'C', and $n$ questions with the answer 'D'.

翻译中…

For each question, Tim wrote his answer on the answer sheet. If he could not figure out the answer, he would leave a question mark '?' for that question.

翻译中…

You are given his answer sheet of $4n$ characters. What is the maximum number of correct answers Tim can get?

翻译中…

Input

翻译中…

The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.

翻译中…

The first line of each test case contains an integer $n$ ($1 \le n \le 100$).

翻译中…

The second line of each test case contains a string $s$ of $4n$ characters ($s_i \in \{\texttt{A}, \texttt{B}, \texttt{C}, \texttt{D}, \texttt{?}\}$) — Tim's answers for the questions.

翻译中…

Output

翻译中…

For each test case, print a single integer — the maximum score that Tim can achieve.

翻译中…

Note

翻译中…

In the first test case, there is exactly one question with each answer 'A', 'B', 'C', and 'D'; so it's possible that Tim gets all his answers correct.

翻译中…

In the second test case, there are only two correct answers 'A' which makes him get exactly $2$ points in any case.

翻译中…

In the third test case, Tim can get at most $2$ correct answers with option 'A' and $2$ correct answers with option 'B'. For example, he would get $4$ points if the answers were 'AACCBBDD'.

翻译中…

In the fourth test case, he refuses to answer any question at all, which makes him get $0$ points.

翻译中…

样例

Input #1
6
1
ABCD
2
AAAAAAAA
2
AAAABBBB
2
????????
3
ABCABCABCABC
5
ACADC??ACAC?DCAABC?C
Output #1
4
2
4
0
9
13
InputCopy OutputCopy
题目信息
题号
1993A
时间限制
1 s
内存限制
256 MB
标签
贪心
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。