#include <bits/stdc++.h>
using namespace std;
int cnt[2][100001];
stack<int> print;
int main() {
  int n, s, pr, vol, max1 = 0, min1 = 1000000, i, stock;
  char sign;
  cin >> n >> s;
  for (i = 0; i < n; i++) {
    cin >> sign >> pr >> vol;
    if (sign == 'B') {
      cnt[0][pr] += vol;
      max1 = max(max1, pr);
    }
    if (sign == 'S') {
      cnt[1][pr] += vol;
      min1 = min(min1, pr);
    }
  }
  stock = 0;
  for (i = min1; i <= 100000; i++) {
    if (stock == s) break;
    if (cnt[1][i] == 0) continue;
    stock++;
    print.push(i);
  }
  for (;;) {
    if (print.empty() == 1) break;
    printf("S %d %d\n", print.top(), cnt[1][print.top()]);
    print.pop();
  }
  stock = 0;
  for (i = max1; i >= 0; i--) {
    if (stock == s) break;
    if (cnt[0][i] == 0) continue;
    stock++;
    printf("B %d %d\n", i, cnt[0][i]);
  }
  return 0;
}
