#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > buy;
vector<pair<int, int> > sell;
int main() {
  int i, j, k, s, n, l, n1, n2, m;
  char ch;
  cin >> n >> s;
  for (i = 0; i < n; i++) {
    cin >> ch >> n1 >> n2;
    if (ch == 'B') {
      int f = 0;
      for (j = 0; j < buy.size(); j++) {
        if (buy[j].first == n1) {
          buy[j].second += n2;
          f = 1;
        }
      }
      if (f == 0) buy.push_back(make_pair(n1, n2));
    } else {
      int f = 0;
      for (j = 0; j < sell.size(); j++) {
        if (sell[j].first == n1) {
          sell[j].second += n2;
          f = 1;
        }
      }
      if (f == 0) sell.push_back(make_pair(n1, n2));
    }
  }
  sort(buy.begin(), buy.end());
  sort(sell.begin(), sell.end());
  int cnt = 0, len;
  if (sell.size() <= s)
    len = sell.size() - 1;
  else
    len = s - 1;
  for (i = len; i >= 0; i--) {
    cout << "S"
         << " " << sell[i].first << " " << sell[i].second << endl;
  }
  cnt = 0;
  for (i = buy.size() - 1; i >= 0; i--) {
    cout << "B"
         << " " << buy[i].first << " " << buy[i].second << endl;
    cnt++;
    if (cnt == s) break;
  }
  return 0;
}
