#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, s;
  cin >> n >> s;
  map<long long int, long long int, greater<long long int>> B, S;
  long long int j = 0, k = 0;
  while (n--) {
    char ch;
    long long int price, quantity;
    cin >> ch >> price >> quantity;
    if (ch == 'B') {
      B[price] += quantity;
    } else {
      S[price] += quantity;
    }
  }
  n = s;
  while (S.size() > s) {
    S.erase(S.begin());
  }
  for (auto it : S) {
    cout << 'S' << ' ';
    cout << it.first;
    cout << ' ' << it.second << "\n";
  }
  while (B.size() > s) {
    B.erase(--B.end());
  }
  for (auto it : B) {
    cout << 'B' << ' ';
    cout << it.first;
    cout << ' ' << it.second << "\n";
  }
  return 0;
}
