#laddus
t=input()
for i in range(t):
 t,loca=raw_input().split()
 l=[]
 for j in range(int(t)):
  l=l+raw_input().split()
  
 count=0
 for c in range(len(l)):
  if l[c]=="CONTEST_WON":
   if int(l[c+1])<20:
     count=count+300+(20-int(l[c+1]))
   else:
     count=count+300
  elif l[c]=="TOP_CONTRIBUTOR":
   count=count+300
  elif l[c]=="BUG_FOUND":
   count=count+int(l[c+1])
  elif l[c]=="CONTEST_HOSTED":
   count=count+50
  
 if loca=="INDIAN":
   print count/200
 else:
   print count/400