T=int(raw_input())
while T>0:
    T-=1    
    no_activities, origin = map(str, raw_input().split())
    no_activities=int(no_activities)
    activity_list=[]
    while no_activities>0:
        no_activities-=1
        activity_list.append([i for i in raw_input().split()])
    total_laddus=0
    index=0
    for activity in activity_list:
        if activity_list[index][0]=='CONTEST_WON':
            total_laddus+=300
            rank=int(activity_list[index][1])
            if rank<=20:
                bonus=20-rank
                total_laddus+=bonus
        elif activity_list[index][0]=='TOP_CONTRIBUTOR':
            total_laddus+=300
        elif activity_list[index][0]=='BUG_FOUND':
            severity=int(activity_list[index][1])
            total_laddus+=severity
        elif activity_list[index][0]=='CONTEST_HOSTED':
            total_laddus+=50
        index+=1
    if origin=='INDIAN':
        months=total_laddus/200
    elif origin=='NON_INDIAN':
        months=total_laddus/400
    print months