#include <bits/stdc++.h>
using namespace std;
int n, s;
map<int, int> Mb, Ms;
vector<pair<int, int> > vec;
int main() {
  while (~scanf("%d%d", &n, &s)) {
    Mb.clear(), Ms.clear(), vec.clear();
    char ss[3];
    int p, q;
    for (int i = 1; i <= n; i++) {
      scanf("%s%d%d", ss, &p, &q);
      if (ss[0] == 'B')
        Mb[p] += q;
      else if (ss[0] == 'S')
        Ms[p] += q;
    }
    int t = 0;
    for (map<int, int>::iterator ri = Ms.begin(); ri != Ms.end(); ri++) {
      vec.push_back(make_pair(ri->first, ri->second));
      if (++t >= s) break;
    }
    for (int i = vec.size() - 1; i >= 0; i--)
      printf("S %d %d\n", vec[i].first, vec[i].second);
    t = 0;
    for (map<int, int>::reverse_iterator ri = Mb.rbegin(); ri != Mb.rend();
         ri++) {
      printf("B %d %d\n", ri->first, ri->second);
      if (++t >= s) break;
    }
  }
  return 0;
}
