#!/usr/bin/env python def read(): return input(), map(int, raw_input().split()) def work((N, vList)): vList.sort() cntList = [] idx = 0 while idx < N: cnt = 1 while idx + 1 < N and vList[idx] == vList[idx + 1]: idx += 1 cnt += 1 cntList.append(cnt) idx += 1 ans = 0 while len(cntList) >= 3: if cntList[0] == 0: del cntList[0] continue if cntList[1] == 0: del cntList[1] continue if cntList[2] == 0: del cntList[2] continue ans += 1 cntList[0] -= 1 cntList[1] -= 1 cntList[2] -= 1 print ans if __name__ == "__main__": for i in range(input()): work(read())