for t in xrange(int(raw_input())):
  n_origin = raw_input().split()
  n, origin = int(n_origin[0]), n_origin[1]
  tot_laddus = 0
  for i in xrange(n):
    a = raw_input().split()
    if a[0] == 'CONTEST_WON':
      tot_laddus += 300
      if int(a[1]) < 20:
        tot_laddus += 20 - int(a[1])
    elif a[0] == 'TOP_CONTRIBUTOR':
      tot_laddus += 300
    elif a[0] == 'BUG_FOUND':
      tot_laddus += int(a[1])
    elif a[0] == 'CONTEST_HOSTED':
      tot_laddus += 50
  if origin == 'INDIAN':
    print tot_laddus / 200
  else:
    print tot_laddus / 400