#include <bits/stdc++.h>
using namespace std;
int n, m, ta, tb;
char x[10];
map<int, int> y[2];
map<int, int>::iterator it;
int main() {
  scanf("%d%d", &n, &m);
  while (n--) {
    scanf("%s%d%d", x, &ta, &tb);
    y[x[0] == 'B'][ta] += tb;
  }
  it = y[0].begin();
  for (int a = 0; a < m; a++)
    if (it != y[0].end()) it++;
  while (1) {
    if (it != y[0].begin())
      it--;
    else
      break;
    printf("S %d %d\n", it->first, it->second);
  }
  it = y[1].end();
  for (int a = 0; a < m; a++) {
    if (it != y[1].begin())
      it--;
    else
      break;
    printf("B %d %d\n", it->first, it->second);
  }
  return 0;
}
