#include <bits/stdc++.h>
using namespace std;
map<int, int> buyMap;
map<int, int> sellMap;
int main() {
  int n, s;
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    char d;
    int p, q;
    cin >> d >> p >> q;
    if (d == 'B')
      buyMap[p] = (buyMap[p]) ? buyMap[p] + q : q;
    else
      sellMap[p] = (sellMap[p]) ? sellMap[p] + q : q;
  }
  map<int, int>::reverse_iterator rit;
  int startIndex = s > sellMap.size() ? sellMap.size() : s;
  int index = sellMap.size();
  for (rit = sellMap.rbegin(); rit != sellMap.rend(); ++rit) {
    if (startIndex < index--) continue;
    cout << "S " << rit->first << " " << rit->second << endl;
  }
  index = 0;
  for (rit = buyMap.rbegin(); rit != buyMap.rend(); ++rit) {
    cout << "B " << rit->first << " " << rit->second << endl;
    if (++index == s) break;
  }
  return 0;
}
