#include <bits/stdc++.h>
using namespace std;
int l[300007], r[300007], d[300007];
char s[1000];
int main() {
  int a, b, c, x, y, m, n, i, j, k, z, ll, rr, dd;
  long long ans;
  scanf("%d%d%d", &a, &b, &c);
  scanf("%d", &m);
  ll = 0;
  rr = 0;
  dd = 0;
  for (i = 0; i < m; i++) {
    scanf("%d", &k);
    getchar();
    gets(s);
    j = 0;
    while (s[j] != 'U' && s[j] != 'P' && j < strlen(s)) j++;
    if (s[j] == 'U')
      l[ll++] = k;
    else
      r[rr++] = k;
  }
  sort(l, l + ll);
  sort(r, r + rr);
  ans = 0;
  if (ll < a) a = ll;
  if (rr < b) b = rr;
  for (i = 0; i < a; i++) ans += (long long)l[i];
  for (i = 0; i < b; i++) ans += (long long)r[i];
  for (i = a; i < ll; i++) d[dd++] = l[i];
  for (i = b; i < rr; i++) d[dd++] = r[i];
  sort(d, d + dd);
  if (dd < c) c = dd;
  for (i = 0; i < c; i++) ans += (long long)d[i];
  printf("%d %I64d\n", a + b + c, ans);
  return 0;
}
