#include <bits/stdc++.h>
using namespace std;
int by[100005], sl[100005];
int main() {
  int n, m, i, j, p, k, q;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    char ch;
    cin >> ch >> p >> q;
    if (ch == 'B')
      by[p] += q;
    else
      sl[p] += q;
  }
  int bm = m, sm = m;
  vector<int> vt;
  for (i = 0; i <= 100000; i++) {
    if (sl[i] > 0) {
      sm--;
      vt.push_back(i);
    }
    if (sm == 0) break;
  }
  for (i = vt.size() - 1; i >= 0; i--) {
    cout << "S " << vt[i] << " " << sl[vt[i]] << "\n";
  }
  for (i = 100000; i >= 0; i--) {
    if (by[i] > 0) {
      bm--;
      cout << "B " << i << " " << by[i] << "\n";
    }
    if (bm == 0) break;
  }
  return 0;
}
