Today, Chef decided to cook some delicious meals from the ingredients in his kitchen. There are $N$ ingredients, represented by strings $S_1, S_2, \ldots, S_N$. Chef took all the ingredients, put them into a cauldron and mixed them up.
In the cauldron, the letters of the strings representing the ingredients completely mixed, so each letter appears in the cauldron as many times as it appeared in all the strings in total; now, any number of times, Chef can take one letter out of the cauldron (if this letter appears in the cauldron multiple times, it can be taken out that many times) and use it in a meal. A complete meal is the string "codechef". Help Chef find the maximum number of complete meals he can make!

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first line of each test case contains a single integer $N$.
- $N$ lines follow. For each $i$ ($1 \le i \le N$), the $i$-th of these lines contains a single string $S_i$.

-----Output-----
For each test case, print a single line containing one integer — the maximum number of complete meals Chef can create.

-----Constraints-----
- $1 \le T \le 100$
- $1 \le N \le 100$
- $|S_1| + |S_2| + \ldots + |S_N| \le 1,000$
- each string contains only lowercase English letters

-----Example Input-----
3
6
cplusplus
oscar
deck
fee
hat
near
5
code
hacker
chef
chaby
dumbofe
5
codechef
chefcode
fehcedoc
cceeohfd
codechef

-----Example Output-----
1
2
5

-----Explanation-----
Example case 1: After mixing, the cauldron contains the letter 'c' 3 times, the letter 'e' 4 times, and each of the letters 'o', 'd', 'h' and 'f' once. Clearly, this is only enough for one "codechef" meal.
Example case 2: After mixing, the cauldron contains the letter 'c' 4 times, 'o' 2 times, 'd' 2 times, 'e' 4 times, 'h' 3 times and 'f' 2 times, which is enough to make 2 meals.

Difficulty: EASY

