#include <bits/stdc++.h>
using namespace std;
struct Order {
  int p;
  int q;
  int index;
  Order(int a = 0, int b = 0, int c = 0) {
    p = a;
    q = b;
    index = c;
  }
};
Order b[1001], s[1001];
bool cmp_higher_price(const Order& a, const Order& b) { return a.p > b.p; }
bool cmp_lower_price(const Order& a, const Order& b) { return a.p < b.p; }
bool cmp_index(const Order& a, const Order& b) { return a.index < b.index; }
int main() {
  int n, st, p, q;
  char d;
  scanf("%d %d", &n, &st);
  int i, tb, ts, j;
  tb = ts = 0;
  for (i = 0; i < n; i++) {
    scanf("\n%c %d %d", &d, &p, &q);
    if (d == 'B') {
      for (j = tb - 1; j >= 0; j--) {
        if (b[j].p == p) {
          b[j].q += q;
          break;
        }
      }
      if (j < 0) {
        b[tb] = Order(p, q, tb);
        tb++;
      }
    } else if (d == 'S') {
      for (j = ts - 1; j >= 0; j--) {
        if (s[j].p == p) {
          s[j].q += q;
          break;
        }
      }
      if (j < 0) {
        s[ts] = Order(p, q, ts);
        ts++;
      }
    }
  }
  sort(b, b + tb, cmp_higher_price);
  sort(s, s + ts, cmp_higher_price);
  if (ts <= st) {
    for (i = 0; i < ts; i++) {
      printf("S %d %d\n", s[i].p, s[i].q);
    }
  } else {
    for (i = ts - st; i < ts; i++) {
      printf("S %d %d\n", s[i].p, s[i].q);
    }
  }
  if (tb <= st) {
    for (i = 0; i < tb; i++) {
      printf("B %d %d\n", b[i].p, b[i].q);
    }
  } else {
    for (i = 0; i < st; i++) {
      printf("B %d %d\n", b[i].p, b[i].q);
    }
  }
  return 0;
}
