#include <bits/stdc++.h>
using namespace std;
int main() {
  int usb, ps, both;
  scanf("%d", &usb);
  scanf("%d", &ps);
  scanf("%d", &both);
  int cnt = 0;
  long long cost = 0;
  vector<int> u, p;
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int c;
    scanf("%d", &c);
    string s;
    cin >> s;
    if (s == "USB")
      u.push_back(c);
    else
      p.push_back(c);
  }
  sort(u.begin(), u.end());
  sort(p.begin(), p.end());
  int l = 0, r = 0;
  while (l < u.size() && r < p.size()) {
    if (u[l] < p[r]) {
      if (usb > 0) {
        usb--;
        cost += (long long)u[l++];
        cnt++;
      } else if (both > 0) {
        both--;
        cost += (long long)u[l++];
        cnt++;
      } else {
        while (r < p.size() && ps > 0) {
          ps--;
          cost += (long long)p[r++];
          cnt++;
        }
        break;
      }
    } else {
      if (ps > 0) {
        ps--;
        cost += (long long)p[r++];
        cnt++;
      } else if (both > 0) {
        both--;
        cost += (long long)p[r++];
        cnt++;
      } else {
        while (l < u.size() && usb > 0) {
          usb--;
          cost += (long long)u[l++];
          cnt++;
        }
        break;
      }
    }
  }
  while (l < u.size()) {
    if (usb > 0) {
      usb--;
      cost += (long long)u[l++];
      cnt++;
    } else if (both > 0) {
      both--;
      cost += (long long)u[l++];
      cnt++;
    } else
      break;
  }
  while (r < p.size()) {
    if (ps > 0) {
      ps--;
      cost += (long long)p[r++];
      cnt++;
    } else if (both > 0) {
      both--;
      cost += (long long)p[r++];
      cnt++;
    } else
      break;
  }
  cout << cnt << " " << cost << endl;
  return 0;
}
