#include <bits/stdc++.h>
using namespace std;
int main() {
  int usb, ps, both;
  cin >> usb >> ps >> both;
  int num;
  cin >> num;
  int total = 0;
  vector<int> p1;
  vector<int> p2;
  for (int x = 0; x < num; x++) {
    int price;
    cin >> price;
    string type;
    cin >> type;
    if (type == "USB")
      p1.push_back(price);
    else
      p2.push_back(price);
  }
  sort(p1.begin(), p1.end());
  sort(p2.begin(), p2.end());
  int i = 0;
  long long ans = 0;
  for (; i < p1.size() && usb-- > 0; i++) {
    ans += p1[i];
    total++;
  }
  int j = 0;
  for (; j < p2.size() && ps-- > 0; j++) {
    ans += p2[j];
    total++;
  }
  while (both-- > 0) {
    if (i < p1.size() && j < p2.size()) {
      if (p1[i] < p2[j]) {
        ans += p1[i];
        i++;
      } else {
        ans += p2[j];
        j++;
      }
      total++;
    } else if (i < p1.size()) {
      ans += p1[i++];
      total++;
    } else if (j < p2.size()) {
      ans += p2[j++];
      total++;
    }
  }
  cout << total << " " << ans;
  return 0;
}
