#include <bits/stdc++.h>
using namespace std;
map<int, int> bu, se;
int main() {
  int n, s;
  cin >> n >> s;
  char a;
  int b, c;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    if (a == 'B')
      bu[b] += c;
    else
      se[b] += c;
  }
  vector<pair<int, int> > hi1, hi2;
  for (auto x : bu) hi1.push_back({x.first, x.second});
  for (auto x : se) hi2.push_back({x.first, x.second});
  sort(hi1.begin(), hi1.end(), greater<pair<int, int> >());
  sort(hi2.begin(), hi2.end());
  int yo1 = hi1.size(), yo2 = hi2.size();
  vector<pair<int, int> > vi1, vi2;
  for (int i = 0; i < min(yo1, s); i++) vi1.push_back(hi1[i]);
  for (int i = 0; i < min(yo2, s); i++) vi2.push_back(hi2[i]);
  sort(vi1.begin(), vi1.end(), greater<pair<int, int> >());
  sort(vi2.begin(), vi2.end(), greater<pair<int, int> >());
  for (int i = 0; i < vi2.size(); i++)
    cout << "S " << vi2[i].first << " " << vi2[i].second << '\n';
  for (int i = 0; i < vi1.size(); i++)
    cout << "B " << vi1[i].first << " " << vi1[i].second << '\n';
  return 0;
}
