#include <bits/stdc++.h>
using namespace std;
int S[100002], B[100002];
int main() {
  int n, s, i, p, q, k;
  char d;
  cin >> n >> s;
  while (n--) {
    cin >> d >> p >> q;
    if (d == 'S')
      S[p] += q;
    else
      B[p] += q;
  }
  for (i = 0, k = 0; k < s && i <= 100000; i++) {
    if (S[i] != 0) k++;
  }
  for (; i >= 0; i--) {
    if (S[i] != 0) cout << "S " << i << " " << S[i] << endl;
  }
  for (k = 0, i = 100000; k < s && i >= 0; i--) {
    if (B[i] != 0) {
      k++;
      cout << "B " << i << " " << B[i] << endl;
    }
  }
}
