#include <bits/stdc++.h>
using namespace std;
map<int, long> b, sl, tmp;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, s;
  cin >> n >> s;
  char c;
  for (int i = 0; i < n; i++) {
    int p, q;
    cin >> c >> p >> q;
    if (c == 'B')
      b[-p] += q;
    else
      sl[p] += q;
  }
  map<int, long>::iterator it;
  int i = 0;
  for (it = sl.begin(); it != sl.end() && i < s; i++, it++)
    tmp[-(it->first)] = it->second;
  for (it = tmp.begin(); it != tmp.end(); it++)
    cout << 'S' << " " << -(it->first) << " " << it->second << '\n';
  i = 0;
  for (it = b.begin(); it != b.end() && i < s; i++, it++)
    cout << 'B' << " " << -(it->first) << " " << it->second << '\n';
  return 0;
}
