#include <bits/stdc++.h>
using namespace std;
const double inf = 1e-8;
struct Node {
  int score, x, y;
  int T;
  Node() {}
  Node(int a, int b, int c, char s) {
    score = a;
    x = b;
    y = c;
    T = (s == 'T');
  }
} mirr[110];
int n, hl, hr, jj;
int up[100010], down[100010];
void init() {
  memset(up, -1, sizeof(up));
  memset(down, -1, sizeof(down));
  int i = 0;
  while (mirr[i].T == 0) {
    for (int j = mirr[i].x; j <= mirr[i].y; j++) down[j] = i;
    i++;
  }
  while (i < n) {
    for (int j = mirr[i].x; j <= mirr[i].y; j++) up[j] = i;
    i++;
  }
}
bool cmp(Node a, Node b) {
  if (a.T == b.T) return a.x < b.x;
  return a.T < b.T;
}
bool inside(Node a, double x) {
  if (a.x - inf <= x && a.y + inf >= x) return 1;
  return 0;
}
int vis[110];
void cal(int hl, int hr, int n, double &x, double &y, double &z) {
  z = 10000000.0 / (hl + hr + 100.0 * n);
  x = z * hl / 100;
  y = z * hr / 100;
}
int check(double dx, double dz, double ux, double uz, int num, int a, int b) {
  int temp, ans, i, j, k;
  double x = dx;
  temp = ans = 0;
  memset(vis, 0, sizeof(vis));
  for (i = a; i <= num && temp != -1; i += 2, x += 2 * dz) {
    j = 0;
    k = 0;
    while (j < jj && temp != -1) {
      if (inside(mirr[j], x)) {
        vis[j]++;
        temp += mirr[j].score;
        k = 1;
        if (vis[j] > 1) {
          temp = -1;
        }
      }
      j++;
    }
    if (k == 0) temp = -1;
  }
  if (temp != -1) {
    x = ux;
    for (i = b; i <= num && temp != -1; i += 2, x += 2 * uz) {
      j = jj;
      k = 0;
      while (j < n && temp != -1) {
        if (inside(mirr[j], x)) {
          vis[j]++;
          temp += mirr[j].score;
          k = 1;
          if (vis[j] > 1) temp = -1;
        }
        j++;
      }
      if (k == 0) temp = -1;
    }
  }
  return temp;
}
int find(int num) {
  double xx, yy, zz, x, y;
  int i, j, k;
  int temp, ans;
  if (num == 1) {
    temp = -1;
    memset(vis, 0, sizeof(vis));
    xx = 100000.0 * hl / (hr + hl + 0.0);
    yy = 100000.0 * hr / (hr + hl + 0.0);
    i = 0;
    k = 0;
    while (mirr[i].T == 0) {
      if (inside(mirr[i], xx)) {
        temp = mirr[i].score;
        k = 1;
      }
      i++;
    }
    xx = 100000.0 * (100 - hl) / (200.0 - hr - hl);
    while (i < n) {
      if (inside(mirr[i], xx) && mirr[i].score > temp) temp = mirr[i].score;
      i++;
    }
    return temp;
  } else {
    ans = temp = -1;
    if (num % 2 == 0) {
      cal(hl, 100 - hr, num - 1, xx, yy, zz);
      temp = check(xx, zz, xx + zz, zz, num, 1, 2);
      if (temp > ans) ans = temp;
      cal(100 - hl, hr, num - 1, xx, yy, zz);
      temp = check(xx + zz, zz, xx, zz, num, 2, 1);
      if (temp > ans) ans = temp;
    } else {
      cal(hl, hr, num - 1, xx, yy, zz);
      temp = check(xx, zz, xx + zz, zz, num, 1, 2);
      if (temp > ans) ans = temp;
      cal(100 - hl, 100 - hr, num - 1, xx, yy, zz);
      temp = check(xx + zz, zz, xx, zz, num, 2, 1);
      if (temp > ans) ans = temp;
    }
  }
  return ans;
}
int main() {
  int scor, x, y, ans, temp;
  char c;
  while (scanf("%d%d%d", &hl, &hr, &n) == 3) {
    for (int i = 0; i < n; i++) {
      scanf("%d %c%d%d", &scor, &c, &x, &y);
      mirr[i] = Node(scor, x, y, c);
    }
    sort(mirr, mirr + n, cmp);
    jj = 0;
    while (mirr[jj].T == 0) jj++;
    ans = -1;
    for (int i = 1; i <= n; i++) {
      temp = find(i);
      if (temp > ans) ans = temp;
    }
    if (ans == -1) ans = 0;
    printf("%d\n", ans);
  }
}
