case = int(raw_input())
for i in range(case):
    points = 0
    base = 1
    activities, origin = raw_input().strip().split()
    for j in range(int(activities)):
        data = raw_input().strip().split()
        if data[0] == 'CONTEST_WON':
            points += 300 + max(0, 20-int(data[1]))
        elif data[0] == 'TOP_CONTRIBUTOR':
            points += 300
        elif data[0] == 'BUG_FOUND':
            points += int(data[1])
        elif data[0] == 'CONTEST_HOSTED':
            points += 50
    if origin == 'INDIAN':
        base = 200
    else:
        base = 400
    print points / base