#include <bits/stdc++.h>
using namespace std;
long long a, b, c, n;
vector<long long> usb, ps2;
void enter() {
  cin >> a >> b >> c >> n;
  long long x;
  string type;
  for (long long i = 0, _a = (n); i < _a; ++i) {
    cin >> x >> type;
    if (type == "USB")
      usb.push_back(x);
    else
      ps2.push_back(x);
  }
}
long long cnt, ans;
void solve() {
  sort(usb.begin(), usb.end());
  sort(ps2.begin(), ps2.end());
  long long i = 0, j = 0, k = 0;
  for (i = 0; i < min(((long long)(usb).size()), a); i++) {
    cnt++;
    ans += usb[i];
  }
  for (j = 0; j < min(((long long)(ps2).size()), b); j++) {
    cnt++;
    ans += ps2[j];
  }
  while (k < c &&
         (i < ((long long)(usb).size()) || j < ((long long)(ps2).size()))) {
    if (i >= ((long long)(usb).size()) || j >= ((long long)(ps2).size())) {
      if (i < ((long long)(usb).size()))
        ans += usb[i], i++;
      else
        ans += ps2[j];
      j++;
    } else if (usb[i] < ps2[j]) {
      ans += usb[i];
      i++;
    } else {
      ans += ps2[j];
      j++;
    }
    k++;
    cnt++;
  }
  cout << cnt << ' ' << ans;
}
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cout << (fixed) << setprecision(9);
  enter();
  solve();
}
