#include <bits/stdc++.h>
using namespace std;
const int delta = (int)1e9 + 7;
int a, b, c, m, x, t;
long long ans;
vector<int> v[3];
string s;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> a >> b >> c >> m;
  while (m--) {
    cin >> x >> s;
    if (s == "USB")
      v[1].push_back(x);
    else
      v[2].push_back(x);
  }
  sort(v[1].begin(), v[1].end());
  sort(v[2].begin(), v[2].end());
  for (int i = 0; i < v[1].size(); ++i) {
    if (a) {
      ++t;
      ans += v[1][i];
      --a;
    } else
      v[0].push_back(v[1][i]);
  }
  for (int i = 0; i < v[2].size(); ++i) {
    if (b) {
      ++t;
      ans += v[2][i];
      --b;
    } else
      v[0].push_back(v[2][i]);
  }
  sort(v[0].begin(), v[0].end());
  for (int i = 0; i < v[0].size(); ++i) {
    if (c) {
      ++t;
      ans += v[0][i];
      --c;
    }
  }
  cout << t << " " << ans;
  return cout << endl, 0;
}
