#include <bits/stdc++.h>
using namespace std;
int a, b, c, n, cnt, an, bn, A[300300], B[300300];
long long cost, sa[300300], sb[300300];
int main() {
  scanf("%d %d %d", &a, &b, &c);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int val;
    char type[11];
    scanf("%d %s", &val, type);
    if (strcmp(type, "USB") == 0)
      A[++an] = val;
    else
      B[++bn] = val;
  }
  if (an) sort(A + 1, A + an + 1);
  for (int i = 1; i <= an; i++) sa[i] = sa[i - 1] + A[i];
  if (bn) sort(B + 1, B + bn + 1);
  for (int i = 1; i <= bn; i++) sb[i] = sb[i - 1] + B[i];
  for (int i = 0; i <= a + c && i <= an; i++) {
    int j = min(b + c + a - max(i, a), bn);
    if (i + j > cnt)
      cnt = i + j, cost = sa[i] + sb[j];
    else if (i + j == cnt)
      cost = min(cost, sa[i] + sb[j]);
  }
  printf("%d %I64d\n", cnt, cost);
  return 0;
}
