#include <bits/stdc++.h>
using namespace std;
long long fmin(long long a, long long b) { return a < b ? a : b; }
long long fmax(long long a, long long b) { return a > b ? a : b; }
int getBit(int n, int pos) { return (n >> pos) & 1; }
vector<pair<long long, long long>> sell, buy;
bool sortSell(pair<int, int> a, pair<int, int> b) { return a.first < b.first; }
bool sortBuy(pair<int, int> a, pair<int, int> b) { return a.first > b.first; }
int main() {
  ios_base::sync_with_stdio(false);
  int n, s;
  cin >> n >> s;
  long long a, b;
  string st;
  for (int i = 0; i < n; i++) {
    cin >> st;
    cin >> a >> b;
    if (st == "S") {
      int flag = 0;
      for (int i = 0; i < sell.size(); i++)
        if (sell[i].first == a) {
          sell[i].second += b;
          flag = 1;
        }
      if (flag == 1) continue;
      sell.push_back(make_pair(a, b));
    } else {
      int flag = 0;
      for (int i = 0; i < buy.size(); i++)
        if (buy[i].first == a) {
          buy[i].second += b;
          flag = 1;
        }
      if (flag == 1) continue;
      buy.push_back(make_pair(a, b));
    }
  }
  sort(sell.begin(), sell.end(), sortSell);
  sort(buy.begin(), buy.end(), sortBuy);
  for (int i = fmin(s, sell.size()) - 1; i >= 0; i--)
    cout << "S " << sell[i].first << " " << sell[i].second << endl;
  for (int i = 0; i < fmin(s, buy.size()); i++)
    cout << "B " << buy[i].first << " " << buy[i].second << endl;
}
