#include <bits/stdc++.h>
using namespace std;
int flag[100000 + 5], flag2[100000 + 5], n, m, tmp, pos, p, q;
char word[5];
int main() {
  while (~scanf("%d%d", &n, &m)) {
    memset(flag, 0, sizeof flag);
    memset(flag2, 0, sizeof flag2);
    for (int i = 1; i <= n; ++i) {
      scanf("%s%d%d", word, &p, &q);
      if (word[0] == 'S')
        flag[p] += q;
      else
        flag2[p] += q;
    }
    tmp = pos = 0;
    for (int i = 0; i <= 100000 && tmp < m; ++i)
      if (flag[i] > 0) ++tmp, pos = i;
    for (int i = pos; i >= 0; --i)
      if (flag[i] > 0) printf("S %d %d\n", i, flag[i]);
    tmp = 0;
    for (int i = 100000; i >= 0 && tmp < m; --i)
      if (flag2[i] > 0) {
        printf("B %d %d\n", i, flag2[i]);
        ++tmp;
      }
  }
  return 0;
}
