for _ in xrange(input()):
    s=raw_input().split()
    n=int(s[0])
    sum=0
    for i in xrange(n):
        z=raw_input()
        if "CONTEST_WON" in z:
            z=int(z.split()[1])
            if z<=20:
                sum+=300+20-z
            else:
                sum+=300
        elif "TOP_CONTRIBUTOR" in z:
            sum+=300
        elif "BUG_FOUND" in z:
            z=int(z.split()[1])
            sum+=z
        elif "CONTEST_HOSTED" in z:
            sum+=50
            
    if s[1]=="INDIAN":
        print sum/200
    else:
        print sum/400