def	calculate_laddus(activity):
	if activity[0] == 'TOP_CONTRIBUTOR':
		return 300
	if activity[0] == 'CONTEST_HOSTED':
		return 50
	if activity[0] == 'CONTEST_WON':
		rank = int(activity[1])
		if rank <= 20:  		
			bonus = 20 - rank
		else:
			bonus = 0
		return 300 + bonus
	if activity[0] == 'BUG_FOUND':
		return int(activity[1])
			
		
cases = int(raw_input())
for i in range(cases):
	s = raw_input().split(' ')
	nationality = s[1]
	laddus = 0
	for j in range(int(s[0])):
		s = raw_input().split(' ')
		laddus += calculate_laddus(s)
	if nationality == 'INDIAN':
		print laddus/200
	else:
		print laddus/400