#include <bits/stdc++.h>
using namespace std;
struct use {
  long long int t, v;
};
int a, b, c, m;
vector<use> v;
use aux;
char xua[10];
bool mark[300030];
bool cmp(use a, use b) { return a.v < b.v; }
int main() {
  scanf("%d %d %d %d", &a, &b, &c, &m);
  v.reserve(m + 2);
  for (int i = (int)0; i < (int)m; i++) {
    scanf("%lld %s", &aux.v, xua);
    if (xua[0] == 'U')
      aux.t = 0;
    else
      aux.t = 1;
    v.push_back(aux);
  }
  sort(v.begin(), v.end(), cmp);
  long long int total = 0, sum = 0;
  for (int i = (int)0; i < (int)v.size(); i++) {
    if (v[i].t == 0 && a) {
      mark[i] = true;
      a--;
      total++;
      sum += v[i].v;
    }
    if (v[i].t == 1 && b) {
      mark[i] = true;
      b--;
      total++;
      sum += v[i].v;
    }
  }
  for (int i = (int)0; i < (int)v.size(); i++) {
    if (mark[i]) continue;
    if (c) {
      mark[i] = true;
      c--;
      total++;
      sum += v[i].v;
    }
  }
  cout << total << " " << sum << '\n';
  return 0;
}
