#include <bits/stdc++.h>
using namespace std;
int n, s, S[100010], B[100010], a, b;
string ch;
vector<pair<int, int> > v, vv;
int main() {
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    cin >> ch >> a >> b;
    if (ch == "B")
      B[a] += b;
    else
      S[a] += b;
  }
  for (int i = 0; i < 100010; i++)
    if (S[i]) v.push_back(make_pair(i, S[i]));
  for (int i = 100010 - 1; i >= 0; i--)
    if (B[i]) vv.push_back(make_pair(i, B[i]));
  for (int i = min((int)v.size(), s) - 1; i >= 0; i--)
    cout << "S " << v[i].first << " " << v[i].second << endl;
  for (int i = 0; i < min((int)vv.size(), s); i++)
    cout << "B " << vv[i].first << " " << vv[i].second << endl;
  return 0;
}
