#include <bits/stdc++.h>
using namespace std;
long long n, s, buy[1000005] = {0}, sell[1000005] = {0}, p, q;
int main() {
  char c;
  vector<long long> B, S, B2, S2;
  cin >> n >> s;
  for (int i = 0; i < n; ++i) {
    cin >> c;
    if (c == 'B') {
      cin >> p >> q;
      if (buy[p] == 0) B.push_back(p);
      buy[p] += q;
    } else {
      cin >> p >> q;
      if (sell[p] == 0) S.push_back(p);
      sell[p] += q;
    }
  }
  B2 = B;
  S2 = S;
  sort(B2.begin(), B2.end());
  sort(S2.begin(), S2.end());
  int x, y, zs, zb;
  zs = S.size();
  zb = B.size();
  if (s > zs)
    x = zs - 1;
  else
    x = s - 1;
  if (zs != 0)
    for (int i = x; i >= 0; --i) {
      cout << "S " << S2[i] << " " << sell[S2[i]] << endl;
    }
  if (s > zb)
    y = 0;
  else
    y = zb - s;
  if (zb != 0)
    for (int i = zb - 1; i >= y; --i) {
      cout << "B " << B2[i] << " " << buy[B2[i]] << endl;
    }
  return 0;
}
