for t in xrange(int(raw_input())):
	activities, nationality = raw_input().split()
	laddu = 0
	for i in range(int(activities)):
		activity = raw_input()
		if (activity.startswith("CONTEST_WON")):
			laddu += 300
			rank = int(activity.split()[1])
			if (rank <= 20):
				bonus = 20 - rank
				laddu += bonus
		elif (activity.startswith("TOP_CONTRIBUTOR")):
			laddu += 300
		elif (activity.startswith("BUG_FOUND")):
			severity = int(activity.split()[1])
			laddu += severity
		elif (activity.startswith("CONTEST_HOSTED")):
			laddu += 50
	if (nationality == "INDIAN"):
		answer =  laddu/200
	else:
		answer =  laddu/400
	print answer