from collections import Counter
T = int(input())
for _ in range(T):
    N = int(input())
    L = list(map(int, input().split()))
    cnt = Counter(L)
    count = 0
    while True:
        m = cnt.most_common(3)
        if len(m) == 3:
            if m[2][1] != 0:
                sub = Counter({i[0]: 1 for i in m})
                cnt.subtract(sub)
                count += 1
            else:
                break
        else:
            break
    print(count)