#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ;
  int u, p, b;
  cin >> u >> p >> b;
  int n;
  cin >> n;
  vector<int> us, ps;
  us.push_back(1e9 + 500);
  ps.push_back(1e9 + 500);
  for (int i = 0; i < n; i++) {
    int val;
    cin >> val;
    string ty;
    cin >> ty;
    if (ty == "USB")
      us.push_back(val);
    else
      ps.push_back(val);
  }
  sort(us.begin(), us.end(), greater<int>());
  sort(ps.begin(), ps.end(), greater<int>());
  long long cost = 0;
  int count = 0;
  n = us.size() - 1;
  for (int i = 0; i < min(u, n); i++) {
    cost += us.back();
    count++;
    us.pop_back();
  }
  n = ps.size() - 1;
  for (int i = 0; i < min(p, n); i++) {
    cost += ps.back();
    count++;
    ps.pop_back();
  }
  n = us.size() + ps.size() - 2;
  for (int i = 0; i < min(b, n); i++) {
    int m = min(us.back(), ps.back());
    cost += m;
    count++;
    if (us.back() == m)
      us.pop_back();
    else
      ps.pop_back();
  }
  cout << count << ' ' << cost << endl;
  return 0;
}
