Raj loves to listen to songs in his free time. It’s his birthday tomorrow and his friend Neelansh wants his gift to be the most unique. Being great at making music, he decides to produce a song for him. However, Raj likes songs according to their beauty. He determines the beauty of the song as the number of times all the octave musical tones are completed in ascending order.

He begins with a jumbled tone of length N and numbers each octave tone as 1,2,3….8.

Neelansh wants to maximize the beauty of the song but since he uses the trial version of the software,
- He cannot change the size of N.
- He cannot introduce any new tone, but can choose any two tones and swap their positions

However, Neelansh just received a mail that he needs to submit all his pending assignments by tomorrow. He has tons of assignments left to do, but he doesn’t want to spoil the idea of his gift. Can you help him? 

-----INPUT-----
- The first line contains a single integer T- the number of test cases  
- The first line of each test case contains a single integer N- the length of the song  
- The second line contains N- space separated integers ai,  ai+1,.....aN 

-----OUTPUT-----
For each test case, print a single line containing one integer- the maximum possible beauty of the song  

-----CONSTRAINTS-----
1<=T<=102
1<=N<=105
1<=a<=8

-----EXAMPLE INPUT-----
2

8

1 2 3 4 5 6 7 8

16

1 2 1 2 3 3 4 4 5 5 6 6 7 8 7 8

-----EXAMPLE OUTPUT-----
1

2

```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 = "# cook your dish here\nfrom collections import Counter\nimport string\nimport math\nimport sys\ndef array_int():\n    return [int(i) for i in sys.stdin.readline().split()]\ndef vary(arrber_of_variables):\n    if arrber_of_variables==1:\n        return int(sys.stdin.readline())\n    if arrber_of_variables>=2:\n        return list(map(int,sys.stdin.readline().split())) \ndef makedict(var):\n    return dict(Counter(var))\n# i am noob wanted to be better and trying hard for that\ndef printDivisors(n): \n    divisors=[]  \n    # Note that this loop runs till square root \n    i = 1\n    while i <= math.sqrt(n): \n          \n        if (n % i == 0) : \n              \n            # If divisors are equal, print only one \n            if (n//i == i) : \n                divisors.append(i) \n            else : \n                # Otherwise print both \n                divisors.extend((i,n//i)) \n        i = i + 1\n    return divisors\n\ndef countTotalBits(num):\n     \n     # convert number into it's binary and \n     # remove first two characters 0b.\n     binary = bin(num)[2:]\n     return(len(binary))\nfor _ in range(vary(1)):\n    n=vary(1)\n    num=array_int()\n    nt=makedict(num)\n    st=set((1,2,3,4,5,6,7,8))\n    for i in nt:\n        if i in st:\n            st.remove(i)\n    if len(st)!=0:\n        print(0)\n    else:\n        mini=float('inf')\n        for i in nt:\n            if nt[i]<mini:\n                mini=nt[i]\n                \n        print(mini)\n\n\n\n        \n    \n        \n    \n        \n    \n\n\t\n\n\n\n                \n\n\n\n\n\n\n    \n    \n\n    \n    \n\n\n    \n\n    \n\n\n\n    \n\n\n    \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n        \n\n    \n\n            \n    \n\n\n\n\n\n        \n        \n   \n"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 14963