#include <bits/stdc++.h>
using namespace std;
int a, b, c, n, x, resk, l;
long long ress;
string s;
vector<int> u, p;
int main() {
  cin >> a >> b >> c >> n;
  for (int i = (0); i < (n); i++) {
    cin >> x >> s;
    if (s == "USB")
      u.push_back(x);
    else
      p.push_back(x);
  }
  sort((u).begin(), (u).end());
  sort((p).begin(), (p).end());
  while (l < u.size() && a) {
    ress += u[l];
    u[l] = INT_MAX;
    resk++;
    l++;
    a--;
  }
  l = 0;
  while (l < p.size() && b) {
    ress += p[l];
    p[l] = INT_MAX;
    resk++;
    l++;
    b--;
  }
  for (int i = (0); i < (p.size()); i++) u.push_back(p[i]);
  sort((u).begin(), (u).end());
  l = 0;
  while (l < u.size() && c && u[l] != INT_MAX) {
    ress += u[l];
    resk++;
    l++;
    c--;
  }
  cout << resk << " " << ress;
  return 0;
}
