#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, s;
  cin >> n >> s;
  map<int, int> buy;
  map<int, int> sell;
  char type;
  int price, quantity;
  for (int i = 0; i < n; i++) {
    cin >> type >> price >> quantity;
    if (type == 'S') {
      sell[price] += quantity;
    } else if (type == 'B') {
      buy[price] += quantity;
    }
  }
  int temp1 = 0;
  if (s > sell.size())
    temp1 = sell.size();
  else
    temp1 = s;
  int count1, count2;
  bool flag1 = 1, flag2 = 1;
  count1 = sell.size();
  if (count1 == 0) flag1 = 0;
  if (count1 > s) count1 = s;
  int temp = 0;
  if (flag1 == 1) {
    map<int, int>::iterator it = sell.begin();
    advance(it, temp1 - 1);
    for (; temp < count1; temp++, it--) {
      cout << "S " << it->first << " " << it->second << "\n";
    }
  }
  temp = 0;
  count2 = buy.size();
  if (count2 == 0) flag2 = 0;
  if (count2 > s) count2 = s;
  if (flag2 == 1) {
    map<int, int>::iterator jt = buy.end();
    jt--;
    for (; temp < count2; temp++, jt--) {
      cout << "B " << jt->first << " " << jt->second << " \n";
    }
  }
  return 0;
}
