#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, s, p, q;
  map<int, int> sell, buy;
  vector<pair<int, int>> v;
  char d;
  cin >> n >> s;
  while (n--) {
    cin >> d >> p >> q;
    if (d == 'B') {
      if (buy.find(p) == buy.end()) {
        buy[p] = q;
      } else {
        buy[p] += q;
      }
    } else {
      if (sell.find(p) == sell.end())
        sell[p] = q;
      else
        sell[p] += q;
    }
  }
  map<int, int>::iterator it;
  int len = sell.size();
  if (len) {
    n = min(s, (int)sell.size());
    it = sell.begin();
    advance(it, n - 1);
    for (int i = 0; i < n; i++) {
      cout << "S " << it->first << " " << it->second << endl;
      it--;
    }
  }
  len = buy.size();
  if (len) {
    n = min(s, (int)buy.size());
    it = buy.end();
    it--;
    for (int i = 0; i < n; i++) {
      cout << "B " << it->first << " " << it->second << endl;
      it--;
    }
  }
  return 0;
}
