#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s;
  cin >> n >> s;
  map<int, int> by, sl;
  for (int i = 0; i < n; i++) {
    int p, q;
    char a;
    cin >> a >> p >> q;
    if (a == 'B') {
      by[p] += q;
    } else
      sl[p] += q;
  }
  int cnt = 0;
  while (sl.size() > s) {
    auto it = sl.end();
    it--;
    sl.erase(it);
  }
  if (!sl.empty()) {
    auto it = sl.end();
    it--;
    while (it != sl.begin()) {
      cout << "S " << it->first << " " << it->second << endl;
      it--;
    }
    cout << "S " << it->first << " " << it->second << endl;
  }
  if (!by.empty()) {
    auto it = by.end();
    it--;
    while (cnt != s && it != by.begin()) {
      cout << "B"
           << " " << it->first << " " << it->second << endl;
      cnt++;
      it--;
    }
    if (cnt != s) cout << "B " << it->first << " " << it->second;
  }
}
