t = gets.to_i t.times do n = gets.to_i a = gets.split.map(&:to_i) h1 = Hash.new(0) n.times do |i| h1[a[i]] += 1 end res = 0 count = 0 while true do find = false h1.each_key do |k| if h1[k] > 0 h1[k] -= 1 count += 1 end if count >= 3 count = 0 res += 1 find = true end end if !find break end end puts res end