testCases = int(raw_input(""))

answers = []

for j in range(0,testCases):
    actOrigin = raw_input("").split(" ")
    isIndian = True if actOrigin[1].startswith("INDIAN") else False

    activities = []
    for i in range(0,int(actOrigin[0])):
        activities.append(raw_input(""))


    total = 0
    for activity in activities:
        if activity.startswith("CONTEST_WON"):
            place = int(activity.split(" ")[1])
            total = total + (20 - min(place , 20)) + 300
        if activity.startswith("TOP_CONTRIBUTOR"):
            total = total + 300
        if activity.startswith("BUG_FOUND"):
            sever = int(activity.split(" ")[1])
            total = total + sever
        if activity.startswith("CONTEST_HOSTED"):
            total = total + 50

    #print(total)
    divider = 200 if isIndian else 400
    answers.append(total/divider)

for answer in answers:
    print(answer)

'''
2
4 INDIAN
CONTEST_WON 1
TOP_CONTRIBUTOR
BUG_FOUND 100
CONTEST_HOSTED
5 NON_INDIAN
CONTEST_WON 1
CONTEST_WON 1
TOP_CONTRIBUTOR
BUG_FOUND 100
CONTEST_HOSTED


'''