#include <bits/stdc++.h>
using namespace std;
bool mycomp(pair<int, char> a, pair<int, char> b) {
  if (a.first < b.first)
    return true;
  else
    return false;
}
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  long long sum = 0;
  int total = a + b + c;
  int m;
  cin >> m;
  vector<pair<int, char> > gr;
  for (int i = 0; i < m; i++) {
    int t;
    string s;
    cin >> t >> s;
    gr.push_back(make_pair(t, s[0]));
  }
  sort(gr.begin(), gr.end(), mycomp);
  for (int i = 0; i < m; i++) {
    if (gr[i].second == 'U') {
      if (a > 0) {
        sum += gr[i].first;
        a--;
      } else if (c > 0) {
        sum += gr[i].first;
        c--;
      }
    } else {
      if (b > 0) {
        sum += gr[i].first;
        b--;
      } else if (c > 0) {
        sum += gr[i].first;
        c--;
      }
    }
  }
  cout << total - a - b - c << " " << sum;
  return 0;
}
