#include <bits/stdc++.h>
using namespace std;
int cmp(pair<int, int> A, pair<int, int> B) { return A.first > B.first; }
int main() {
  int n, m;
  cin >> n >> m;
  map<long long, long long> S, B;
  for (int i = 0; i < n; i++) {
    char c;
    int p, q;
    cin >> c >> p >> q;
    if (c == 'S') {
      S[p] += q;
    } else
      B[p] += q;
  }
  int t = m;
  map<long long, long long>::iterator it;
  vector<pair<int, int> > X, Y;
  for (it = S.begin(); it != S.end(); ++it) {
    X.push_back(pair<int, int>(it->first, it->second));
  }
  t = m;
  for (it = B.begin(); it != B.end(); ++it) {
    Y.push_back(pair<int, int>(it->first, it->second));
  }
  sort((X).begin(), (X).end(), cmp);
  sort((Y).begin(), (Y).end(), cmp);
  for (int i = max(0, (int)X.size() - t); t-- && i < (int)X.size(); i++) {
    cout << "S " << X[i].first << " " << X[i].second << "\n";
  }
  t = m;
  for (int i = 0; t-- && i < (int)Y.size(); i++) {
    cout << "B " << Y[i].first << " " << Y[i].second << "\n";
  }
}
