#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int qt[3];
  cin >> qt[0] >> qt[1] >> qt[2];
  map<string, int> conv;
  conv["USB"] = 0;
  conv["PS/2"] = 1;
  int m;
  cin >> m;
  pair<int, int> v[300010];
  string s;
  for (int i = 0; i < m; i++) {
    cin >> v[i].first >> s;
    v[i].second = conv[s];
  }
  sort(v, v + m);
  long long ans = 0;
  int am = 0;
  for (int i = 0; i < m; i++) {
    if (qt[v[i].second] > 0) {
      ans += v[i].first;
      qt[v[i].second]--;
      am++;
    } else if (qt[2] > 0) {
      ans += v[i].first;
      qt[2]--;
      am++;
    }
  }
  cout << am << " " << ans << endl;
  return 0;
}
