#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, m, temp;
  scanf("%d%d%d", &a, &b, &c);
  scanf("%d", &m);
  vector<int> p;
  vector<int> q;
  string str;
  while (m--) {
    cin >> temp;
    cin >> str;
    if (str == "USB") {
      p.push_back(temp);
    } else {
      q.push_back(temp);
    }
  }
  int l1 = p.size();
  int l2 = q.size();
  if (l1 != 0) sort(p.rbegin(), p.rend());
  if (l2 != 0) sort(q.rbegin(), q.rend());
  long long int sum = 0;
  int cnt = 0;
  while (l1 != 0 && a > 0) {
    sum = sum + p.back();
    p.pop_back();
    l1--;
    a--;
    cnt++;
  }
  while (l2 != 0 && b > 0) {
    sum = sum + q.back();
    q.pop_back();
    l2--;
    b--;
    cnt++;
  }
  while (c > 0 && (l1 != 0 || l2 != 0)) {
    if (l1 == 0) {
      sum = sum + q.back();
      q.pop_back();
      l2--;
      b--;
      cnt++;
    } else if (l2 == 0) {
      sum = sum + p.back();
      p.pop_back();
      l1--;
      a--;
      cnt++;
    } else {
      if (p.back() < q.back()) {
        sum = sum + p.back();
        p.pop_back();
        l1--;
        cnt++;
      } else {
        sum = sum + q.back();
        q.pop_back();
        l2--;
        cnt++;
      }
    }
    c--;
  }
  cout << cnt << " " << sum << endl;
  return 0;
}
