#include <bits/stdc++.h>
using namespace std;
int n, M, i, tip, p, v, cnt;
int m[2][100010];
int main() {
  scanf("%d %d\n", &n, &M);
  for (i = 1; i <= n; ++i) {
    scanf("%c %d %d\n", &tip, &p, &v);
    if (tip == 'S')
      m[1][p] += v;
    else
      m[0][p] += v;
  }
  cnt = 0;
  for (i = 0; i <= 100000; ++i) {
    if (m[1][i] != 0) cnt++;
    if (cnt == M) break;
  }
  for (; i >= 0; --i)
    if (m[1][i] != 0) printf("S %d %d\n", i, m[1][i]);
  cnt = 0;
  for (i = 100000; i >= 0; --i)
    if (m[0][i] != 0) {
      cnt++;
      printf("B %d %d\n", i, m[0][i]);
      if (cnt == M) break;
    }
  return 0;
}
