#include <bits/stdc++.h>
int main() {
  using namespace std;
  long long a, b, c, x, y, i, e, j, t, T, G, g, f;
  char s;
  t = 0;
  T = 0;
  scanf("%I64d", &a);
  scanf("%I64d", &b);
  scanf("%I64d", &c);
  scanf("%I64d", &t);
  vector<long long> A;
  vector<long long> B;
  vector<long long> C;
  for (i = 0; i < t; i++) {
    scanf("%I64d", &g);
    scanf("%c", &s);
    scanf("%c", &s);
    if (s == 'U') A.push_back(g);
    if (s == 'P') B.push_back(g);
    for (; (int)s != 10;) scanf("%c", &s);
  }
  std::sort(A.begin(), A.end());
  std::sort(B.begin(), B.end());
  t = 0;
  T = 0;
  g = fmin(A.size(), a);
  a -= g;
  for (i = 0; i < g; i++) {
    t++;
    T += A[i];
  }
  A.erase(A.begin(), A.begin() + g);
  g = fmin(B.size(), b);
  b -= g;
  for (i = 0; i < g; i++) {
    t++;
    T += B[i];
  }
  B.erase(B.begin(), B.begin() + g);
  C = A;
  for (i = 0; i < B.size(); i++) A.push_back(B[i]);
  std::sort(A.begin(), A.end());
  g = fmin(A.size(), c);
  for (i = 0; i < g; i++) {
    t++;
    T += A[i];
  }
  printf("%I64d %I64d", t, T);
}
