#include <bits/stdc++.h>
using namespace std;
bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
  if (b.first == a.first) {
    return (a.second > b.second);
  }
  return (a.first > b.first);
}
int main() {
  int n, i, j, k;
  vector<pair<int, int> > s, b;
  scanf("%d%d", &n, &k);
  char d;
  int p, q;
  for (i = 0; i < n; i++) {
    getchar();
    scanf("%c%d%d", &d, &p, &q);
    if (d == 'B') {
      b.push_back(make_pair(p, q));
    } else {
      s.push_back(make_pair(p, q));
    }
  }
  sort(s.begin(), s.end());
  sort(b.begin(), b.end(), cmp);
  vector<pair<int, int> > dh3, dh;
  for (i = 0; i < s.size();) {
    int Q = s[i].second;
    j = i + 1;
    while (j < s.size() && s[i].first == s[j].first) {
      Q += s[j].second;
      j++;
    }
    dh3.push_back(make_pair(s[i].first, Q));
    if (dh3.size() == k) break;
    i = j;
  }
  for (i = 0; i < b.size();) {
    int Q = b[i].second;
    j = i + 1;
    while (j < b.size() && b[i].first == b[j].first) {
      Q += b[j].second;
      j++;
    }
    dh.push_back(make_pair(b[i].first, Q));
    if (dh.size() == k) break;
    i = j;
  }
  for (i = dh3.size() - 1; i >= 0; i--) {
    printf("S %d %d\n", dh3[i].first, dh3[i].second);
  }
  for (i = 0; i < dh.size(); i++) {
    printf("B %d %d\n", dh[i].first, dh[i].second);
  }
  return 0;
}
