#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, s, p, q;
  cin >> n >> s;
  char c;
  map<long long int, long long int, greater<long long int> > b, se;
  for (long long int i = 0; i < n; i++) {
    cin >> c >> p >> q;
    if (c == 'B') {
      if (b.find(p) == b.end()) b.insert({p, 0});
      b[p] += q;
    } else {
      if (se.find(p) == se.end()) se.insert({p, 0});
      se[p] += q;
    }
  }
  long long int i = 0;
  map<long long int, long long int>::iterator it;
  if (se.size() > s)
    it = prev(se.end(), s);
  else
    it = se.begin();
  while (i < fmin(s, se.size())) {
    cout << "S"
         << " " << it->first << " " << it->second << endl;
    it++;
    i++;
  }
  i = 0;
  it = b.begin();
  while (i < fmin(s, b.size())) {
    cout << "B"
         << " " << it->first << " " << it->second << endl;
    it++;
    i++;
  }
}
