#include <bits/stdc++.h>
using namespace std;
int b[100005], s[100005];
int main() {
  for (int i = 0; i < 100005; i++) b[i] = s[i] = 0;
  int n, S;
  scanf("%d %d", &n, &S);
  int p, q;
  char d;
  for (int i = 0; i < n; i++) {
    scanf(" %c %d %d", &d, &p, &q);
    if (d == 'B')
      b[p] += q;
    else
      s[p] += q;
  }
  int k = 0, j = 0;
  pair<int, int> buy[1003], sell[1003];
  for (int i = 0; i < 100005; i++) {
    if (b[i]) buy[k++] = make_pair(-i, b[i]);
    if (s[i]) sell[j++] = make_pair(i, s[i]);
  }
  sort(buy, buy + k);
  sort(sell, sell + j);
  int t = min(j, S);
  for (int i = 0; i < t; i++) sell[i].first = -sell[i].first;
  sort(sell, sell + t);
  for (int i = 0; i < t; i++)
    printf("S %d %d\n", -sell[i].first, sell[i].second);
  t = min(k, S);
  for (int i = 0; i < t; i++) printf("B %d %d\n", -buy[i].first, buy[i].second);
}
