#include <bits/stdc++.h>
using namespace std;
unsigned long long a, b, c, n, temp, wyn1 = 0, wyn2 = 0;
string typ;
vector<unsigned int> vusb;
vector<unsigned int> vps2;
vector<unsigned int> v3;
int main() {
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> n;
  for (unsigned int i = 0; i < n; i++) {
    cin >> temp;
    cin >> typ;
    if (typ == "USB")
      vusb.push_back(temp);
    else
      vps2.push_back(temp);
  }
  sort(vusb.begin(), vusb.end());
  sort(vps2.begin(), vps2.end());
  for (unsigned int i = a; i < vusb.size(); i++) {
    v3.push_back(vusb[i]);
  }
  for (unsigned int i = b; i < vps2.size(); i++) {
    v3.push_back(vps2[i]);
  }
  sort(v3.begin(), v3.end());
  for (unsigned int i = 0; i < a; i++) {
    if (i >= vusb.size()) break;
    wyn1++;
    wyn2 += vusb[i];
  }
  for (unsigned int i = 0; i < b; i++) {
    if (i >= vps2.size()) break;
    wyn1++;
    wyn2 += vps2[i];
  }
  for (unsigned int i = 0; i < v3.size() and c > 0; i++) {
    wyn1++;
    wyn2 += v3[i];
    c--;
  }
  cout << wyn1 << " " << wyn2;
  return 0;
}
