#include <bits/stdc++.h>
struct order {
  int price;
  int quality;
};
int compare(const void *a, const void *b) {
  return ((struct order *)a)->price - ((struct order *)b)->price;
}
void sort(struct order a[], int size) {
  qsort(a, size, sizeof(struct order), compare);
}
int main() {
  int n, s;
  scanf("%d%d", &n, &s);
  struct order buy[1000];
  struct order sell[1000];
  int nb = 0;
  int ns = 0;
  int i, j;
  for (i = 0; i < n; i++) {
    getchar();
    char d = getchar();
    if (d == 'B') {
      scanf("%d%d", &(buy[nb].price), &(buy[nb].quality));
      nb++;
    } else if (d == 'S') {
      scanf("%d%d", &(sell[ns].price), &(sell[ns].quality));
      ns++;
    } else {
      printf("读入数据出现了问题\n");
      return 1;
    }
  }
  struct order aggregated_buy[1000];
  int nnb = 0;
  for (i = 0; i < nb; i++) {
    if (buy[i].price >= 0) {
      int sum = buy[i].quality;
      for (j = i + 1; j < nb; j++) {
        if (buy[i].price == buy[j].price) {
          sum += buy[j].quality;
          buy[j].price = (-1);
        }
      }
      aggregated_buy[nnb].price = buy[i].price;
      aggregated_buy[nnb].quality = sum;
      nnb++;
    }
  }
  struct order aggregated_sell[1000];
  int nns = 0;
  for (i = 0; i < ns; i++) {
    if (sell[i].price >= 0) {
      int sum = sell[i].quality;
      for (j = i + 1; j < ns; j++) {
        if (sell[i].price == sell[j].price) {
          sum += sell[j].quality;
          sell[j].price = (-1);
        }
      }
      aggregated_sell[nns].price = sell[i].price;
      aggregated_sell[nns].quality = sum;
      nns++;
    }
  }
  sort(aggregated_sell, nns);
  int start = s - 1;
  if (nns < s) start = nns - 1;
  for (i = start; i >= 0; i--) {
    printf("S %d %d\n", aggregated_sell[i].price, aggregated_sell[i].quality);
  }
  start = nnb - 1;
  int end = nnb - s;
  if (nnb < s) {
    start = nnb - 1;
    end = 0;
  }
  sort(aggregated_buy, nnb);
  for (i = start; i >= end; i--) {
    printf("B %d %d\n", aggregated_buy[i].price, aggregated_buy[i].quality);
  }
  return 0;
}
