#include <bits/stdc++.h>
using namespace std;
template <class T>
T POW(T x, T y) {
  T ret = 1;
  while (y--) {
    ret *= x;
  }
  return ret;
}
template <class T>
inline bool EQUAL(T x, T y) {
  if (fabs(x - y) < 1e-9) return true;
  return false;
}
struct Data {
  int p, q;
} buy[1004], buy2[1004], sell[1004], sell2[1004];
bool cmp(Data a, Data b) { return a.p < b.p; }
bool cmp2(Data a, Data b) { return a.p > b.p; }
int main() {
  int n, s, pi, qi, mn;
  char di;
  cin >> n >> s;
  int bb = 0, ss = 0;
  for (int i = 0; i < n; i++) {
    cin >> di >> pi >> qi;
    if (di == 'B') {
      buy[bb].p = pi;
      buy[bb].q = qi;
      bb++;
    }
    if (di == 'S') {
      sell[ss].p = pi;
      sell[ss].q = qi;
      ss++;
    }
  }
  sort(buy, buy + bb, cmp2);
  sort(sell, sell + ss, cmp);
  int idx;
  if (ss) {
    idx = 1;
    sell2[0] = sell[0];
    for (int i = 1; i < ss; i++) {
      if (sell[i].p == sell2[idx - 1].p)
        sell2[idx - 1].q += sell[i].q;
      else {
        sell2[idx] = sell[i];
        idx++;
      }
    }
    mn = min(s, idx);
    sort(sell2, sell2 + mn, cmp2);
    for (int i = 0; i < mn; i++) printf("S %d %d\n", sell2[i].p, sell2[i].q);
  }
  if (bb) {
    idx = 1;
    buy2[0] = buy[0];
    for (int i = 1; i < bb; i++) {
      if (buy[i].p == buy2[idx - 1].p)
        buy2[idx - 1].q += buy[i].q;
      else {
        buy2[idx] = buy[i];
        idx++;
      }
    }
    mn = min(s, idx);
    for (int i = 0; i < mn; i++) printf("B %d %d\n", buy2[i].p, buy2[i].q);
  }
  return 0;
}
