#include <bits/stdc++.h>
using namespace std;
inline void prin(int n) { printf("%d\n", n); }
int main() {
  int n, s, a, b;
  map<int, int> B, S;
  vector<pair<int, int> > b1, s1;
  cin >> n >> s;
  char ch;
  for (int i = 0; i < (int)(n); ++i) {
    cin >> ch >> a >> b;
    if (ch == 'B')
      B[a] += b;
    else
      S[a] += b;
  }
  for (auto x : B) b1.push_back(make_pair(x.first, x.second));
  for (auto x : S) s1.push_back(make_pair(x.first, x.second));
  for (int i = min(s - 1, ((int)((s1).size())) - 1); i >= 0; i--)
    cout << "S " << s1[i].first << " " << s1[i].second << endl;
  for (int i = ((int)((b1).size())) - 1; i >= 0 && s; i--, s--)
    cout << "B " << b1[i].first << " " << b1[i].second << endl;
}
