#include <bits/stdc++.h>
using namespace std;
struct Mouse {
  int price;
  string type;
};
bool comparator(Mouse m1, Mouse m2) { return m1.price < m2.price; }
int main() {
  ios_base::sync_with_stdio(false);
  int m, a, b, c;
  cin >> a >> b >> c >> m;
  Mouse mice[m];
  bool bought[m];
  memset(bought, false, sizeof bought);
  for (int i = 0; i < m; i++) {
    cin >> mice[i].price >> mice[i].type;
  }
  sort(mice, mice + m, comparator);
  int equipped = 0;
  long long int price = 0;
  for (int i = 0; i < m; i++) {
    if (a <= 0 && b <= 0) break;
    bool buy = false;
    if (a > 0 && mice[i].type == "USB") {
      a--;
      buy = true;
    } else if (b > 0 && mice[i].type == "PS/2") {
      b--;
      buy = true;
    }
    if (buy) {
      bought[i] = true;
      equipped++;
      price += mice[i].price;
    }
  }
  for (int i = 0; i < m && c > 0; i++) {
    if (!bought[i]) {
      price += mice[i].price;
      c--;
      equipped++;
    }
  }
  cout << equipped << " " << price;
  return 0;
}
