#include <bits/stdc++.h>
using namespace std;
int main() {
  map<int, int> B, S;
  int n, s;
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    string side;
    cin >> side;
    int p, q;
    cin >> p >> q;
    if (side == "B") {
      B[p] += q;
    } else {
      S[p] += q;
    }
  }
  vector<pair<int, int> > buy, sell;
  for (auto it : B) buy.push_back({it.first, it.second});
  for (auto it : S) sell.push_back({it.first, it.second});
  sort(buy.begin(), buy.end(),
       [](const pair<int, int>& a, const pair<int, int>& b) {
         return a.first > b.first;
       });
  sort(sell.begin(), sell.end(),
       [](const pair<int, int>& a, const pair<int, int>& b) {
         return a.first < b.first;
       });
  vector<int> fin;
  for (int i = 0; i < s && i < sell.size(); i++) {
    fin.push_back(i);
  }
  for (int i = fin.size() - 1; i >= 0; i--) {
    printf("S %d %d\n", sell[i].first, sell[i].second);
  }
  for (int i = 0; i < s && i < buy.size(); i++) {
    printf("B %d %d\n", buy[i].first, buy[i].second);
  }
}
