#include <bits/stdc++.h>
using namespace std;
const int N = 10101010;
const int K = (int)log2(N) + 2;
const int SQRTN = (int)sqrt(N) + 7;
const long long infi = 1ll << 60;
long long p1, p2, pp, m, val, ans, cnt;
vector<long long> usb, p, all;
string s;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  cin >> p1 >> p2 >> pp >> m;
  while (m--) {
    cin >> val >> s;
    if (s == "USB")
      usb.push_back(val);
    else
      p.push_back(val);
  }
  sort(usb.begin(), usb.end());
  sort(p.begin(), p.end());
  cnt += min(p1, (long long)usb.size());
  for (int(i) = (0); (i) <= (int)(min(p1, (long long)usb.size()) - 1); ++(i))
    ans += usb[i];
  for (int(i) = (min(p1, (long long)usb.size()));
       (i) <= (int)((long long)usb.size() - 1); ++(i))
    all.push_back(usb[i]);
  cnt += min(p2, (long long)p.size());
  for (int(i) = (0); (i) <= (int)(min(p2, (long long)p.size()) - 1); ++(i))
    ans += p[i];
  for (int(i) = (min(p2, (long long)p.size()));
       (i) <= (int)((long long)p.size() - 1); ++(i))
    all.push_back(p[i]);
  sort(all.begin(), all.end());
  cnt += min(pp, (long long)all.size());
  for (int(i) = (0); (i) <= (int)(min(pp, (long long)all.size()) - 1); ++(i))
    ans += all[i];
  cout << cnt << " " << ans << endl;
  return 0;
}
