#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s;
  cin >> n >> s;
  map<int, int> buy;
  map<int, int> sell;
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    int p, q;
    cin >> p >> q;
    if (c == 'B') {
      map<int, int>::iterator it = buy.find(p);
      if (it == buy.end()) {
        buy.insert(make_pair(p, q));
      } else {
        (*it).second += q;
      }
    } else {
      map<int, int>::iterator it = sell.find(p);
      if (it == sell.end()) {
        sell.insert(make_pair(p, q));
      } else {
        (*it).second += q;
      }
    }
  }
  vector<pair<int, int> > seller;
  int i = 0;
  for (map<int, int>::iterator it = sell.begin(); it != sell.end(); it++) {
    seller.push_back(make_pair(it->first, it->second));
    i++;
    if (i == s) break;
  }
  for (int j = seller.size() - 1; j >= 0; j--) {
    cout << "S " << seller[j].first << " " << seller[j].second << endl;
  }
  i = 0;
  for (map<int, int>::reverse_iterator it = buy.rbegin(); it != buy.rend();
       ++it) {
    cout << "B " << it->first << " " << it->second << endl;
    i++;
    if (i == s) break;
  }
}
