#include <bits/stdc++.h>
const int maxn = 1e5;
using namespace std;
int n, s, x, y, z;
int sp[maxn + 5], bp[maxn + 5];
int S[maxn + 5], Scnt;
char op[3];
int main() {
  scanf("%d%d", &n, &s);
  for (int i = 1; i <= n; i++) {
    scanf("%s%d%d", op, &x, &y);
    if (op[0] == 'S') {
      sp[x] += y;
    } else if (op[0] == 'B') {
      bp[x] += y;
    }
  }
  int scnt = 0, bcnt = 0;
  for (int i = 1; i <= maxn && scnt < s; i++) {
    if (sp[i]) S[++scnt] = i;
  }
  for (int i = scnt; i >= 1; i--) printf("S %d %d\n", S[i], sp[S[i]]);
  for (int i = maxn; i >= 0 && bcnt < s; i--) {
    if (bp[i]) printf("B %d %d\n", i, bp[i]), bcnt++;
  }
}
