#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
int N, S;
int main(void) {
  cin >> N >> S;
  map<int, int> mab, mas;
  for (int i = 0; i < (int)(N); ++i) {
    char d;
    int p, q;
    cin >> d >> p >> q;
    if (d == 'B')
      mab[p] += q;
    else
      mas[p] += q;
  }
  vector<pair<int, int> > vs, vb;
  for (auto p : mab) vb.push_back(p);
  for (auto p : mas) vs.push_back(p);
  sort(vb.begin(), vb.end());
  sort(vs.begin(), vs.end());
  reverse(vb.begin(), vb.end());
  for (int i = min((int)vs.size(), S) - 1; i >= 0; i--)
    cout << "S " << vs[i].first << " " << vs[i].second << endl;
  for (int i = 0; i < (int)(min((int)vb.size(), S)); ++i)
    cout << "B " << vb[i].first << " " << vb[i].second << endl;
  return 0;
}
