#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAXV 361
#define MAXT 361

struct move
{
  unsigned a, b;
};

struct move gote[MAXT];
unsigned ngote;
unsigned starts[MAXV + 2];

void play_size (int alices_turn, struct move *r, unsigned size)
{
  int n = starts[size + 1] - starts[size], m, i;

  if (!n)
    return;

  if (alices_turn)
    /* Alice gets moves 0, ..., (n - 1) / 2, Bob gets (n + 1) / 2, ..., n - 1.  */
    m = (n - 1) / 2;
  else
    /* Alice gets moves 0, ..., n/2 - 1, Bob gets n/2, ..., n - 1.  */
    m = n / 2 - 1;

  for (i = 0; i <= m; i++)
    r->a += gote[starts[size] + i].a;
  for (i = m + 1; i < n; i++)
    r->b += gote[starts[size] + i].b;
}

struct move play (int alices_turn)
{
  struct move rslt = {0,0};
  unsigned i;

  for (i = MAXV; i != 0; i--)
    {
      play_size (alices_turn, &rslt, i);
      if ((starts[i+1] - starts[i]) & 1)
	alices_turn = !alices_turn;
    }

  return rslt;
}

/* positive if M1 is a better move for Bob than M2.  */

int better_move (const void *m1, const void *m2)
{
  const struct move *mm1 = (move*)m1;
  const struct move *mm2 = (move*)m2;
  unsigned size1 = mm1->a + mm1->b;
  unsigned size2 = mm2->a + mm2->b;

  if (size1 != size2)
    return size1 - size2;

  return mm1->b - mm2->b;
}

int better_score (struct move s1, struct move s2)
{
  int diff1 = s1.a - s1.b;
  int diff2 = s2.a - s2.b;

  if (diff1 > diff2)
    return 1;
  if (diff1 < diff2)
    return 0;

  return s1.a > s2.a;
}

int main(void)
{
  unsigned n, i;
  char as[3], bs[3];
  struct move pa, best_rev_sente, act;
  struct move asente, bsente;

  while (1)
    {
      if (scanf ("%u%u%u", &pa.a, &pa.b, &n) != 3)
	return 0;

      best_rev_sente.a = best_rev_sente.b = 0;
      ngote = 0;

      for (i = 0; i < n; i++)
	{
	  scanf ("%u%u%s%s", &act.a, &act.b, as, bs);
	  if (!act.a && !act.b)
	    continue;

	  if (*as == 'S')
	    {
	      /* Alice gets all sente moves.  */
	      pa.a += act.a;
	    }
	  else if (*bs == 'S')
	    {
	      /* Bob gets all reverse sente moves,
		 except possibly for the largest one.  */
	      pa.b += act.b;
	      if (better_move (&act, &best_rev_sente) > 0)
		best_rev_sente = act;
	    }
	  else
	    {
	      gote[ngote] = act;
	      ngote++;
	    }
	}

      qsort (gote, ngote, sizeof (struct move), better_move);
      memset (starts, 0, sizeof (starts));

      for (i = 0; i < ngote; i++)
	starts[gote[i].a + gote[i].b + 1]++;
      for (i = 1; i <= MAXV + 1; i++)
	starts[i] += starts[i - 1];
      if (starts[MAXV + 1] != ngote)
	abort ();

      /* We don't know who gets this move.  */
      pa.b -= best_rev_sente.b;

      asente = play (1);
      bsente = play (0);

      /* Add the initial scores.  */
      asente.a += pa.a;
      asente.b += pa.b;
      bsente.a += pa.a;
      bsente.b += pa.b;

      /* There are two possibilities:
	 Alice plays the biggest reverse sente, and Bob
	 starts taking gote moves.
	 Alice plays biggest gote, Bob takes biggest
	 reverse sente and continues taking gote moves.  */
      asente.b += best_rev_sente.b;
      bsente.a += best_rev_sente.a;

      if (better_score (asente, bsente))
	printf ("%d %d\n", asente.a, asente.b);
      else
	printf ("%d %d\n", bsente.a, bsente.b);
    }
}
