#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > v;
struct node {
  string dir;
  long long price, vol;
} book[1005], l[1005];
int chk[1002];
bool cmp(node i, node j) { return i.dir > j.dir; }
bool cmp2(node i, node j) {
  if (i.dir == "S" && j.dir == "S")
    return i.price > j.price;
  else if (i.dir == "B" && j.dir == "B")
    return i.price > j.price;
  else
    return i.dir > j.dir;
}
int main() {
  int n, s;
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    cin >> book[i].dir >> book[i].price >> book[i].vol;
  }
  int len = 0;
  for (int i = 0; i < n; i++) {
    long long sum = book[i].vol;
    for (int j = i + 1; j < n; j++) {
      if (i == j) continue;
      if (book[i].dir == book[j].dir && book[i].price == book[j].price &&
          chk[j] == 0) {
        sum += book[j].vol;
        chk[j] = 1;
      }
    }
    if (chk[i] == 0) {
      l[len].dir = book[i].dir;
      l[len].price = book[i].price;
      l[len].vol = sum;
      len++;
    }
  }
  sort(l, l + len, cmp);
  sort(l, l + len, cmp2);
  int buy = 0, sell = 0;
  for (int i = 0; i < len; i++) {
    if (l[i].dir == "B") buy++;
    if (l[i].dir == "S") sell++;
  }
  int k = 0, p = 0;
  for (int i = 0; i < len; i++) {
    if (l[i].dir == "S") {
      if (sell <= s)
        cout << l[i].dir << " " << l[i].price << " " << l[i].vol << endl;
      sell--;
    }
    if (l[i].dir == "B") {
      if (k < s)
        cout << l[i].dir << " " << l[i].price << " " << l[i].vol << endl;
      k++;
    }
  }
  return 0;
}
