Chef's friend Alex runs a movie theatre. Due to the increasing number of platforms for watching movies online, his business is not running well. As a friend, Alex asked Chef to help him maximise his profits. Since Chef is a busy person, he needs your help to support his friend Alex.  
Alex's theatre has four showtimes: 12 PM, 3 PM, 6 PM and 9 PM. He has four movies which he would like to play ― let's call them A, B, C and D. Each of these movies must be played exactly once and all four must be played at different showtimes. For each showtime, the price of a ticket must be one of the following: Rs 25, Rs 50, Rs 75 or Rs 100. The prices of tickets for different showtimes must also be different.
Through his app, Alex receives various requests from his customers. Each request has the form "I want to watch this movie at this showtime". Let's assume that the number of people who come to watch a movie at a given showtime is the same as the number of requests for that movie at that showtime.
It is not necessary to accommodate everyone's requests ― Alex just wants to earn the maximum amount of money. There is no restriction on the capacity of the theatre. However, for each movie that is not watched by anyone, Alex would suffer a loss of Rs 100 (deducted from the profit).
You are given $N$ requests Alex received during one day. Find the maximum amount of money he can earn on that day by choosing when to play which movies and with which prices. 

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first line of each test case contains a single integer $N$.
- $N$ lines follow. Each of these lines contains a character $m$, followed by a space and an integer $t$, describing a request to see the movie $m$ at the showtime $t$.

-----Output-----
For each test case, print a single line containing one integer ― the maximum profit Alex can earn (possibly negative).
Finally, print a line containing one integer ― the total profit over all test cases, i.e. over $T$ days.

-----Constraints-----
- $1 \le T \le 150$
- $0 \le N \le 100$
- $m$ is 'A', 'B', 'C' or 'D'
- $t$ is $12$, $3$, $6$ or $9$

-----Subtasks-----
Subtask #1 (30 points): it is possible to fulfill all requests
Subtask #2 (70 points): original constraints

-----Example Input-----
5
12
A 3
B 12
C 6
A 9
B 12
C 12
D 3
B 9
D 3
B 12
B 9
C 6
7
A 9
A 9
B 6
C 3
D 12
A 9
B 6
2
A 9
B 6
1
D 12
0 

-----Example Output-----
575
525
-25 
-200 
-400
475

-----Explanation-----
Example case 1: The following table shows the number of people that want to watch the movies at the given showtimes:  12  3  6  9   A   0  1  0 1  B   3  0  0  2   C   1  0  2  0   D   0  2  0  0 
The maximum number of requests was sent for movie B at 12 PM. Therefore, we play this movie at this time and the tickets cost Rs 100. Next, we play movie D at 3 PM with ticket price Rs 75 and movie C at 6 PM with ticket price Rs 50. Finally, we have a slot for 9 PM and the only movie we can play at that time now is movie A, with ticket price Rs 25. The total profit is $3 \cdot 100 + 2 \cdot 75 + 2 \cdot 50 + 1 \cdot 25 = 300 + 150 + 100 + 25 = 575$. Since each movie was watched by at least one person, there is no additional loss.
Example case 2: Just like above, we show the requests in a table:  12  3  6  9   A   0  0  0 3  B   0  0  2  0   C   0  1  0  0   D   1  0  0  0 
The optimal solution is to play movie A at 9 PM, movie B at 6 PM, movie C at 3 PM and movie D at 12 PM, with decreasing ticket prices in this order. The profit is $3 \cdot 100 + 2 \cdot 75 + 1 \cdot 50 + 1 \cdot 25 = 300+150+50+25 = 525$.
Example case 3: Again, we show the requests in a table:  12  3  6  9   A   0  0  0 1  B   0  0  1  0   C   0  0  0  0   D   0  0  0  0 
The optimal solution is to play movie A at 9 PM with ticket price Rs 100, movie B at 6 PM with ticket price Rs 75 and the remaining two movies in any order at 12 PM and 3 PM ― either way, there will be nobody watching them. We earn $1 \cdot 100 + 1 \cdot 75 = 175$, but we have to deduct Rs 200, so the resulting profit is $175 - 200 = -25$.
Example case 4: The optimal solution is to play movie D at 12 PM; the other three movies go unattended. We have to deduct Rs 300, so the profit is $1 \cdot 100 - 300 = -200$.
Example case 5: Since there are no requests for any movie at any time, all movies go unattended and Alex just suffers a loss of Rs 400.
The total profit for all 5 days is $575+525-25-200-400 = 475$.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = "from pprint import pprint\nfrom numpy import where\narr =[]\nfrom sys import stdin,stdout\nfor _ in range(int(stdin.readline())):\n t = int(stdin.readline())\n a = []\n for i in range(4):\n  temp = []\n  for j in range(4):\n   temp.append(0)\n  a.append(temp)\n s = 0\n for __ in range(t):\n  mov , time = input().split()\n  time = int(time)\n  if mov == 'A':\n   if time == 12:\n    a[0][0]+=1\n   elif time ==3:\n    a[0][1]+=1\n   elif time == 6:\n    a[0][2]+=1\n   else:\n    a[0][3]+=1\n  elif mov =='B':\n   if time == 12:\n    a[1][0]+=1\n   elif time == 3:\n    a[1][1]+=1\n   elif time == 6:\n    a[1][2]+=1\n   else:\n    a[1][3]+=1\n  elif mov =='C':\n   if time == 12:\n    a[2][0]+=1\n   elif time == 3:\n    a[2][1]+=1\n   elif time == 6:\n    a[2][2]+=1\n   else:\n    a[2][3]+=1\n  else:\n   if time == 12:\n    a[3][0]+=1\n   elif time == 3:\n    a[3][1]+=1\n   elif time == 6:\n    a[3][2]+=1\n   else:\n    a[3][3]+=1\n ma = -1\n cakes =[]\n for k in range(4):\n  mai,maj=-1,-1\n  for i in range(4):\n   for j in range(4):\n    if a[i][j] > ma:\n     ma = a[i][j]\n     mai = i\n     maj = j\n  for z in range(4):\n   for x in range(4):\n    if z==mai or x == maj:\n     a[z][x]=0\n  cakes.append(ma)\n  ma = -1\n cakes = sorted(cakes,reverse=True)\n for i in range(4):\n  if cakes[i]==0:\n   s-=100\n  else:\n   if i==0:\n    s+= cakes[i]*100\n   elif i==1:\n    s+= cakes[i]*75\n   elif i==2:\n    s+= cakes[i]*50\n   elif i==3:\n    s+= cakes[i]*25\n print(s)\n arr.append(s)\n #print(arr)\nprint(sum(arr))"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 7260850