#include <bits/stdc++.h>
using namespace std;
const int INF = int(1e9);
long long a, b, c, n, ans, cost;
vector<pair<long long, string> > v;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> a >> b >> c;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int q;
    string w;
    cin >> q >> w;
    v.push_back({q, w});
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); ++i) {
    if (!a && !b && !c) break;
    if (v[i].second == "USB") {
      if (a > 0) {
        --a;
        ++ans;
        cost += v[i].first;
        continue;
      }
    }
    if (v[i].second == "PS/2") {
      if (b > 0) {
        --b;
        ++ans;
        cost += v[i].first;
        continue;
      }
    }
    if (c > 0) {
      ++ans;
      cost += v[i].first;
      --c;
    }
  }
  cout << ans << " " << cost;
  return 0;
}
