#include <bits/stdc++.h>
using namespace std;
map<int, int> b, s;
vector<pair<int, int> > b1, s1;
int main() {
  ios_base::sync_with_stdio(0);
  int n, ss;
  cin >> n >> ss;
  char com;
  int d, p;
  for (int i = 0; i < n; ++i) {
    cin >> com >> d >> p;
    if (com == 'S')
      s[d] += p;
    else
      b[d] += p;
  }
  for (auto i = b.begin(); i != b.end(); i++)
    b1.push_back(make_pair(i->first, i->second));
  for (auto i = s.begin(); i != s.end(); i++)
    s1.push_back(make_pair(i->first, i->second));
  if (ss < s1.size()) {
    for (int i = ss - 1; i >= 0; --i) {
      cout << "S " << s1[i].first << " " << s1[i].second << "\n";
    }
  } else {
    for (int i = s1.size() - 1; i >= 0; --i) {
      cout << "S " << s1[i].first << " " << s1[i].second << "\n";
    }
  }
  if (ss < b1.size()) {
    for (int i = b1.size() - 1; i >= b1.size() - ss; --i) {
      cout << "B " << b1[i].first << " " << b1[i].second << "\n";
    }
  } else {
    for (int i = b1.size() - 1; i >= 0; --i) {
      cout << "B " << b1[i].first << " " << b1[i].second << "\n";
    }
  }
  return 0;
}
