#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
int B[100000 + 5];
int S[100000 + 5];
int main() {
  int k, n;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    char c;
    int a, b;
    cin >> c >> a >> b;
    if (c == 'B') {
      B[a] += b;
    } else {
      S[a] += b;
    }
  }
  int t = k;
  stack<int> SS, SSS;
  for (int i = 0; i <= 100000 + 4 && t; i++) {
    if (S[i]) SS.push(i), SSS.push(S[i]), t--;
  }
  while (!SS.empty()) {
    int a = SS.top(), b = SSS.top();
    SS.pop();
    SSS.pop();
    printf("S %d %d\n", a, b);
  }
  t = k;
  for (int i = 100000 + 4; i >= 0 && t; i--) {
    if (B[i]) printf("B %d %d\n", i, B[i]), t--;
  }
}
