#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s, i, count, x, y, min = 0;
  char c;
  cin >> n >> s;
  count = s;
  int buy[100001], sell[100001];
  memset(buy, 0, sizeof(buy));
  memset(sell, 0, sizeof(sell));
  for (i = 0; i < n; i++) {
    cin >> c;
    cin >> x >> y;
    if (c == 'B') {
      buy[x] += y;
    } else
      sell[x] += y;
  }
  for (i = 0; i < 100001; i++) {
    if (!count) break;
    if (sell[i]) count--, min = i;
  }
  count = s;
  for (i = min; i >= 0; i--) {
    if (!count) break;
    if ((sell[i])) cout << 'S' << " " << i << " " << sell[i] << endl, count--;
  }
  count = s;
  for (i = 100000; i >= 0; i--) {
    if (!count) break;
    if ((buy[i])) cout << 'B' << " " << i << " " << buy[i] << endl, count--;
  }
  return 0;
}
