#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
int n;
vector<ll> v1, v2;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int a, b, c;
  ll x;
  string s;
  cin >> a >> b >> c;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x >> s;
    if (s == "USB")
      v1.push_back(x);
    else
      v2.push_back(x);
  }
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  int t1 = 0, t2 = 0;
  ll cost = 0;
  for (; t1 < a && t1 < v1.size(); t1++) {
    cost += v1[t1];
  }
  for (; t2 < b && t2 < v2.size(); t2++) {
    cost += v2[t2];
  }
  int ans = 0;
  if (t1 > 0) ans += t1;
  if (t2 > 0) ans += t2;
  for (int i = 0; i < c; i++) {
    if (t1 < v1.size() && (t2 == v2.size() || v1[t1] <= v2[t2])) {
      cost += v1[t1];
      t1++;
      ans++;
    } else if (t2 < v2.size()) {
      cost += v2[t2];
      t2++;
      ans++;
    } else {
      break;
    }
  }
  cout << ans << " " << cost << '\n';
  return 0;
}
