import collections t=int(input()) for i in range(t): n=int(input()) l=list(map(int,input().split())) l=collections.Counter(l) l=list(l.values()) l.sort() l.reverse() ans=0 for i in range(n//3+1): ct=0 for j in range(len(l)): if l[j]>0: ct+=1 l[j]-=1 if ct==3: break if ct==3: ans+=1 print(ans)