#include <bits/stdc++.h>
using namespace std;
long long volume[100001][2];
vector<long long> sell, buy;
int main() {
  long long n, s;
  cin >> n >> s;
  for (long long i = 0; i < n; i++) {
    char a;
    long long b, c, d;
    cin >> a >> b >> c;
    if (a == 'B')
      d = 1;
    else
      d = 0;
    if (volume[b][d] == 0) {
      if (d == 0)
        sell.push_back(b);
      else
        buy.push_back(b);
    }
    volume[b][d] += c;
  }
  sort(buy.begin(), buy.end());
  sort(sell.begin(), sell.end());
  for (long long i = 0; i < s; i++) {
    if (s - i - 1 < sell.size() && s - i - 1 >= 0)
      cout << "S " << sell[s - i - 1] << " " << volume[sell[s - i - 1]][0]
           << endl;
  }
  for (long long i = 0; i < s; i++) {
    if (buy.size() - i - 1 >= 0)
      cout << "B " << buy[buy.size() - i - 1] << " "
           << volume[buy[buy.size() - i - 1]][1] << endl;
  }
}
