#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int sold[maxn];
int buy[maxn];
stack<int> pp;
int main() {
  int i, n;
  int s;
  cin >> n >> s;
  for (i = 0; i < maxn; i++) {
    sold[i] = -1;
    buy[i] = -1;
  }
  for (i = 0; i < n; i++) {
    char ch;
    int p;
    int q;
    cin >> ch >> p >> q;
    if (ch == 'B') {
      if (buy[p] == -1) {
        buy[p] = q;
      } else
        buy[p] += q;
    } else {
      if (sold[p] == -1) {
        sold[p] = q;
      } else
        sold[p] += q;
    }
  }
  int total = 0;
  for (i = 0; i < maxn; i++) {
    if (sold[i] != -1) {
      total++;
      pp.push(i);
      if (total == s) break;
    }
  }
  while (!pp.empty()) {
    cout << "S " << pp.top() << " " << sold[pp.top()] << endl;
    pp.pop();
  }
  total = 0;
  for (i = maxn - 1; i >= 0; i--) {
    if (buy[i] != -1) {
      total++;
      cout << "B " << i << " " << buy[i] << endl;
      if (total == s) break;
    }
  }
  return 0;
}
