#include <bits/stdc++.h>
using namespace std;
int size;
int n;
int p;
char d;
int q;
int s;
map<int, int, greater<int> > sell, buy;
map<int, int, greater<int> >::iterator itr;
int main() {
  scanf("%d%d", &n, &s);
  for (int i = 0; i < n; i++) {
    scanf(" %c", &d);
    scanf("%d%d", &p, &q);
    if (d == 'S') {
      sell[p] += q;
    } else if (d == 'B') {
      buy[p] += q;
    }
  }
  itr = sell.begin();
  size = sell.size();
  for (int i = 0; itr != sell.end(); i++) {
    if (size - s <= i) {
      printf("S %d %d\n", itr->first, itr->second);
    }
    itr++;
  }
  itr = buy.begin();
  for (int i = 0; itr != buy.end() && i < s; i++) {
    printf("B %d %d\n", itr->first, itr->second);
    itr++;
  }
}
