T=input()
for i in range(T):
    a,o=raw_input().split(" ")
    a=int(a)
    act=[]
    for j in range(a):
        act.append(raw_input().split(" "))
    laddus=0
    for a in  act:
        if "CONTEST_WON" in a:
            rank=int(a[1])
            if rank>20:
                laddus+=300
            else:
                laddus+=300+20-rank
        elif "TOP_CONTRIBUTOR" in a:
            laddus+=300
        elif "BUG_FOUND" in a:
            laddus+=int(a[1])
        else:
            laddus+=50
    if o=="INDIAN":
        print laddus/200
    else:
        print laddus/400