#include <bits/stdc++.h>
using namespace std;
bool compare(pair<long long int, string> p1, pair<long long int, string> p2) {
  return p1.first < p2.first;
}
int main() {
  int a, b, c;
  int m;
  cin >> a >> b >> c;
  cin >> m;
  vector<pair<long long int, string> > v;
  int i = 0;
  long long int cost = 0, count = 0;
  for (i = 0; i < m; i++) {
    int no;
    string s;
    cin >> no >> s;
    v.push_back(make_pair(no, s));
  }
  sort(v.begin(), v.end(), compare);
  vector<pair<long long int, string> >::iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it->second == "USB") {
      if (a) {
        a--;
        cost += it->first;
        count++;
      } else if (c) {
        c--;
        cost += it->first;
        count++;
      }
    } else if (it->second == "PS/2") {
      if (b) {
        b--;
        cost += it->first;
        count++;
      } else if (c) {
        c--;
        cost += it->first;
        count++;
      }
    }
    if (c == 0 && b == 0 && a == 0) break;
  }
  cout << count << " " << cost;
  return 0;
}