Solutions:
for _ in range(int(input())):
	n = int(input())
	soup = ''
	for _ in range(n):
		soup += input()
	print(min(soup.count('c') // 2, soup.count('e') // 2, soup.count('o'), soup.count('d'), soup.count('h'), soup.count('f')))


t = int(input())
for i in range(t):
	n = int(input())
	c = ''
	(a, b, d, e, f, g) = (0, 0, 0, 0, 0, 0)
	for j in range(n):
		s = input()
		c = c + s
	for k in c:
		if k == 'c':
			a += 1
		if k == 'o':
			b += 1
		if k == 'd':
			d += 1
		if k == 'e':
			e += 1
		if k == 'h':
			f += 1
		if k == 'f':
			g += 1
	a = int(a / 2)
	e = int(e / 2)
	print(min(a, b, d, e, f, g))


t = int(input())
for i in range(t):
	d = {'c': 0, 'o': 0, 'd': 0, 'e': 0, 'h': 0, 'f': 0}
	n = int(input())
	for k in range(n):
		s = input()
		for j in s:
			if j in d.keys():
				d[j] = d[j] + 1
	if d['c'] >= 2 and d['e'] >= 2:
		if d['o'] > 0 and d['d'] > 0 and (d['h'] > 0) and (d['f'] > 0):
			print(min(d['o'], d['d'], d['f'], d['h'], d['c'] // 2, d['e'] // 2))
		else:
			print(0)
	else:
		print(0)


for i in range(int(input())):
	n = int(input())
	l = ''
	for i in range(n):
		l = l + str(input())
	c = l.count('c')
	o = l.count('o')
	d = l.count('d')
	e = l.count('e')
	h = l.count('h')
	f = l.count('f')
	min1 = min(c, e)
	n1 = int(min1 / 2)
	min2 = min(o, d, h, f)
	if o >= n1 and d >= n1 and (h >= n1) and (f >= n1):
		print(n1)
	elif min2 <= n1:
		print(min(c, o, d, e, h, f))


t = int(input())
for i in range(t):
	n = int(input())
	x = ''
	lst = []
	for j in range(n):
		x += input()
	lst.append(x.count('c') // 2)
	lst.append(x.count('e') // 2)
	lst.append(x.count('d'))
	lst.append(x.count('o'))
	lst.append(x.count('h'))
	lst.append(x.count('f'))
	print(min(lst))


t = int(input())
for i in range(t):
	n = int(input())
	list1 = []
	for i in range(n):
		s = input()
		for i in range(len(s)):
			list1.append(s[i])
	t1 = 0
	t2 = 0
	t3 = 0
	t4 = 0
	t5 = 0
	t6 = 0
	t1 = list1.count('c') // 2
	t2 = list1.count('o') // 1
	t3 = list1.count('d') // 1
	t4 = list1.count('e') // 2
	t5 = list1.count('h') // 1
	t6 = list1.count('f') // 1
	print(min(t1, t2, t3, t4, t5, t6))


for i in range(int(input())):
	n = int(input())
	s = ''
	for j in range(n):
		s += input()
	d = {'c': 0, 'o': 0, 'd': 0, 'e': 0, 'h': 0, 'f': 0}
	for j in s:
		if j in d:
			d[j] += 1
	print(min(d['c'] // 2, d['o'], d['d'], d['e'] // 2, d['h'], d['f']))


t = int(input())
for _ in range(t):
	n = int(input())
	list1 = []
	l = []
	for i in range(n):
		x = input()
		list1.extend(list(x))
	for i in 'codehf':
		l.append(list1.count(i))
	l[0] = l[0] / 2
	l[3] = l[3] / 2
	print(int(min(l)))


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	d = defaultdict(int)
	for i in range(n):
		s = input()
		for k in s:
			if k in 'codechef':
				d[k] = d[k] + 1
	d['c'] = d['c'] // 2
	d['e'] = d['e'] // 2
	g = list(d.values())
	if len(g) == 6:
		print(min(g))
	else:
		print(0)


t = int(input())
for i in range(t):
	ingre = int(input())
	cauldron = []
	for j in range(ingre):
		arr = input()
		for ele in arr:
			if ele == 'c' or ele == 'o' or ele == 'd' or (ele == 'e') or (ele == 'h') or (ele == 'f'):
				cauldron.append(ele)
	if cauldron.count('c') >= 2 and cauldron.count('e') >= 2:
		if 'o' in cauldron and 'd' in cauldron and ('h' in cauldron) and ('f' in cauldron):
			print(min(cauldron.count('o'), cauldron.count('d'), cauldron.count('h'), cauldron.count('f'), cauldron.count('c') // 2, cauldron.count('e') // 2))
		else:
			print(0)
	else:
		print(0)


t = int(input())
for _ in range(t):
	l1 = []
	l2 = []
	c = 'codechef'
	n = int(input())
	for i in range(n):
		s = input()
		for j in s:
			l1.append(j)
	for i in c:
		if i == 'c' or i == 'e':
			l2.append(l1.count(i) // 2)
		else:
			l2.append(l1.count(i))
	print(min(l2))


for i in range(int(input())):
	a = int(input())
	b = list()
	count1 = 0
	l1 = list()
	for _ in range(a):
		b.append(input())
	b = ''.join(b)
	l = list(''.join(b))
	l1.append(l.count('c') // 2)
	l1.append(l.count('o'))
	l1.append(l.count('d'))
	l1.append(l.count('e') // 2)
	l1.append(l.count('h'))
	l1.append(l.count('f'))
	print(min(l1))


t = int(input())
while t:
	t -= 1
	n = int(input())
	d = {}
	l = ''
	for i in range(n):
		l = l + input()
	for i in l:
		if i in d.keys():
			d[i] += 1
		else:
			d[i] = 1
	d_meal = {'c': 2, 'o': 1, 'd': 1, 'e': 2, 'h': 1, 'f': 1}
	flag = True
	min_p = 10000000000
	for i in d_meal.keys():
		c = d.get(i, 0)
		min_p = min(min_p, c // d_meal[i])
	print(min_p)


t = int(input())
for bunny in range(t):
	n = int(input())
	s = ''
	for i in range(n):
		s += input()
	c = []
	for i in list('codechef'):
		c.append(s.count(i))
	c[0] /= 2
	c[3] /= 2
	print(int(min(c)))


for t in range(int(input())):
	S = ''
	n = int(input())
	for i in range(n):
		S += str(input())
	c1 = S.count('c')
	c2 = S.count('o')
	c3 = S.count('d')
	c4 = S.count('e')
	c5 = S.count('h')
	c6 = S.count('f')
	c = min(c1, c4)
	n = int(c / 2)
	k = min(c2, c3, c5, c6)
	if c2 >= n and c3 >= n and (c5 >= n) and (c6 >= n):
		print(n)
	elif k <= n:
		print(k)


for i in range(int(input())):
	n = int(input())
	d = {'c': 0, 'o': 0, 'd': 0, 'e': 0, 'h': 0, 'f': 0}
	for i in range(n):
		a = input()
		for i in a:
			if i in d:
				d[i] += 1
	l = []
	for i in d:
		if i == 'c' or i == 'e':
			l.append(d[i] // 2)
		else:
			l.append(d[i])
	print(min(l))


t = int(input())
for i in range(t):
	n = int(input())
	s = ''
	for i in range(n):
		s += input()
	aa = s.count('c') // 2
	bb = s.count('e') // 2
	cc = s.count('o')
	dd = s.count('d')
	ee = s.count('h')
	ff = s.count('f')
	print(min(aa, bb, cc, dd, ee, ff))


for _ in range(int(input())):
	x = int(input())
	l = []
	for i in range(x):
		l.append(input())
	a = ','.join(l)
	k = [a.count('c') // 2, a.count('o'), a.count('d'), a.count('e') // 2, a.count('f'), a.count('h')]
	print(min(k))


for x in range(int(input())):
	string = ''
	for y in range(int(input())):
		s = input()
		string += s
	l = []
	for x in 'codehf':
		l.append(string.count(x))
	l[0] //= 2
	l[3] //= 2
	print(min(l))


for _ in range(int(input())):
	N = int(input())
	s = ''
	for i in range(N):
		s += input()
	c = []
	for i in list('codehf'):
		c.append(s.count(i))
	c[0] /= 2
	c[3] /= 2
	print(int(min(c)))


for t in range(int(input())):
	n = int(input())
	c = 0
	e = 0
	d = 0
	o = 0
	h = 0
	f = 0
	for i in range(n):
		s = input()
		c = c + s.count('c')
		e = e + s.count('e')
		d += s.count('d')
		o += s.count('o')
		h += s.count('h')
		f += s.count('f')
	c = c // 2
	e = e // 2
	print(min(c, e, d, o, h, f))


for i in range(int(input())):
	n = int(input())
	s = ''
	for i in range(n):
		s += input()
	c = s.count('c')
	o = s.count('o')
	d = s.count('d')
	e = s.count('e')
	h = s.count('h')
	f = s.count('f')
	if c >= 2 and o >= 1 and (d >= 1) and (e >= 2) and (f >= 1) and (h >= 1):
		c = c // 2
		e = e // 2
		print(min(c, o, d, e, h, f))
	else:
		print(0)


t = int(input())
for i in range(t):
	n = int(input())
	b = []
	for j in range(n):
		sj = input()
		b.append(sj)
	stri = ''.join(b)
	l = [i for i in stri]
	c = [l.count('c') // 2, l.count('e') // 2, l.count('d'), l.count('o'), l.count('h'), l.count('f')]
	print(min(c))


T = int(input())
for _ in range(T):
	letters = {'c': 0, 'o': 0, 'd': 0, 'e': 0, 'h': 0, 'f': 0}
	N = int(input())
	for i in range(N):
		for letter in input():
			if letter in letters:
				letters[letter] += 1
	meals = float('inf')
	for (letter, value) in letters.items():
		if letter in ['c', 'e']:
			meals = min(meals, value // 2)
		else:
			meals = min(meals, value)
	print(meals)


for i in range(int(input())):
	a = int(input())
	s = ''
	l = []
	for i in range(a):
		s += input()
	l.append(s.count('c') // 2)
	l.append(s.count('o'))
	l.append(s.count('d'))
	l.append(s.count('e') // 2)
	l.append(s.count('f'))
	l.append(s.count('h'))
	print(min(l))


for i in range(int(input())):
	n = int(input())
	s = ''
	for i in range(n):
		s = s + input()
	b = []
	for j in 'codechef':
		if j == 'c' or j == 'e':
			b.append(s.count(j) // 2)
		else:
			b.append(s.count(j))
	print(min(b))


t = int(input())
for i in range(t):
	s = ''
	n = int(input())
	for i in range(n):
		k = input()
		s += k
	d = {'c': 0, 'o': 0, 'd': 0, 'e': 0, 'h': 0, 'f': 0}
	for i in s:
		if i in d:
			d[i] += 1
	m = min(d.values())
	b = d['c'] // 2
	c = d['e'] // 2
	print(min(m, c, b))


for i in range(int(input())):
	x = int(input())
	y = ''
	for _ in range(x):
		y += input()
	y = [y.count(l) for l in ['c', 'o', 'd', 'e', 'h', 'f']]
	y[0] //= 2
	y[3] //= 2
	print(min(y))


for vsvvs in range(int(input())):
	n = int(input())
	l = []
	countl = []
	m = ['c', 'o', 'd', 'e', 'c', 'h', 'e', 'f']
	for i in range(n):
		s = input()
		l.append(s)
	for i in range(len(m)):
		count = 0
		for string in l:
			for k in range(len(string)):
				if m[i] == string[k]:
					count += 1
		countl.append(count)
	count = 0
	flag = 0
	countl.pop(4)
	countl.pop(5)
	if 0 not in countl and countl[0] >= 2 and (countl[3] >= 2):
		while 0 not in countl and countl[0] >= 2 and (countl[3] >= 2):
			for i in range(len(countl)):
				if i == 0 or i == 3:
					countl[i] -= 2
				else:
					countl[i] -= 1
			count += 1
	print(count)


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	s1 = ''.join((input().strip() for _ in range(n)))
	count_dict = defaultdict(int)
	for char in s1:
		count_dict[char] += 1
	c = count_dict['c'] // 2
	e = count_dict['e'] // 2
	o = count_dict['o']
	d = count_dict['d']
	h = count_dict['h']
	f = count_dict['f']
	print(min(c, e, o, d, h, f))


for _ in range(int(input())):
	n = int(input())
	d = {'c': 0, 'o': 0, 'd': 0, 'e': 0, 'h': 0, 'f': 0}
	for i in range(n):
		s = input()
		for x in s:
			if x in 'codehf':
				d[x] += 1
	d['c'] //= 2
	d['e'] //= 2
	print(min(d.values()))


t = int(input())
for i in range(0, t):
	n = int(input())
	lst = []
	for j in range(0, n):
		stri = input()
		lst.append(list(stri))
	c = 0
	o = 0
	d = 0
	e = 0
	h = 0
	f = 0
	for i in lst:
		for j in i:
			if j == 'c':
				c += 1
			elif j == 'o':
				o += 1
			elif j == 'd':
				d += 1
			elif j == 'e':
				e += 1
			elif j == 'h':
				h += 1
			elif j == 'f':
				f += 1
	c = c / 2
	e = e / 2
	ans = min(c, o, d, e, h, f)
	print(int(ans))


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	um = defaultdict(int)
	for _ in range(n):
		s = input()
		for j in s:
			um[j] += 1
	print(min(um['c'] // 2, um['o'], um['d'], um['e'] // 2, um['h'], um['f']))


for i in range(int(input())):
	n = int(input())
	s = ''
	for j in range(n):
		s = s + input()
	l1 = s.count('c')
	l2 = s.count('o')
	l3 = s.count('d')
	l4 = s.count('e')
	l5 = s.count('h')
	l6 = s.count('f')
	if l1 >= 2 and l2 >= 1 and (l3 >= 1) and (l4 >= 2) and (l5 >= 1) and (l6 >= 1):
		print(min(l1 // 2, l2, l3, l4 // 2, l5, l6))
	else:
		print(0)


t = int(input())
while t > 0:
	p = int(input())
	s1 = ''
	while p > 0:
		s = input()
		s1 += s
		p -= 1
	c1 = 0
	c2 = 0
	c3 = 0
	c4 = 0
	c5 = 0
	c6 = 0
	for i in s1:
		if i == 'c':
			c1 += 1
		elif i == 'o':
			c2 += 1
		elif i == 'd':
			c3 += 1
		elif i == 'e':
			c4 += 1
		elif i == 'h':
			c5 += 1
		elif i == 'f':
			c6 += 1
	min1 = min(c1 // 2, c2, c3, c4 // 2, c5, c6)
	print(min1)
	t -= 1


for i in range(int(input())):
	p = ''
	for i in range(int(input())):
		s = input()
		p = p + s
	d = {'c': 0, 'd': 0, 'e': 0, 'f': 0, 'h': 0, 'o': 0}
	for i in p:
		if i in d:
			d[i] += 1
	d['c'] = d['c'] // 2
	d['e'] = d['e'] // 2
	print(min(d.values()))


for i in range(int(input())):
	n = int(input())
	s = ''
	for i in range(n):
		s = s + input()
	l = []
	for i in 'codechef':
		l.append(s.count(i))
	l[0] = l[0] // 2
	l[3] = l[3] // 2
	print(min(l))


for _ in range(int(input())):
	l = []
	for _ in range(int(input())):
		a = input()
		for i in a:
			if i in 'codechef':
				l.append(i)
	if l.count('c') >= 2 and l.count('e') >= 2:
		if 'o' in l and 'd' in l and ('h' in l) and ('f' in l):
			print(min(l.count('o'), l.count('d'), l.count('h'), l.count('f'), l.count('c') // 2, l.count('e') // 2))
		else:
			print(0)
	else:
		print(0)


for _ in range(int(input())):
	n = int(input())
	a = ''
	for i in range(n):
		s = input()
		a = a + s
	c = 0
	o = 0
	d = 0
	e = 0
	h = 0
	f = 0
	for i in a:
		if i == 'c':
			c += 1
		elif i == 'o':
			o += 1
		elif i == 'd':
			d += 1
		elif i == 'e':
			e += 1
		elif i == 'h':
			h += 1
		elif i == 'f':
			f += 1
	c = c // 2
	e = e // 2
	print(min(c, o, d, e, h, f))


for _ in range(int(input())):
	n = int(input())
	a = []
	d = [0] * 26
	for i in range(n):
		for k in input():
			d[ord(k) - ord('a')] += 1
	a.append(d[2] // 2)
	a.append(d[14])
	a.append(d[3])
	a.append(d[4] // 2)
	a.append(d[7])
	a.append(d[5])
	print(min(a))


t = int(input())
for i in range(t):
	n = int(input())
	l = []
	for k in range(n):
		s = input()
		l.append(s)
	s = ''.join(l)
	f = 'odhf'
	m = []
	for j in f:
		m.append(s.count(j))
	m.append(s.count('c') // 2)
	m.append(s.count('e') // 2)
	print(min(m))


t = int(input())
for _ in range(t):
	n = int(input())
	letters = []
	for i in range(n):
		letters += list(input())
	letters.sort()
	print(min(letters.count('c') // 2, letters.count('o'), letters.count('d'), letters.count('e') // 2, letters.count('f'), letters.count('h')))


for i in range(0, int(input())):
	n = int(input())
	l = []
	for j in range(n):
		a = list(input())
		l = l + a
	m = []
	m.append(l.count('c') // 2)
	m.append(l.count('o'))
	m.append(l.count('d'))
	m.append(l.count('e') // 2)
	m.append(l.count('c') - l.count('c') // 2)
	m.append(l.count('h'))
	m.append(l.count('e') - l.count('e') // 2)
	m.append(l.count('f'))
	print(min(m))


ss = int(input())
for i in range(ss):
	n = int(input())
	mixture = ''
	for j in range(n):
		mixture = mixture + input()
	meal = 'codechef'
	if mixture.count('c') >= 2 and mixture.count('e'):
		if 'o' in mixture and 'd' in mixture and ('h' in mixture) and ('f' in mixture):
			print(min(mixture.count('c') // 2, mixture.count('e') // 2, mixture.count('o'), mixture.count('d'), mixture.count('h'), mixture.count('f')))
		else:
			print(0)
	else:
		print(0)


t = int(input())
for i in range(t):
	n = int(input())
	v = {'c': 0, 'o': 0, 'd': 0, 'e': 0, 'f': 0, 'h': 0}
	for i in range(n):
		s = input()
		for i in s:
			if i in v:
				v[i] += 1
			else:
				continue
	for i in v:
		if i == 'c' or i == 'e':
			v[i] = v[i] // 2
	print(min(v.values()))


for i in range(int(input())):
	igt = int(input())
	cauldron = []
	for j in range(igt):
		arr = input()
		for element in arr:
			if element == 'c' or element == 'o' or element == 'd' or (element == 'e') or (element == 'h') or (element == 'f'):
				cauldron.append(element)
	if cauldron.count('c') >= 2 and cauldron.count('e') >= 2:
		if 'o' in cauldron and 'd' in cauldron and ('h' in cauldron) and ('f' in cauldron):
			print(min(cauldron.count('o'), cauldron.count('d'), cauldron.count('h'), cauldron.count('f'), cauldron.count('c') // 2, cauldron.count('e') // 2))
		else:
			print(0)
	else:
		print(0)


for i in range(int(input())):
	a = int(input())
	c = 0
	o = 0
	d = 0
	e = 0
	h = 0
	f = 0
	for j in range(a):
		l = list(map(str, input()))
		c = c + l.count('c')
		o = o + l.count('o')
		d = d + l.count('d')
		e = e + l.count('e')
		h = h + l.count('h')
		f = f + l.count('f')
	x = min(c, e)
	y = min(o, d, h, f)
	z = min(x // 2, y)
	print(z)


t = int(input())
for i in range(t):
	n = int(input())
	l = []
	for i in range(n):
		l.append(input())
	a = ','.join(l)
	k = [a.count('c') // 2, a.count('o'), a.count('d'), a.count('e') // 2, a.count('h'), a.count('f')]
	b = min(k)
	print(b)


ref = {'c': 2, 'o': 1, 'd': 1, 'e': 2, 'h': 1, 'f': 1}
for _ in range(int(input())):
	res = ''
	min = float('inf')
	for _ in range(int(input())):
		st = input()
		res = res + st
	for i in ref:
		cur = res.count(i) // ref[i]
		if cur < min:
			min = cur
	print(min)


for _ in range(int(input())):
	n = int(input())
	x = ''
	lst = []
	c = ['c', 'o', 'd', 'e', 'c', 'h', 'e', 'f']
	for __ in range(n):
		s = input()
		x = x + s
	for l in c:
		if l == 'c' or l == 'e':
			lst.append(x.count(l) // 2)
		else:
			lst.append(x.count(l))
	print(min(lst))


t = int(input())
while t > 0:
	n = int(input())
	li = []
	(c, o, d, e, h, f) = (0, 0, 0, 0, 0, 0)
	for i in range(0, n):
		s = input()
		for i in range(len(s)):
			if s[i] == 'c':
				c = c + 1
			elif s[i] == 'o':
				o = o + 1
			elif s[i] == 'd':
				d = d + 1
			elif s[i] == 'e':
				e = e + 1
			elif s[i] == 'h':
				h = h + 1
			elif s[i] == 'f':
				f = f + 1
	e = e // 2
	c = c // 2
	print(min(c, o, d, e, h, f))
	t -= 1


for _ in range(int(input())):
	s = ''
	for i in range(int(input())):
		s += input()
	counts = []
	counts.append(s.count('c') // 2)
	counts.append(s.count('e') // 2)
	counts.append(s.count('o'))
	counts.append(s.count('d'))
	counts.append(s.count('h'))
	counts.append(s.count('f'))
	print(min(counts))


t = int(input())
while t > 0:
	l = []
	ci = {}
	r = {'c': 2, 'o': 1, 'd': 1, 'e': 2, 'h': 1, 'f': 1}
	n = int(input())
	for i in range(0, n):
		temp = list(input())
		l += temp
	for i in r:
		ci[i] = l.count(i)
	count1 = 0
	c = 1
	while c == 1:
		if ci == r:
			count1 += 1
			break
		for i in r:
			temp = ci[i] - r[i]
			if temp >= 0:
				ci[i] -= r[i]
			else:
				c = 0
				break
		if c == 1:
			count1 += 1
	print(count1)
	t -= 1


for i in range(int(input())):
	n = int(input())
	l = []
	c = 0
	o = 0
	d = 0
	e = 0
	h = 0
	f = 0
	for i in range(n):
		s = input()
		for i in range(len(s)):
			if s[i] == 'c':
				c = c + 1
			elif s[i] == 'o':
				o = o + 1
			elif s[i] == 'd':
				d = d + 1
			elif s[i] == 'e':
				e = e + 1
			elif s[i] == 'h':
				h = h + 1
			elif s[i] == 'f':
				f = f + 1
	c = c // 2
	e = e // 2
	l = [c, o, d, e, h, f]
	print(min(l))


t = int(input())
for i in range(t):
	n = int(input())
	arr = []
	for i in range(n):
		string = input()
		str_arr = list(string)
		arr.extend(str_arr)
	ans_dict = {'c': 0, 'o': 0, 'd': 0, 'e': 0, 'h': 0, 'f': 0}
	for key in ans_dict.keys():
		ans_dict[key] = arr.count(key)
	if ans_dict['c'] > 1 and ans_dict['e'] > 1:
		if ans_dict['o'] > 0 and ans_dict['d'] > 0 and (ans_dict['h'] > 0) and (ans_dict['f'] > 0):
			print(min(ans_dict['o'], ans_dict['d'], ans_dict['h'], ans_dict['f'], ans_dict['c'] // 2, ans_dict['e'] // 2))
		else:
			print(0)
	else:
		print(0)


t = int(input())
for i in range(t):
	n = int(input())
	l = [0, 0, 0, 0, 0, 0]
	lst = []
	for j in range(n):
		s = input()
		lst.append(s)
	for k in lst:
		l[0] += k.count('c')
		l[1] += k.count('o')
		l[2] += k.count('d')
		l[3] += k.count('e')
		l[4] += k.count('h')
		l[5] += k.count('f')
	mnc = l[0] // 2
	mne = l[3] // 2
	l.append(mnc)
	l.append(mne)
	print(min(l))


for i in range(int(input())):
	string = ''
	for j in range(int(input())):
		string += input()
	c = string.count('c') // 2
	o = string.count('o')
	d = string.count('d')
	e = string.count('e') // 2
	h = string.count('h')
	f = string.count('f')
	print(min(c, o, d, e, h, f))


for i in range(int(input())):
	n = int(input())
	l = []
	for j in range(n):
		s = input()
		l.append(s)
	d = {'c': 0, 'o': 0, 'd': 0, 'h': 0, 'f': 0, 'e': 0}
	for i in range(0, len(l)):
		for j in range(0, len(l[i])):
			if l[i][j] in d:
				d[l[i][j]] += 1
	l.clear()
	for k in d:
		l.append(d[k])
	l[0] = l[0] // 2
	l[-1] = l[-1] // 2
	print(min(l))


t = int(input())
for _ in range(t):
	n = int(input())
	d = {'c': 0, 'o': 0, 'd': 0, 'e': 0, 'h': 0, 'f': 0}
	for z in range(n):
		s = input()
		for i in range(len(s)):
			if s[i] in d:
				d[s[i]] += 1
	l = []
	for x in d:
		if x == 'c' or x == 'e':
			l.append(d[x] // 2)
		else:
			l.append(d[x])
	print(min(l))


t = int(input())
while t > 0:
	n = int(input())
	s = ''
	while n > 0:
		s += input()
		n -= 1
	c = s.count('c')
	c = c // 2
	o = s.count('o')
	d = s.count('d')
	e = s.count('e')
	e = e // 2
	h = s.count('h')
	f = s.count('f')
	m = min(c, o, d, e, h, f)
	print(m)
	t -= 1


T = int(input())
for i in range(T):
	n = int(input())
	arr = ''
	for j in range(n):
		arr += input()
	c = arr.count('c') // 2
	o = arr.count('o')
	d = arr.count('d')
	e = arr.count('e') // 2
	h = arr.count('h')
	f = arr.count('f')
	print(min(c, o, d, e, h, f))


for _ in range(int(input())):
	n = int(input())
	ll = []
	for _ in range(n):
		ll.append(input())
	d1 = {}
	for i in range(n):
		for j in ll[i]:
			if j not in d1:
				d1[j] = 1
			else:
				d1[j] += 1
	if 'c' in d1 and 'o' in d1 and ('d' in d1) and ('e' in d1) and ('h' in d1) and ('f' in d1):
		print(min(d1['c'] // 2, d1['o'], d1['d'], d1['e'] // 2, d1['h'], d1['f']))
	else:
		print(0)


def countOfCompleteMeals(Sp):
	(cc, co, cd, ce, ch, cf) = (0, 0, 0, 0, 0, 0)
	for ingredient in Sp:
		for c in ingredient:
			if c == 'c':
				cc += 1
			elif c == 'o':
				co += 1
			elif c == 'd':
				cd += 1
			elif c == 'e':
				ce += 1
			elif c == 'h':
				ch += 1
			elif c == 'f':
				cf += 1
	if cc > 1 and co > 0 and (cd > 0) and (ce > 1) and (ch > 0) and (cf > 0):
		count = [cc // 2, co, cd, ce // 2, ch, cf]
		return min(count)
	else:
		return 0
Trp = int(input())
while Trp:
	Trp -= 1
	N = int(input())
	Sp = []
	for i in range(N):
		Sp.append(input())
	print(countOfCompleteMeals(Sp))


for i in range(int(input())):
	n = int(input())
	s1 = str()
	for i in range(n):
		s = str(input())
		s1 += s
	l = list(s1.strip())
	ln = []
	ln.append(l.count('c') // 2)
	ln.append(l.count('e') // 2)
	ln.append(l.count('o'))
	ln.append(l.count('d'))
	ln.append(l.count('h'))
	ln.append(l.count('f'))
	print(min(ln))


from collections import Counter
for i in range(int(input())):
	n = int(input())
	bowl = ''
	for j in range(n):
		s = input()
		bowl += s
	a = Counter(bowl)
	lst = []
	lst.append(a['c'] // 2)
	lst.append(a['o'])
	lst.append(a['d'])
	lst.append(a['e'] // 2)
	lst.append(a['c'])
	lst.append(a['h'])
	lst.append(a['e'])
	lst.append(a['f'])
	print(min(lst))


n = int(input())
for i in range(n):
	n1 = int(input())
	(c, o, d, e, h, f) = (0, 0, 0, 0, 0, 0)
	for j in range(n1):
		s = input()
		for k in range(len(s)):
			if s[k] == 'c':
				c += 1
			elif s[k] == 'o':
				o += 1
			elif s[k] == 'd':
				d += 1
			elif s[k] == 'e':
				e += 1
			elif s[k] == 'h':
				h += 1
			elif s[k] == 'f':
				f += 1
	c /= 2
	e /= 2
	print(int(min(c, o, d, e, h, f)))


for _ in range(int(input())):
	n = int(input())
	l = []
	for i in range(n):
		s = input()
		a = list(s)
		l = l + a
	m = ['o', 'd', 'h', 'f']
	n = []
	x = l.count('c')
	n.append(x // 2)
	y = l.count('e')
	n.append(y // 2)
	for j in range(4):
		a = l.count(m[j])
		n.append(a)
	print(min(n))


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	p = ''
	for i in range(n):
		s = input()
		p += s
	d = {'c': 0, 'd': 0, 'e': 0, 'f': 0, 'h': 0, 'o': 0}
	for i in p:
		if i in d:
			d[i] += 1
	d['c'] = d['c'] // 2
	d['e'] = d['e'] // 2
	print(min(d.values()))