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 ch = 0 h1.each_key do |k| if h1[k] <= 0 next end h1[k] -= 1 count += 1 if h1[k] > 0 ch += 1 end if count >= 3 count = 0 res += 1 end end if ch + count < 3 break end end puts res end