#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<int> p, q;
vector<char> d;
int main() {
  cin >> n >> k;
  p.resize(n);
  q.resize(n);
  d.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i] >> p[i] >> q[i];
  }
  map<int, int> b, s;
  for (int i = 0; i < n; i++) {
    if (d[i] == 'S') {
      if (s.find(p[i]) == s.end())
        s[p[i]] = q[i];
      else
        s[p[i]] += q[i];
    } else {
      if (b.find(-p[i]) == b.end())
        b[-p[i]] = q[i];
      else
        b[-p[i]] += q[i];
    }
  }
  int cnt = s.size();
  for (map<int, int>::reverse_iterator it = s.rbegin(); it != s.rend(); it++) {
    if (cnt <= k) {
      cout << "S " << it->first << " " << it->second << "\n";
    }
    cnt--;
  }
  cnt = 0;
  for (map<int, int>::iterator it = b.begin(); it != b.end(); it++) {
    if (cnt < k) {
      cout << "B " << -it->first << " " << it->second << "\n";
    } else
      break;
    cnt++;
  }
  cin >> n;
  return 0;
}
