#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s;
  cin >> n >> s;
  map<int, long long> sale;
  map<int, long long> buy;
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    if (c == 'B') {
      int price, num;
      cin >> price >> num;
      buy[price] += num;
    } else {
      int price, num;
      cin >> price >> num;
      sale[price] += num;
    }
  }
  auto itb = sale.begin();
  stack<pair<long long, long long>> answ;
  for (int i = 0; i < min(int(sale.size()), s); i++) {
    answ.push((*itb));
    itb++;
  }
  while (!answ.empty()) {
    cout << "S"
         << " " << answ.top().first << " " << answ.top().second << endl;
    answ.pop();
  }
  auto its = buy.end();
  for (int i = 0; i < min(int(buy.size()), s); i++) {
    its--;
    cout << 'B' << " " << (*its).first << " " << (*its).second << endl;
  }
  cin >> n;
  return 0;
}
