#include <bits/stdc++.h>
using namespace std;
vector<pair<double, int> > B[2];
const double yy = 100000 - 0.000001;
int hl, hr, n;
int debug;
int getscore(int ud, double pos, double t) {
  int ret = 0, flag, cnt;
  {
    vector<pair<double, int> > tmp = B[ud];
    for (double tp = pos; tp < yy; tp += t + t) {
      tmp.push_back(make_pair(tp, 0));
    }
    sort(tmp.begin(), tmp.end());
    if (debug) {
      for (int i = 0; i < (int)(tmp.size()); i++)
        cout << tmp[i].first << " " << tmp[i].second << endl;
    }
    flag = 0;
    cnt = 0;
    for (int i = 0; i < (int)(tmp.size()); i++) {
      if (tmp[i].second == 0 && flag == 0) return 0;
      if (tmp[i].second < 0) {
        flag = 1;
        cnt = 0;
      } else if (tmp[i].second > 0)
        flag = 0;
      else {
        if (cnt) return 0;
        ret += -tmp[i - 1].second;
        cnt++;
      }
    }
  }
  {
    vector<pair<double, int> > tmp = B[!ud];
    for (double tp = pos + t; tp < yy; tp += t + t) {
      tmp.push_back(make_pair(tp, 0));
    }
    sort(tmp.begin(), tmp.end());
    if (debug) {
      cout << ud << endl;
      for (int i = 0; i < (int)(tmp.size()); i++)
        cout << tmp[i].first << " " << tmp[i].second << endl;
    }
    flag = 0;
    cnt = 0;
    for (int i = 0; i < (int)(tmp.size()); i++) {
      if (tmp[i].second == 0 && flag == 0) return 0;
      if (tmp[i].second < 0) {
        flag = 1;
        cnt = 0;
      } else if (tmp[i].second > 0)
        flag = 0;
      else {
        if (cnt) return 0;
        ret += -tmp[i - 1].second;
        cnt++;
      }
    }
  }
  return ret;
}
int main(int argc, char *argv[]) {
  scanf("%d%d%d", &hl, &hr, &n);
  for (int i = 0; i < (int)(n); i++) {
    int s, lt, rt;
    char st[11];
    scanf("%d%s%d%d", &s, st, &lt, &rt);
    B[st[0] == 'T'].push_back(make_pair(lt - 0.00001, -s));
    B[st[0] == 'T'].push_back(make_pair(rt + 0.00001, s));
  }
  int best = 0;
  for (int k = 0; 2 * k + 2 < n; k++) {
    double t, chu = 0;
    chu = (100.0 - hl + hr) / 100.0 + 2 * k + 1;
    t = 100000 / chu;
    best = max(best, getscore(1, (100.0 - hl) / 100.0 * t, t));
    chu = (100.0 - hr + hl) / 100.0 + 2 * k + 1;
    t = 100000 / chu;
    best = max(best, getscore(0, hl / 100.0 * t, t));
    chu = (200.0 - hr - hl) / 100.0 + 2 * k;
    t = 100000 / chu;
    best = max(best, getscore(1, (100.0 - hl) / 100.0 * t, t));
    chu = (hr + hl) / 100.0 + 2 * k;
    t = 100000 / chu;
    best = max(best, getscore(0, hl / 100.0 * t, t));
    debug = 0;
  }
  cout << best << endl;
  return EXIT_SUCCESS;
}
