t=int(raw_input())
for i in range(0,t):
	l1=map(str,raw_input().split())
	n=int(l1[0])
	count=0
	for j in range(0,n): 
		q=raw_input()
		if 'CONTEST_WON' in q:
			q1=q.split()
			rank=int(q1[1])
			if rank<=20:
				count += 300+20-int(q1[1])
			else:
				count+=300
		elif 'TOP_CONTRIBUTOR' in q:
			count+=300
		elif 'BUG_FOUND' in q:
			q1=q.split()
			count += int(q1[1])
		elif 'CONTEST_HOSTED' in q:
			count+=50
	if l1[1]=='INDIAN':
		print count/200
	else:
		print count/400