#include <bits/stdc++.h>
using namespace std;
int q[10001], p[10001];
int q1[100005], p1[100005];
int main() {
  int n, j, i, l, s, k;
  char a[2];
  memset(q1, 0, sizeof(q1));
  memset(p1, 0, sizeof(p1));
  memset(q, 0, sizeof(q));
  memset(p, 0, sizeof(p));
  scanf("%d%d", &n, &s);
  i = 0;
  j = 0;
  while (n--) {
    scanf("%s %d %d", a, &l, &k);
    if (a[0] == 'S') {
      q[i++] = l;
      q1[l] += k;
    } else {
      p[j++] = l;
      p1[l] += k;
    }
  }
  sort(q, q + i);
  sort(p, p + j);
  int l1 = 0, l2 = 0;
  q[i] = -1;
  p[j] = -1;
  for (l = 0; l < i; l++)
    if (q[l] != q[l + 1]) q[l1++] = q[l];
  for (l = 0; l < j; l++)
    if (p[l] != p[l + 1]) p[l2++] = p[l];
  if (l1 > s)
    i = s;
  else
    i = l1;
  for (i--; i >= 0; i--) {
    printf("S %d %d\n", q[i], q1[q[i]]);
  }
  for (l = l2 - 1, i = 0; l >= 0 && i < s; l--, i++) {
    printf("B %d %d\n", p[l], p1[p[l]]);
  }
}
