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