#include <bits/stdc++.h>
int compare(const void *a, const void *b) {
  long long *la = (long long *)a;
  long long *lb = (long long *)b;
  return *la == *lb ? 0 : (*la < *lb ? -1 : 1);
}
int main() {
  static long long uu[300000], pp[300000];
  int a, b, c, m, uk, pk;
  int max, k, i;
  long long min;
  scanf("%d%d%d", &a, &b, &c);
  scanf("%d", &m);
  uk = pk = 0;
  for (i = 0; i < m; i++) {
    static char up[16];
    int a;
    scanf("%d %s", &a, up);
    if (strlen(up) == 3 && strcmp(up, "USB") == 0)
      uu[uk++] = a;
    else
      pp[pk++] = a;
  }
  qsort(uu, uk, sizeof *uu, compare);
  qsort(pp, pk, sizeof *pp, compare);
  for (i = 1; i < uk; i++) uu[i] += uu[i - 1];
  for (i = 1; i < pk; i++) pp[i] += pp[i - 1];
  max = 0, min = 0;
  for (k = 0; k <= uk && k <= a + c; k++) {
    int r = b + (k <= a ? c : c - (k - a));
    int k_ = (r < pk ? r : pk);
    int cnt = k + k_;
    long long price = (k == 0 ? 0 : uu[k - 1]) + (k_ == 0 ? 0 : pp[k_ - 1]);
    if (max < cnt || (max == cnt && min > price)) {
      max = cnt;
      min = price;
    }
  }
  printf("%d %lld\n", max, min);
  return 0;
}
