#include <bits/stdc++.h>
using namespace std;
long long m[1000005], n[1000005], w[1000005];
int main() {
  long long a, b, c;
  char ch[10];
  while ((scanf("%lld%lld%lld", &a, &b, &c)) != EOF) {
    long long t;
    scanf("%lld", &t);
    long long p = 0, q = 0, r, sum1 = 0, sum2 = 0, f;
    for (int i = 0; i < t; i++) {
      scanf("%lld", &f);
      scanf("%s", ch);
      if (ch[0] == 'U')
        m[p++] = f;
      else
        n[q++] = f;
    }
    sort(m, m + p);
    sort(n, n + q);
    long long i, j;
    long long l = 0;
    for (i = 0; i < a && i < p; i++) {
      sum2 += m[i];
      sum1++;
    }
    while (m[i]) {
      w[l++] = m[i++];
    }
    for (i = 0; i < b && i < q; i++) {
      sum2 += n[i];
      sum1++;
    }
    while (n[i]) w[l++] = n[i++];
    sort(w, w + l);
    for (int i = 0; i < c && i < l; i++) {
      sum2 += w[i];
      sum1++;
    }
    printf("%lld %lld\n", sum1, sum2);
  }
  return 0;
}
