#include <bits/stdc++.h>
int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int main() {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  int val, n, USB[300000], ps[300000], l1 = 0, l2 = 0;
  char str[6];
  scanf("%d", &n);
  while (n--) {
    scanf("%d%s", &val, str);
    if (str[0] == 'U') {
      USB[l1++] = val;
    } else
      ps[l2++] = val;
  }
  qsort(USB, l1, sizeof(int), cmp);
  qsort(ps, l2, sizeof(int), cmp);
  int count = 0, j = 0, k = 0, l = 0;
  long long sum = 0;
  while (j < l1 && j < a) {
    count++;
    sum += USB[j++];
  }
  while (k < l2 && k < b) {
    count++;
    sum += ps[k++];
  }
  while ((j < l1 || k < l2) && l < c) {
    count++;
    l++;
    if (j == l1)
      sum += ps[k++];
    else if (k == l2)
      sum += USB[j++];
    else if (USB[j] < ps[k])
      sum += USB[j++];
    else
      sum += ps[k++];
  }
  printf("%d %lld\n", count, sum);
  return 0;
}
