#include <bits/stdc++.h>
using namespace std;
int min(int a, int b) { return a <= b ? a : b; }
int max(int a, int b) { return a >= b ? a : b; }
int up[100000 * 2], down[100000 * 2], upnum, downnum;
int upend[100000 * 2], downend[100000 * 2];
bool uphit[100000 * 2], downhit[100000 * 2];
double hl, hr;
int num;
int exist(double x, bool loc) {
  int t = (int)x;
  if (loc) {
    if (up[t] == -1) return -1;
    if (x <= (double)upend[t]) {
      if (uphit[upend[t]]) return -1;
      uphit[upend[t]] = true;
      return up[t];
    }
    return -1;
  } else {
    if (down[t] == -1) return -1;
    if (x <= (double)downend[t]) {
      if (downhit[downend[t]]) return -1;
      downhit[downend[t]] = true;
      return down[t];
    }
    return -1;
  }
}
int getscore(double len, int loc) {
  int ans = 0;
  double start;
  if (loc == 0)
    start = hl * len / (1.0 * 100);
  else
    start = (100 - hl) * len / (1.0 * 100);
  for (double i = start; i <= 100000; i += len) {
    int tans = exist(i, loc);
    if (tans == -1) return -1;
    ans += tans;
    loc = 1 - loc;
  }
  return ans;
}
int main() {
  while (scanf("%lf %lf %d", &hl, &hr, &num) != EOF) {
    memset(up, -1, sizeof(up));
    memset(down, -1, sizeof(down));
    memset(uphit, false, sizeof(uphit));
    memset(downhit, false, sizeof(downhit));
    upnum = downnum = 0;
    for (int i = 0; i < num; i++) {
      int score, l, r;
      char loc;
      scanf("%d %c %d %d", &score, &loc, &l, &r);
      if (loc == 'T') {
        upnum++;
        for (int i = l; i <= r; i++) {
          up[i] = score;
          upend[i] = r;
        }
      } else {
        downnum++;
        for (int i = l; i <= r; i++) {
          down[i] = score;
          downend[i] = r;
        }
      }
    }
    int ans = -1;
    int maxnum = min(upnum, downnum) + 10;
    for (int i = 0; i <= maxnum; i++) {
      double rad = 100000 / ((hr + hl) / (2.0 * 100) + 1.0 * i) / 2;
      memset(uphit, false, sizeof(uphit));
      memset(downhit, false, sizeof(downhit));
      int temp = getscore(rad, 0);
      if (temp > ans) ans = temp;
    }
    for (int i = 0; i <= maxnum; i++) {
      double rad =
          100000 / (((100 - hr) + hl) / (2.0 * 100) + 1.0 * i + 0.5) / 2;
      memset(uphit, false, sizeof(uphit));
      memset(downhit, false, sizeof(downhit));
      int temp = getscore(rad, 0);
      if (temp > ans) ans = temp;
    }
    for (int i = 0; i <= maxnum; i++) {
      double rad =
          100000 / ((2.0 * 100 - (hr + hl)) / (2.0 * 100) + 1.0 * i) / 2;
      memset(uphit, false, sizeof(uphit));
      memset(downhit, false, sizeof(downhit));
      int temp = getscore(rad, 1);
      if (temp > ans) ans = temp;
    }
    for (int i = 0; i <= maxnum; i++) {
      double rad =
          100000 / (((100 - hl) + hr) / (2.0 * 100) + 1.0 * i + 0.5) / 2;
      memset(uphit, false, sizeof(uphit));
      memset(downhit, false, sizeof(downhit));
      int temp = getscore(rad, 1);
      if (temp > ans) ans = temp;
    }
    if (ans == -1)
      cout << 0 << endl;
    else
      cout << ans << endl;
  }
  return 0;
}
