#include <bits/stdc++.h>
using namespace std;
int dpp[100001], dps[100001];
int main() {
  int n, s;
  cin >> n >> s;
  vector<pair<int, int> > buy, sell;
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    if (c == 'B') {
      int p, b;
      cin >> p >> b;
      dpp[p] += b;
    } else {
      int p, b;
      cin >> p >> b;
      dps[p] += b;
    }
  }
  for (int i = 0; i <= 100000; i++) {
    if (dpp[i]) buy.push_back({i, dpp[i]});
    if (dps[i]) sell.push_back({i, dps[i]});
  }
  sort(buy.rbegin(), buy.rend());
  sort(sell.rbegin(), sell.rend());
  for (int i = max(0, (int)sell.size() - s); i < sell.size(); i++) {
    cout << "S " << sell[i].first << " " << sell[i].second << "\n";
  }
  for (int i = 0; i < s; i++) {
    if (i >= buy.size()) break;
    cout << "B " << buy[i].first << " " << buy[i].second << "\n";
  }
}
