#include <bits/stdc++.h>
using namespace std;
long long ans1, ans, i, a, b, c, m, k;
pair<long long, string> pairi[300000];
int main() {
  cin >> a >> b >> c >> m;
  for (i = 0; i < m; i++) cin >> pairi[i].first >> pairi[i].second;
  sort(pairi, pairi + m);
  for (i = 0; i < m; i++) {
    if (a != 0 && pairi[i].second == "USB") {
      ans += pairi[i].first;
      a--;
      ans1++;
    } else if (b != 0 && pairi[i].second == "PS/2") {
      ans += pairi[i].first;
      b--;
      ans1++;
    } else if (c != 0) {
      ans += pairi[i].first;
      c--;
      ans1++;
    }
  }
  cout << ans1 << " " << ans;
}
