#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b, c;
  cin >> a >> b >> c;
  long long int total = a + b + c;
  long long int m;
  long long int cost = 0;
  cin >> m;
  vector<long long int> USB, PS;
  long long int i, val;
  string type;
  for (i = 0; i < m; i++) {
    cin >> val;
    cin >> type;
    if (type == "USB") USB.push_back(val);
    if (type == "PS/2") PS.push_back(val);
  }
  vector<long long int>::iterator it1, it2;
  sort(USB.begin(), USB.end());
  sort(PS.begin(), PS.end());
  for (it1 = USB.begin(); it1 != USB.end(); it1++) {
    if (a == 0)
      break;
    else {
      cost += (*it1);
      a--;
    }
  }
  for (it2 = PS.begin(); it2 != PS.end(); it2++) {
    if (b == 0)
      break;
    else {
      cost += (*it2);
      b--;
    }
  }
  while (it1 != USB.end() || it2 != PS.end()) {
    if (c == 0)
      break;
    else {
      long long int yo1, yo2;
      if (it1 == USB.end())
        yo1 = 1000000007;
      else {
        yo1 = (*it1);
      }
      if (it2 == PS.end())
        yo2 = 1000000007;
      else {
        yo2 = (*it2);
      }
      if (yo1 < yo2) {
        cost += yo1;
        c--;
        it1++;
      } else {
        cost += yo2;
        c--;
        it2++;
      }
    }
  }
  cout << (total - (a + b + c)) << ' ' << cost << endl;
  return 0;
}
