#include <bits/stdc++.h>
using namespace std;
struct ss {
  int p, q;
} nodeb[1005], nodes[1005], node[1005], node1[1005];
bool cmp1(ss a, ss b) { return a.p > b.p; }
bool cmp2(ss a, ss b) { return a.p < b.p; }
int main() {
  int n, s;
  int tot = 0, tot1 = 0;
  scanf("%d%d", &n, &s);
  getchar();
  int cntb = 0, cnts = 0;
  for (int i = 0; i < n; i++) {
    char ch;
    int x, y;
    scanf("%c%d%d", &ch, &x, &y);
    getchar();
    if (ch == 'B') {
      nodeb[cntb].p = x;
      nodeb[cntb++].q = y;
    } else {
      nodes[cnts].p = x;
      nodes[cnts++].q = y;
    }
  }
  sort(nodeb, nodeb + cntb, cmp1);
  sort(nodes, nodes + cnts, cmp2);
  int ans = nodes[0].q;
  int flag = 0;
  for (int i = 0; i < cnts; i++) {
    if (nodes[i].p == nodes[i + 1].p && i + 1 < cnts) {
      ans += nodes[i + 1].q;
    } else {
      node1[tot1].p = nodes[i].p, node1[tot1++].q = ans;
      ans = nodes[i + 1].q;
      flag++;
    }
    if (flag == s) break;
  }
  ans = nodeb[0].q;
  flag = 0;
  for (int i = 0; i < cntb; i++) {
    if (nodeb[i].p == nodeb[i + 1].p && i + 1 < cntb) {
      ans += nodeb[i + 1].q;
    } else {
      node[tot].p = nodeb[i].p, node[tot++].q = ans;
      ans = nodeb[i + 1].q;
      flag++;
    }
    if (flag == s) break;
  }
  for (int i = tot1 - 1; i >= 0; i--) {
    printf("S %d %d\n", node1[i].p, node1[i].q);
  }
  for (int i = 0; i < tot; i++) {
    printf("B %d %d\n", node[i].p, node[i].q);
  }
  return 0;
}
