#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s, ct = 0, x, i, y, j;
  char c;
  cin >> n >> s;
  map<int, int> buy, sell;
  for (i = 0; i < n; i++) {
    cin >> c >> x >> y;
    if (c == 'B') {
      buy[x] += y;
    }
    if (c == 'S') {
      sell[x] += y;
    }
  }
  map<int, int>::reverse_iterator rit;
  ct = 1;
  for (rit = sell.rbegin(); rit != sell.rend(); rit++) {
    if (distance(rit, sell.rend()) > s) {
      continue;
    }
    cout << "S"
         << " " << rit->first << " " << rit->second << endl;
  }
  ct = 1;
  for (rit = buy.rbegin(); rit != buy.rend() && s--; rit++) {
    cout << "B"
         << " " << rit->first << " " << rit->second << endl;
  }
  return 0;
}
