out=[]
T=int(raw_input())
while T:
	l=0
	n,o=raw_input().split()
	n=int(n)
	while n:
		t=raw_input().split()
		if t[0] == "CONTEST_WON":
			r=int(t[1])
			l += 20-r+300 if r<20 else 300
		elif t[0] == "TOP_CONTRIBUTOR":
			l+=300
		elif t[0] == "BUG_FOUND":
			l += int(t[1])
		elif t[0] == "CONTEST_HOSTED":
			l +=50
		n-=1
	out.append(l/200 if o=="INDIAN" else l/400)
	T-=1
	
for i in out:
	print i