#include <bits/stdc++.h>
using namespace std;
struct entry {
  long long price, quantity;
};
int comp(entry a, entry b) { return a.price < b.price; }
int comp2(entry a, entry b) { return a.price > b.price; }
entry B[1000];
entry S[1000];
entry T[1000];
int main() {
  long long n, s;
  cin >> n >> s;
  char d;
  long long p, q;
  long long i = 0, j = 0;
  for (long long k = 0; k < n; k++) {
    cin >> d >> p >> q;
    if (d == 'B') {
      B[i].price = p;
      B[i].quantity = q;
      i++;
    } else {
      S[j].price = p;
      S[j].quantity = q;
      j++;
    }
  }
  sort(B, B + i, comp2);
  sort(S, S + j, comp);
  long long m = 0, temp = S[0].quantity;
  long long t = 0;
  for (long long k = 0; (k < j) && (k < s) && (m <= j - 1); k++) {
    while ((m < j - 1) && (S[m].price == S[m + 1].price)) {
      m++;
      temp += S[m].quantity;
    }
    T[t].price = S[m].price;
    T[t].quantity = temp;
    t++;
    m++;
    temp = S[m].quantity;
  }
  sort(T, T + t, comp2);
  for (long long k = 0; k < t; k++) {
    cout << "S " << T[k].price << " " << T[k].quantity << endl;
  }
  m = 0, temp = B[0].quantity;
  for (long long k = 0; (k < i) && (k < s) && (m <= i - 1); k++) {
    while ((m < i - 1) && (B[m].price == B[m + 1].price)) {
      m++;
      temp += B[m].quantity;
    }
    cout << "B " << B[m].price << " " << temp << endl;
    m++;
    temp = B[m].quantity;
  }
}
