#include <bits/stdc++.h>
using namespace std;
int n, m, k, x;
int bot[100001];
int top[100001];
int mir[101];
int hr, hl;
int uuh, bbh, ubh, buh;
int L = 100000;
double eps = 0.00001;
int mxr;
int sco(int s, bool up) {
  int res = 0;
  int dh = ((s % 2) ? (up ? uuh : bbh) : (up ? ubh : buh));
  double f = ((double)(up ? (100 - hl) : hl)) * L / (100 * (s - 1) + dh);
  double T = ((double)L * 100) / (100 * (s - 1) + dh);
  int l1 = 0, l2 = 0, l3 = 0;
  int* u = (up ? top : bot);
  for (int i = 0; i < s; ++i) {
    if ((f - floor(f)) > eps) {
      l3 = u[(int)floor(f)];
    } else {
      l3 = max(u[(int)floor(f) - 1], u[(int)floor(f)]);
    }
    if ((l3 == l1) || (l3 == 0)) {
      return 0;
    }
    l1 = l2;
    l2 = l3;
    res += mir[l3];
    u = (u == top ? bot : top);
    f += T;
  }
  return res;
}
int main(int argc, char** argv) {
  cin >> hl >> hr >> n;
  uuh = 200 - hl - hr;
  bbh = hr + hl;
  ubh = 100 + hr - hl;
  buh = 100 + hl - hr;
  int v, a, b;
  char c;
  for (int i = 1; i <= n; ++i) {
    cin >> v >> c >> a >> b;
    mir[i] = v;
    if (c == 'T') {
      for (int j = a; j < b; ++j) {
        top[j] = i;
      }
    } else {
      for (int j = a; j < b; ++j) {
        bot[j] = i;
      }
    }
  }
  double T;
  int mxr = 0;
  for (k = 1; k <= n; ++k) {
    int res = sco(k, true);
    if (res > mxr) {
      mxr = res;
    }
    res = sco(k, false);
    if (res > mxr) {
      mxr = res;
    }
  }
  cout << mxr;
  return 0;
}
