#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000;
const int INF = 0x7fffffff;
const int MOD = 1000 * 1000 * 1000 + 7;
long long by[MAXN + 17] = {0}, sl[MAXN + 17] = {0};
int main() {
  int n, s;
  cin >> n >> s;
  for (int i = 0; i < n; ++i) {
    char cmd;
    int p, q;
    cin >> cmd >> p >> q;
    if (cmd == 'B')
      by[p] += q;
    else
      sl[p] += q;
  }
  int time = s;
  queue<pair<int, int> > q;
  for (int i = MAXN + 16; i >= 0; i--) {
    if (sl[i] > 0) {
      q.push(make_pair(i, sl[i]));
    }
  }
  while (q.size() > s) {
    q.pop();
  }
  while (!q.empty()) {
    cout << "S " << q.front().first << " " << q.front().second << endl;
    q.pop();
  }
  time = s;
  for (int i = MAXN + 16; i >= 0 && time > 0; i--) {
    if (by[i] > 0) {
      cout << "B"
           << " " << i << " " << by[i] << endl;
      time--;
    }
  }
  return 0;
}
