#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ;
  int n, s;
  cin >> n >> s;
  map<int, int, greater<int>> buy;
  map<int, int> sell;
  vector<pair<int, int>> vt;
  for (int i = 0; i < n; i++) {
    char d;
    int p, q;
    cin >> d >> p >> q;
    if (d == 'B') {
      buy[p] += q;
    } else {
      sell[p] += q;
    }
  }
  int a = 0, b = 0;
  for (auto [i, j] : sell) {
    vt.emplace_back(i, j);
    a++;
    if (a == s) break;
  }
  sort(vt.rbegin(), vt.rend());
  for (auto [i, j] : vt) {
    cout << "S " << i << ' ' << j << endl;
  }
  for (auto [i, j] : buy) {
    cout << "B " << i << ' ' << j << endl;
    b++;
    if (b == s) break;
  }
  return 0;
}
