#include <bits/stdc++.h>
using namespace std;
int n, s;
vector<vector<int> > aggregate;
vector<int> sell, buy;
int main() {
  cin >> n >> s;
  aggregate.resize(2);
  aggregate[0].resize(100001);
  aggregate[1].resize(100001);
  for (int i = 0; i < n; i++) {
    char direction;
    int price, q, newdir;
    cin >> direction >> price >> q;
    if (direction == 'B') {
      newdir = 0;
      buy.push_back(price);
    } else if (direction == 'S') {
      newdir = 1;
      sell.push_back(price);
    }
    aggregate[newdir][price] += q;
  }
  sort(buy.begin(), buy.end());
  buy.erase(unique(buy.begin(), buy.end()), buy.end());
  sort(sell.begin(), sell.end());
  sell.erase(unique(sell.begin(), sell.end()), sell.end());
  for (int i = 1; i <= s; i++) {
    if (s - i < sell.size())
      cout << 'S' << " " << sell[s - i] << " " << aggregate[1][sell[s - i]]
           << endl;
  }
  for (int i = 0; i < s && i < buy.size(); i++) {
    if (buy.size() - i - 1 >= 0)
      cout << 'B' << " " << buy[buy.size() - i - 1] << " "
           << aggregate[0][buy[buy.size() - i - 1]] << endl;
  }
  return 0;
}
