#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c, n, k, p, price = 0, cnt = 0, i, x;
  string str;
  vector<long long> type1, type2;
  cin >> a >> b >> c >> n;
  for (i = 0; i < n; i++) {
    cin >> x;
    cin >> str;
    if (str == "USB")
      type1.push_back(x);
    else
      type2.push_back(x);
  }
  sort(type1.begin(), type1.end());
  sort(type2.begin(), type2.end());
  k = 0;
  while (a != 0) {
    if (type1.size() > k) {
      price += type1[k++];
      cnt++;
    } else
      break;
    a--;
  }
  p = 0;
  while (b != 0) {
    if (type2.size() > p) {
      price += type2[p++];
      cnt++;
    } else
      break;
    b--;
  }
  while (c != 0) {
    if (k < type1.size() && p < type2.size()) {
      if (type1[k] <= type2[p])
        price += type1[k++];
      else
        price += type2[p++];
      cnt++;
    } else if (k < type1.size()) {
      cnt++, price += type1[k++];
    } else if (p < type2.size()) {
      cnt++, price += type2[p++];
    } else
      break;
    c--;
  }
  cout << cnt << " " << price << endl;
}
