#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int t;
  cin >> t;
  vector<int> usb, ps2;
  while (t--) {
    int a;
    string s;
    cin >> a >> s;
    if (s[0] == 'U')
      usb.push_back(a);
    else
      ps2.push_back(a);
  }
  sort(usb.begin(), usb.end());
  sort(ps2.begin(), ps2.end());
  long long int sum = 0;
  int x = ps2.size();
  int y = usb.size();
  for (int i = 0; i < min(a, y); i++) sum += usb[i];
  for (int i = 0; i < min(b, x); i++) sum += ps2[i];
  vector<int> fin;
  for (int i = a; i < usb.size(); i++) fin.push_back(usb[i]);
  for (int i = b; i < ps2.size(); i++) fin.push_back(ps2[i]);
  sort(fin.begin(), fin.end());
  int z = fin.size();
  for (int i = 0; i < min(c, z); i++) sum += fin[i];
  cout << min(a, y) + min(b, x) + min(c, z) << " " << sum << endl;
}
