#include <bits/stdc++.h>
using namespace std;
int a[100005], b[100005];
int n, s;
int main() {
  int p, q, i, k, m;
  char c[1];
  while (scanf("%d %d", &n, &s) != EOF) {
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    for (i = 0; i < n; i++) {
      scanf("%s%d%d", c, &p, &q);
      if (c[0] == 'B')
        a[p] += q;
      else
        b[p] += q;
    }
    k = 0;
    m = 0;
    for (i = 0; i <= 100000; i++) {
      if (b[i] && k < s) {
        k++;
        m = i;
      } else if (k >= s)
        break;
    }
    for (i = m; i >= 0; i--) {
      if (b[i]) {
        printf("S %d %d\n", i, b[i]);
      }
    }
    k = 0;
    for (i = 100000; i >= 0; i--) {
      if (a[i] && k < s) {
        printf("B %d %d\n", i, a[i]);
        k++;
      } else if (k >= s)
        break;
    }
  }
  return 0;
}
