#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, s;
  map<long long, long long> B, S;
  cin >> n >> s;
  while (n--) {
    long long p, q;
    char c;
    cin >> c >> p >> q;
    if (c == 'B')
      B[p] += q;
    else {
      S[p] += q;
    }
  }
  int i = 1, j = 1;
  vector<pair<int, int> > AS;
  map<long long, long long>::iterator it = S.begin();
  while (i <= s && it != S.end()) {
    AS.push_back(make_pair(it->first, it->second));
    it++;
    i++;
  }
  for (int i = AS.size() - 1; i >= 0; i--) {
    cout << "S " << AS[i].first << " " << AS[i].second << endl;
  }
  for (map<long long, long long>::reverse_iterator it2 = B.rbegin();
       it2 != B.rend(); it2++) {
    if (j > s) break;
    cout << "B " << it2->first << " " << it2->second << endl;
    j++;
  }
  return 0;
}
