#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:2560000000000")
using namespace std;
map<int, int> sell;
map<int, int> buy;
int main() {
  int n, s;
  cin >> n >> s;
  for (int i = 1; i <= n; i++) {
    int p, d;
    char c;
    cin >> c >> p >> d;
    if (c == 'S') {
      sell[p] += d;
    } else {
      buy[-p] += d;
    }
  }
  map<int, int>::iterator it = sell.begin();
  vector<pair<int, int>> ans;
  for (int i = 1; i <= s && it != sell.end(); i++) {
    ans.push_back(make_pair(it->first, it->second));
    it++;
  }
  for (int i = ans.size() - 1; i >= 0; i--) {
    cout << "S " << ans[i].first << ' ' << ans[i].second << endl;
  }
  map<int, int>::iterator it1 = buy.begin();
  for (int i = 1; i <= s && it1 != buy.end(); i++) {
    cout << "B " << -it1->first << ' ' << it1->second << endl;
    it1++;
  }
}
