#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  long long int n, s, p, q;
  char d;
  map<long long int, long long int> p1, p2;
  cin >> n >> s;
  for (long long int i = 1; i <= n; i++) {
    cin >> d >> p >> q;
    if (d == 'B')
      p1[p] += q;
    else if (d == 'S')
      p2[p] += q;
  }
  map<long long int, long long int>::reverse_iterator rit;
  map<long long int, long long int>::iterator it;
  vector<pair<long long int, long long int> > p3;
  long long int cnt = 0;
  for (it = p2.begin(); it != p2.end(); it++) {
    if (cnt < s) {
      p3.push_back(make_pair(it->first, it->second));
      cnt++;
    }
  }
  cnt = 0;
  reverse(p3.begin(), p3.end());
  vector<pair<long long int, long long int> >::iterator it2;
  for (it2 = p3.begin(); it2 != p3.end(); ++it2) {
    if (cnt < s) {
      cout << "S"
           << " " << it2->first << " " << it2->second << endl;
      cnt++;
    }
  }
  cnt = 0;
  for (rit = p1.rbegin(); rit != p1.rend(); ++rit) {
    if (cnt < s) {
      cout << "B"
           << " " << rit->first << " " << rit->second << endl;
      cnt++;
    }
  }
  return 0;
}
