#include <bits/stdc++.h>
using namespace std;
mt19937 rng((int)std::chrono::steady_clock::now().time_since_epoch().count());
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, second;
  cin >> n >> second;
  map<int, int> buy, sell;
  while (n--) {
    char d;
    int p, v;
    cin >> d >> p >> v;
    if (d == 'S')
      sell[p] += v;
    else
      buy[p] += v;
  }
  vector<pair<int, int> > bb, ss;
  for (auto &x : buy) bb.push_back(x);
  for (auto &x : sell) ss.push_back(x);
  vector<pair<int, int> > a;
  for (int i = 0; i < second and i < ss.size(); i++) a.push_back(ss[i]);
  reverse(a.begin(), a.end());
  for (auto &x : a) cout << 'S' << " " << x.first << " " << x.second << endl;
  reverse(bb.begin(), bb.end());
  for (int i = 0; i < second and i < bb.size(); i++)
    cout << 'B' << " " << bb[i].first << " " << bb[i].second << endl;
}
