import math

def find(d):
    if(d[0]=='CONTEST_WON'):
        if(int(d[1])<20):
            sum = 320 - int(d[1])
        else:
            sum = 300
    if(d[0]=='TOP_CONTRIBUTOR'):
        sum = 300
    if(d[0]=='BUG_FOUND'):
        if(int(d[1])>=50 and int(d[1])<=1000):
            sum = int(d[1])
    if(d[0]=='CONTEST_HOSTED'):
        sum = 50
    return sum

    

t= input()
while(t!=0):
    n,nat = raw_input().split()
    n = int(n)
    sum = 0
    while(n!=0):
        d = raw_input().split()
        sum = sum + find(d);
        n -= 1

    if(nat=='INDIAN'):
        ans = int(sum/200)
    if(nat=='NON_INDIAN'):
        ans = int(sum/400)

    print ans
    t -= 1