#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int n;
  cin >> n;
  vector<vector<long long>> v(2);
  for (int i = 0; i < n; i++) {
    string s;
    unsigned long long num;
    cin >> num >> s;
    if (s[0] == 'U')
      v[0].push_back(num);
    else
      v[1].push_back(num);
  }
  sort(v[0].begin(), v[0].end());
  sort(v[1].begin(), v[1].end());
  long long sum = 0, total = 0;
  vector<int> both;
  if (a <= v[0].size()) {
    sum += accumulate(v[0].begin(), v[0].begin() + a, 0LL);
    total += a;
    both.insert(both.end(), v[0].begin() + a, v[0].end());
  } else {
    sum += accumulate(v[0].begin(), v[0].end(), 0LL);
    total += v[0].size();
  }
  if (b <= v[1].size()) {
    sum += accumulate(v[1].begin(), v[1].begin() + b, 0LL);
    total += b;
    both.insert(both.end(), v[1].begin() + b, v[1].end());
  } else {
    sum += accumulate(v[1].begin(), v[1].end(), 0LL);
    total += v[1].size();
  }
  sort(both.begin(), both.end());
  if (c <= both.size()) {
    sum += accumulate(both.begin(), both.begin() + c, 0LL);
    total += c;
  } else {
    sum += accumulate(both.begin(), both.end(), 0LL);
    total += both.size();
  }
  cout << total << " " << sum;
  return 0;
}
