#include <bits/stdc++.h>
using namespace std;
int u, p, b, n;
unsigned long long ans;
priority_queue<int, vector<int>, greater<int> > a, d;
int main() {
  scanf("%d %d %d\n", &u, &p, &b);
  scanf("%d\n", &n);
  int cnt = u + p + b;
  for (int i = 0; i < n; ++i) {
    int c;
    string t;
    scanf("%d", &c);
    cin >> t;
    if (t == "USB")
      a.push(c);
    else
      d.push(c);
  }
  while (u > 0 && a.size() > 0) {
    ans += a.top();
    a.pop();
    --u;
  }
  while (p > 0 && d.size() > 0) {
    ans += d.top();
    d.pop();
    --p;
  }
  while (b > 0) {
    int temp = 0;
    if (a.size() > 0) temp = a.top();
    if (d.size() > 0) {
      if (!temp || temp > d.top()) {
        temp = d.top();
        d.pop();
      } else
        a.pop();
    } else if (temp)
      a.pop();
    if (!temp) break;
    ans += temp;
    --b;
  }
  printf("%d %lld\n", cnt - u - p - b, ans);
  return 0;
}
