#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long a, b, c;
  cin >> a >> b >> c;
  long long m;
  cin >> m;
  vector<long long> usb2, ps2, mix;
  for (long long i = 0; i < m; i++) {
    long long val;
    cin >> val;
    string s;
    cin >> s;
    if (s == "USB") {
      usb2.push_back(val);
    } else {
      ps2.push_back(val);
    }
  }
  sort(usb2.begin(), usb2.end());
  sort(ps2.begin(), ps2.end());
  long long ans = 0;
  long long num = 0;
  long long pos = 0;
  while (a > 0 and pos < usb2.size()) {
    ans += usb2[pos];
    num++;
    pos++;
    a--;
  }
  while (pos < usb2.size()) {
    mix.push_back(usb2[pos]);
    pos++;
  }
  pos = 0;
  while (b > 0 and pos < ps2.size()) {
    ans += ps2[pos];
    num++;
    pos++;
    b--;
  }
  while (pos < ps2.size()) {
    mix.push_back(ps2[pos]);
    pos++;
  }
  pos = 0;
  sort(mix.begin(), mix.end());
  while (c > 0 and pos < mix.size()) {
    ans += mix[pos];
    num++;
    pos++;
    c--;
  }
  cout << num << " " << ans << "\n";
  return 0;
}
