#include <bits/stdc++.h>
using namespace std;
bool compare(pair<long long int, long long int>& a,
             pair<long long int, long long int>& b) {
  return (a.first <= b.first);
}
int main() {
  long long int n, s, i, j;
  cin >> n >> s;
  vector<pair<long long int, long long int> > buy;
  vector<pair<long long int, long long int> > sell;
  set<long long int> s1;
  set<long long int> s2;
  for (i = 0; i < n; i++) {
    char ch;
    cin >> ch;
    long long int a, b;
    if (ch == 'B') {
      cin >> a >> b;
      if (s1.find(a) == s1.end()) {
        s1.insert(a);
        buy.push_back(make_pair(a, b));
      } else {
        for (j = 0; j < buy.size(); j++) {
          if (buy[j].first == a) break;
        }
        buy[j].second += b;
      }
    } else {
      cin >> a >> b;
      if (s2.find(a) == s2.end()) {
        s2.insert(a);
        sell.push_back(make_pair(a, b));
      } else {
        for (j = 0; j < sell.size(); j++) {
          if (sell[j].first == a) break;
        }
        sell[j].second += b;
      }
    }
  }
  if (buy.size() != 0) sort(buy.begin(), buy.end(), compare);
  if (sell.size() != 0) sort(sell.begin(), sell.end(), compare);
  long long int x = s - 1;
  long long int k, l;
  k = sell.size();
  l = buy.size();
  x = min(s - 1, k - 1);
  for (i = x; i >= 0; i--) {
    cout << "S"
         << " " << sell[i].first << " " << sell[i].second;
    cout << endl;
  }
  i = l - 1;
  while (i >= 0 && s != 0) {
    cout << "B"
         << " " << buy[i].first << " " << buy[i].second;
    cout << endl;
    i--;
    s--;
  }
}
