#include <bits/stdc++.h>
const double eps = 1e-8;
const int MAXN = (int)1e9 + 5;
using namespace std;
int main(int argc, char const *argv[]) {
  int n, s;
  cin >> n >> s;
  std::map<int, int> sell, buy;
  for (int i = 0; i < n; i++) {
    char dir[3];
    int price, cnt;
    cin >> dir >> price >> cnt;
    if (dir[0] == 'B')
      buy[price] += cnt;
    else
      sell[price] += cnt;
  }
  std::vector<pair<int, int> > res;
  if (sell.size() < s) {
    for (auto i : sell) {
      res.push_back({i.first, i.second});
    }
  } else {
    int cnt = s;
    for (auto i : sell) {
      res.push_back({i.first, i.second});
      cnt--;
      if (cnt == 0) break;
    }
  }
  for (int i = res.size() - 1; i >= 0; i--) {
    printf("S %d %d\n", res[i].first, res[i].second);
  }
  if (buy.size() < s) {
    for (std::map<int, int>::reverse_iterator it = buy.rbegin();
         it != buy.rend(); it++) {
      printf("%c %d %d\n", 'B', it->first, it->second);
    }
  } else {
    int cnt = s;
    for (std::map<int, int>::reverse_iterator it = buy.rbegin(); cnt;
         it++, cnt--) {
      printf("%c %d %d\n", 'B', it->first, it->second);
    }
  }
  return 0;
}
