#include <bits/stdc++.h>
using namespace std;
int sell[110000], buy[110000], n, s, no1[1100], p[1100], k1, k2, no2[1100],
    p1[1100], q, pri, id;
int cmp1(int a, int b) { return p[a] > p[b]; }
int cmp2(int a, int b) { return p1[a] < p1[b]; }
char ord[3];
int main() {
  while (scanf("%d%d", &n, &s) != EOF) {
    memset(sell, 0, sizeof(sell));
    memset(buy, 0, sizeof(buy));
    memset(p, 0, sizeof(p));
    memset(p1, 0, sizeof(p1));
    k1 = -1;
    k2 = -1;
    for (int i = 0; i < n; i++) {
      scanf("%s%d%d", ord, &pri, &q);
      if (strcmp(ord, "B") == 0) {
        if (buy[pri] == 0) {
          k1++;
          no1[k1] = k1;
          p[k1] = pri;
          buy[pri] += q;
        } else {
          buy[pri] += q;
        }
      } else {
        if (sell[pri] == 0) {
          k2++;
          no2[k2] = k2;
          p1[k2] = pri;
          sell[pri] += q;
        } else {
          sell[pri] += q;
        }
      }
    }
    sort(no1, no1 + k1 + 1, cmp1);
    sort(no2, no2 + k2 + 1, cmp2);
    k2 = min(k2 + 1, s);
    k1 = min(k1 + 1, s);
    for (int i = k2 - 1; i >= 0; i--) {
      id = no2[i];
      printf("S %d %d\n", p1[id], sell[p1[id]]);
    }
    for (int i = 0; i < k1; i++) {
      id = no1[i];
      printf("B %d %d\n", p[id], buy[p[id]]);
    }
  }
  return 0;
}
