#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, i, j, m, a1, b1, k, u1, p1;
  vector<long long> usb;
  vector<long long> ps;
  cin >> a >> b >> c >> m;
  long long val, ans(0);
  string s;
  for (i = 0; i < m; i++) {
    cin >> val;
    cin >> s;
    if (s == "USB")
      usb.push_back(val);
    else
      ps.push_back(val);
  }
  if (m == 0) {
    cout << "0"
         << " " << 0;
    return 0;
  }
  sort(usb.begin(), usb.end(), greater<long long>());
  sort(ps.begin(), ps.end(), greater<long long>());
  u1 = usb.size();
  p1 = ps.size();
  a1 = min(a, u1);
  b1 = min(b, p1);
  for (k = a1; k > 0; k--) {
    ans += usb.back();
    usb.pop_back();
  }
  for (k = b1; k > 0; k--) {
    ans += ps.back();
    ps.pop_back();
  }
  for (i = 0; i < ps.size(); i++) usb.push_back(ps[i]);
  sort(usb.begin(), usb.end(), greater<long long>());
  k = c;
  while (k && usb.size() > 0) {
    ans += usb.back();
    usb.pop_back();
    k--;
  }
  cout << a1 + b1 + (c - k) << " " << ans;
  return 0;
}
