#include <bits/stdc++.h>
using namespace std;
const int maxm = 1e3 + 5;
typedef struct {
  char c = '\0';
  int a = 0;
  int b = 0;
} sss;
typedef struct {
  char c = '\0';
  int a = 0;
  int b = 0;
} bbb;
sss st[maxm];
bbb bt[maxm];
int n, m;
int numb, nums;
int cmps(sss s1, sss s2) { return s1.a <= s2.a; }
int cmpb(bbb b1, bbb b2) { return b1.a >= b2.a; }
int isinb(int aa, int bb) {
  for (int i = 0; i < numb; i++) {
    if (bt[i].a == aa) {
      bt[i].b += bb;
      return 1;
    }
  }
  return 0;
}
int isins(int aa, int bb) {
  for (int i = 0; i < nums; i++) {
    if (st[i].a == aa) {
      st[i].b += bb;
      return 1;
    }
  }
  return 0;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    char c[5];
    int x, y;
    scanf("%s%d%d", c, &x, &y);
    if (c[0] == 'B') {
      if (isinb(x, y)) {
        continue;
      } else {
        bt[numb].c = 'B';
        bt[numb].a = x;
        bt[numb].b = y;
        numb++;
      }
    } else if (c[0] == 'S') {
      if (isins(x, y)) {
        continue;
      } else {
        st[nums].c = 'S';
        st[nums].a = x;
        st[nums].b = y;
        nums++;
      }
    }
  }
  sort(bt, bt + numb, cmpb);
  sort(st, st + nums, cmps);
  if (nums < m) {
    for (int i = nums - 1; i >= 0; i--) {
      printf("S %d %d\n", st[i].a, st[i].b);
    }
  } else {
    for (int j = m - 1; j >= 0; j--) {
      printf("S %d %d\n", st[j].a, st[j].b);
    }
  }
  if (numb < m) {
    for (int i = 0; i < numb; i++) {
      printf("B %d %d\n", bt[i].a, bt[i].b);
    }
  } else {
    for (int j = 0; j < m; j++) {
      printf("B %d %d\n", bt[j].a, bt[j].b);
    }
  }
  return 0;
}
