#include <bits/stdc++.h>
using namespace std;
long long int cost = 0;
int total = 0;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int n;
  cin >> n;
  vector<pair<long long int, int> > v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].first;
    string s;
    cin >> s;
    if (s == "USB")
      v[i].second = 1;
    else
      v[i].second = 2;
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    if (v[i].second == 1) {
      if (a > 0) {
        a--;
        cost += v[i].first;
        total++;
      } else if (c > 0) {
        c--;
        cost += v[i].first;
        total++;
      }
    } else if (v[i].second == 2) {
      if (b > 0) {
        b--;
        cost += v[i].first;
        total++;
      } else if (c > 0) {
        c--;
        cost += v[i].first;
        total++;
      }
    }
  }
  cout << total << " " << cost;
  return 0;
}
