t = input()

for i in range(t):
    s = raw_input().split(' ')
    n = int(s[0])
    indian = (s[1] == "INDIAN")
    total = 0
    for j in range(n):
        s = raw_input().split(' ')
        if s[0] == "CONTEST_WON":
            total += 300
            if int(s[1]) < 20:
                total += (20 - int(s[1]))
        elif s[0] == "TOP_CONTRIBUTOR":
            total += 300
        elif s[0] == "BUG_FOUND":
            total += int(s[1])
        elif s[0] == "CONTEST_HOSTED":
            total += 50
    if indian:
        print total / 200
    else:
        print total / 400