This problem is actually a subproblem of problem G from the same contest.

There are $n$ candies in a candy box. The type of the $i$-th candy is $a_i$ ($1 \le a_i \le n$).

You have to prepare a gift using some of these candies with the following restriction: the numbers of candies of each type presented in a gift should be all distinct (i. e. for example, a gift having two candies of type $1$ and two candies of type $2$ is bad). 

It is possible that multiple types of candies are completely absent from the gift. It is also possible that not all candies of some types will be taken to a gift.

Your task is to find out the maximum possible size of the single gift you can prepare using the candies you have.

You have to answer $q$ independent queries.

If you are Python programmer, consider using PyPy instead of Python when you submit your code.


-----Input-----

The first line of the input contains one integer $q$ ($1 \le q \le 2 \cdot 10^5$) — the number of queries. Each query is represented by two lines.

The first line of each query contains one integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the number of candies.

The second line of each query contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le n$), where $a_i$ is the type of the $i$-th candy in the box.

It is guaranteed that the sum of $n$ over all queries does not exceed $2 \cdot 10^5$.


-----Output-----

For each query print one integer — the maximum possible size of the single gift you can compose using candies you got in this query with the restriction described in the problem statement.


-----Example-----
Input
3
8
1 4 8 4 5 6 3 8
16
2 1 3 3 4 3 4 4 1 3 2 2 2 4 1 1
9
2 2 4 4 4 7 7 7 7

Output
3
10
9



-----Note-----

In the first query, you can prepare a gift with two candies of type $8$ and one candy of type $5$, totalling to $3$ candies.

Note that this is not the only possible solution — taking two candies of type $4$ and one candy of type $6$ is also valid.

```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 = '\'\'\'input\n3\n8\n1 4 8 4 5 6 3 8\n16\n2 1 3 3 4 3 4 4 1 3 2 2 2 4 1 1\n9\n2 2 4 4 4 7 7 7 7\n\'\'\'\nfrom sys import stdin, setrecursionlimit\nfrom itertools import combinations\nimport collections\n\ndef doc(s):\n    if hasattr(s, \'__call__\'):\n        s = s.__doc__\n    def f(g):\n        g.__doc__ = s\n        return g\n    return f\n\nclass heapdict(collections.MutableMapping):\n    __marker = object()\n\n    @staticmethod\n    def _parent(i):\n        return ((i - 1) >> 1)\n\n    @staticmethod\n    def _left(i):\n        return ((i << 1) + 1)\n\n    @staticmethod\n    def _right(i):\n        return ((i+1) << 1)    \n    \n    def __init__(self, *args, **kw):\n        self.heap = []\n        self.d = {}\n        self.update(*args, **kw)\n\n    @doc(dict.clear)\n    def clear(self):\n        self.heap.clear()\n        self.d.clear()\n\n    @doc(dict.__setitem__)\n    def __setitem__(self, key, value):\n        if key in self.d:\n            self.pop(key)\n        wrapper = [value, key, len(self)]\n        self.d[key] = wrapper\n        self.heap.append(wrapper)\n        self._decrease_key(len(self.heap)-1)\n\n    def _min_heapify(self, i):\n        l = self._left(i)\n        r = self._right(i)\n        n = len(self.heap)\n        if l < n and self.heap[l][0] < self.heap[i][0]:\n            low = l\n        else:\n            low = i\n        if r < n and self.heap[r][0] < self.heap[low][0]:\n            low = r\n\n        if low != i:\n            self._swap(i, low)\n            self._min_heapify(low)\n\n    def _decrease_key(self, i):\n        while i:\n            parent = self._parent(i)\n            if self.heap[parent][0] < self.heap[i][0]: break\n            self._swap(i, parent)\n            i = parent\n\n    def _swap(self, i, j):\n        self.heap[i], self.heap[j] = self.heap[j], self.heap[i]\n        self.heap[i][2] = i\n        self.heap[j][2] = j\n\n    @doc(dict.__delitem__)\n    def __delitem__(self, key):\n        wrapper = self.d[key]\n        while wrapper[2]:\n            parentpos = self._parent(wrapper[2])\n            parent = self.heap[parentpos]\n            self._swap(wrapper[2], parent[2])\n        self.popitem()\n\n    @doc(dict.__getitem__)\n    def __getitem__(self, key):\n        return self.d[key][0]\n\n    @doc(dict.__iter__)\n    def __iter__(self):\n        return iter(self.d)\n\n    def popitem(self):\n        """D.popitem() -> (k, v), remove and return the (key, value) pair with lowest\\nvalue; but raise KeyError if D is empty."""\n        wrapper = self.heap[0]\n        if len(self.heap) == 1:\n            self.heap.pop()\n        else:\n            self.heap[0] = self.heap.pop(-1)\n            self.heap[0][2] = 0\n            self._min_heapify(0)\n        del self.d[wrapper[1]]\n        return wrapper[1], wrapper[0]    \n\n    @doc(dict.__len__)\n    def __len__(self):\n        return len(self.d)\n\n    def peekitem(self):\n        """D.peekitem() -> (k, v), return the (key, value) pair with lowest value;\\n but raise KeyError if D is empty."""\n        return (self.heap[0][1], self.heap[0][0])\n\ndel doc\n__all__ = [\'heapdict\']\n\n\ndef check(num, arr):\n\tprint(num)\n\tfor i in range(len(arr)):\n\t\tif abs(arr[i] - num) <= k:\n\t\t\tpass\n\t\telse:\n\t\t\treturn False\n\treturn True\n\n\ndef get_heap(arr, n):\n\tmydict = dict()\n\tfor i in arr:\n\t\tif i in mydict:\n\t\t\tmydict[i] +=1 \n\t\telse:\n\t\t\tmydict[i] = 1\n\n\tmheap = heapdict()\n\tfor i in mydict:\n\t\tmheap[i] = -mydict[i]\n\treturn mheap\n\n\n# main starts\nq = int(stdin.readline().strip())\nfor _ in range(q):\n\tn = int(stdin.readline().strip())\n\tarr = list(map(int, stdin.readline().split()))\n\tmheap = get_heap(arr, n)\n\tt, value = mheap.popitem()\n\tnum = -value\n\tans = num\t\n\twhile len(mheap) > 0 and num > 0:\n\t\tnum -= 1\n\t\tt, value = mheap.popitem()\n\t\tvalue = -value\n\t\tif value >= num:\n\t\t\tans += num\n\t\telse:\n\t\t\tnum = value\n\t\t\tans += num\n\tprint(ans)\n\n\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: