#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c, m;
  cin >> a >> b >> c >> m;
  vector<pair<int, string> > v;
  for (long long i = 0; i < m; i++) {
    long long cost;
    string str;
    cin >> cost >> str;
    v.push_back(make_pair(cost, str));
  }
  sort(v.begin(), v.end());
  long long cnt = 0, cost = 0;
  for (long long i = 0; i < v.size(); i++) {
    if (v[i].second == "USB" && a > 0) {
      a--;
      cnt++;
      cost += v[i].first;
    } else if (v[i].second == "PS/2" && b > 0) {
      b--;
      cnt++;
      cost += v[i].first;
    } else if (c > 0) {
      cnt++;
      c--;
      cost += v[i].first;
    }
  }
  cout << cnt << ' ' << cost;
}
