#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b, c, m, valor, conte = 0, res = 0;
  string porta;
  cin >> a >> b >> c;
  cin >> m;
  vector<pair<int, string> > mv(m);
  for (int i = 0; i < m; i++) {
    cin >> valor >> porta;
    mv[i] = make_pair(valor, porta);
  }
  sort(mv.begin(), mv.end());
  for (int i = 0; i < mv.size(); i++) {
    if (mv[i].second == "USB") {
      if (a > 0 || c > 0) {
        conte++;
        res += mv[i].first;
        if (a > 0)
          a--;
        else if (c > 0)
          c--;
      }
    } else {
      if (b > 0 || c > 0) {
        conte++;
        res += mv[i].first;
        if (b > 0)
          b--;
        else if (c > 0)
          c--;
      }
    }
  }
  cout << conte << " " << res << endl;
  return 0;
}
