#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long N = 2e6 + 13, M = N;
vector<long long> g[N];
long long arr[N];
long long n, m, k;
void solve() {
  long long i, j, a, b, c;
  cin >> a >> b >> c;
  long long total = a + b + c;
  cin >> m;
  vector<pair<long long, char>> mouse(m);
  for (i = 0; i < m; i++) {
    long long x;
    string s;
    cin >> x >> s;
    mouse[i].first = x;
    if (s == "USB")
      mouse[i].second = 'a';
    else
      mouse[i].second = 'b';
  }
  sort(mouse.begin(), mouse.end());
  long long cost = 0;
  for (i = 0; i < m; i++) {
    if (mouse[i].second == 'a') {
      if (a) {
        a--;
        cost += mouse[i].first;
      } else if (c) {
        c--;
        cost += mouse[i].first;
      }
    }
    if (mouse[i].second == 'b') {
      if (b) {
        b--;
        cost += mouse[i].first;
      } else if (c) {
        c--;
        cost += mouse[i].first;
      }
    }
  }
  cout << total - a - b - c << " " << cost << endl;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
