#include <bits/stdc++.h>
using namespace std;
long long a, b, c;
long long m;
pair<long long, bool> p[1000000];
string s;
long long x = 0, y = 0;
int main() {
  cin >> a >> b >> c;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> p[i].first >> s;
    if (s == "USB")
      p[i].second = 0;
    else
      p[i].second = 1;
  }
  sort(p, p + m);
  for (int i = 0; i < m; i++) {
    if (p[i].second == 0) {
      if (a > 0) {
        x++;
        a--;
        y += p[i].first;
      } else if (c > 0) {
        x++;
        c--;
        y += p[i].first;
      }
    } else if (p[i].second == 1) {
      if (b > 0) {
        x++;
        b--;
        y += p[i].first;
      } else if (c > 0) {
        x++;
        c--;
        y += p[i].first;
      }
    }
  }
  cout << x << " " << y << "\n";
}
