def main():
    for t in xrange(int(raw_input())):
        activity, nationality = raw_input().split()
        laddu = 0
        for x in xrange(int(activity)):
        	a = raw_input().split()

        	if a[0] == "CONTEST_WON":
        		if int(a[1]) < 20:
        			bonus = 20 - int(a[1])
        		else:
	        		bonus = 0 
        		laddu += 300 + bonus
        	elif a[0] == "TOP_CONTRIBUTOR":
        		laddu += 300
        	elif a[0] == "BUG_FOUND":
        		laddu += int(a[1])
        	elif a[0] == "CONTEST_HOSTED":
        		laddu += 50

        if nationality == "INDIAN":
        	print laddu/200
        	# result.append(laddu/200)
        else:
        	print laddu/400
        	# result.append(laddu/400)

	# print result
############################################################
 
if __name__ == '__main__':
    main()