#include <bits/stdc++.h>
using namespace std;
long long maxi(long long a, long long b) {
  if (a > b) return a;
  return b;
}
long long mini(long long a, long long b) {
  if (a > b) return b;
  return a;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long a, b, c, m;
  cin >> a >> b >> c >> m;
  long long eq = 0, val = 0;
  vector<pair<long long, string> > arr(m);
  for (long long i = 0; i < m; i++) {
    cin >> arr[i].first >> arr[i].second;
  }
  sort(arr.begin(), arr.end());
  for (long long i = 0; i < m; i++) {
    if (a && arr[i].second == "USB") {
      a--;
      eq++;
      val += arr[i].first;
    } else if (b && arr[i].second == "PS/2") {
      b--;
      eq++;
      val += arr[i].first;
    } else if (c) {
      c--;
      eq++;
      val += arr[i].first;
    }
  }
  cout << eq << " " << val << "\n";
  return 0;
}
