#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c;
  scanf("%lld %lld %lld", &a, &b, &c);
  long long n;
  scanf("%lld", &n);
  multiset<long long> usb, ps2, all;
  for (int i = 0; i < n; i++) {
    long long v;
    char s[100];
    scanf("%lld %s", &v, s);
    if (s[0] == 'U') {
      usb.insert(v);
    }
    if (s[0] == 'P') {
      ps2.insert(v);
    }
    all.insert(v);
  }
  long long count = 0, price = 0;
  while (a > 0 && usb.size() > 0) {
    count++;
    a--;
    long long val = *usb.begin();
    price += val;
    usb.erase(usb.begin());
    all.erase(all.find(val));
  }
  while (b > 0 && ps2.size() > 0) {
    count++;
    b--;
    long long val = *ps2.begin();
    price += val;
    ps2.erase(ps2.begin());
    all.erase(all.find(val));
  }
  while (c > 0 && all.size() > 0) {
    count++;
    c--;
    long long val = *all.begin();
    price += val;
    all.erase(all.begin());
  }
  printf("%lld %lld\n", count, price);
  return 0;
}
