def codechef_8():
    testcase=int(raw_input())
    while(testcase):
        user_info=raw_input().strip().split(" ")
        user=int(user_info[0])
        laddus=0
        if(user_info[1]=='INDIAN'):
            redeem=200
        else:
            redeem=400
        while(user):
            induser=raw_input().strip().split(" ")
            action=induser[0]
            if(action=="CONTEST_WON"):
                if(int(induser[1])<20):
                    extra=20-int(induser[1])
                else:
                    extra=0
                laddus=300+laddus+extra
            elif(action=="TOP_CONTRIBUTOR"):
                laddus=laddus+300
            elif(action=="BUG_FOUND"):
                laddus=laddus+int(induser[1])
            elif(action=="CONTEST_HOSTED"):
                laddus=laddus+50
            user=user-1
        print laddus/redeem
        testcase=testcase-1
codechef_8()