#include <bits/stdc++.h>
using namespace std;
map<int, int> sell;
map<int, int> bu;
stack<pair<int, int> > ss;
struct compare {
  bool operator()(pair<int, int> a, pair<int, int> b) {
    return b.first < a.first;
  }
};
struct compare2 {
  bool operator()(pair<int, int> a, pair<int, int> b) {
    return b.first > a.first;
  }
};
int main() {
  int n, s, i, p, q;
  cin >> n >> s;
  char c;
  for (i = 0; i < n; i++) {
    cin >> c >> p >> q;
    if (c == 'S')
      sell[p] += q;
    else
      bu[p] += q;
  }
  priority_queue<pair<int, int>, std::vector<pair<int, int> >, compare2> P;
  priority_queue<pair<int, int>, std::vector<pair<int, int> >, compare> Q;
  map<int, int>::iterator ii;
  pair<int, int> pp;
  for (ii = sell.begin(); ii != sell.end(); ii++)
    Q.push(make_pair(ii->first, ii->second));
  for (ii = bu.begin(); ii != bu.end(); ii++)
    P.push(make_pair(ii->first, ii->second));
  for (i = 0; i < s && !Q.empty(); i++) {
    pp = Q.top();
    Q.pop();
    ss.push(pp);
  }
  while (!ss.empty()) {
    pp = ss.top();
    ss.pop();
    cout << "S"
         << " " << pp.first << " " << pp.second << endl;
  }
  for (i = 0; i < s && !P.empty(); i++) {
    pp = P.top();
    P.pop();
    cout << "B"
         << " " << pp.first << " " << pp.second << endl;
  }
}
