test = int(raw_input().strip())
while(test):
	test-=1
	n,nation = raw_input().strip().split()
	ans=0
	n=int(n)
	for i in range(n):
		l = raw_input().strip().split()
		if(l[0]=='CONTEST_WON'):
			ans+=300
			if(int(l[1])<20):
				ans+=20-int(l[1])
		elif(l[0]=='TOP_CONTRIBUTOR'):
			ans+=300
		elif(l[0]=='BUG_FOUND'):
			ans+=int(l[1])
		elif(l[0]=='CONTEST_HOSTED'):
			ans+=50
	if(nation=='INDIAN'):
		print ans/200
	else:
		print ans/400