#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l, u, v, w, x, y, z, a, b, c, d, e, f, t = 1, tc;
  long long flg, sz, cnt, gt, ans, mx, mn;
  long long m, k, n, i, j;
  long long low, hi, md, inp[200007], sm, ff, ex;
  vector<long long> tk[4];
  cin >> a >> b >> c;
  cin >> n;
  string st;
  for (int i = 0; i < n; i++) {
    cin >> x >> st;
    if (st == "USB") {
      tk[1].push_back(x);
      ;
    } else {
      tk[2].push_back(x);
      ;
    }
  }
  sort(tk[1].begin(), tk[1].end());
  sort(tk[2].begin(), tk[2].end());
  ans = 0, cnt = 0;
  for (int i = 0; i < tk[1].size(); i++) {
    if (!a) break;
    cnt++;
    ans += tk[1][i];
    tk[1][i] = 0;
    a--;
  }
  for (int i = 0; i < tk[2].size(); i++) {
    if (!b) break;
    cnt++;
    ans += tk[2][i];
    tk[2][i] = 0;
    b--;
  }
  for (int i = 0; i < tk[1].size(); i++) {
    if (tk[1][i]) tk[3].push_back(tk[1][i]);
    ;
  }
  for (int i = 0; i < tk[2].size(); i++) {
    if (tk[2][i]) tk[3].push_back(tk[2][i]);
    ;
  }
  sort(tk[3].begin(), tk[3].end());
  for (int i = 0; i < tk[3].size(); i++) {
    if (!c) break;
    cnt++;
    ans += tk[3][i];
    c--;
  }
  cout << cnt << " " << ans << endl;
  return 0;
}
