#include <bits/stdc++.h>
using namespace std;
int n, m, len;
map<int, int> buy, sell;
bool cmp(pair<int, int> l, pair<int, int> r) {
  if (l.first != r.first)
    return l.first > r.first;
  else
    return l.second > r.second;
}
bool cmp2(pair<int, pair<int, int> > l, pair<int, pair<int, int> > r) {
  if (l.first != r.first) return l.first < r.first;
  if (l.second.first != r.second.first) return l.second.first > r.second.first;
  return l.second.second < r.second.second;
}
int main() {
  int i, j, k, t, a, b;
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    string u;
    cin >> u;
    cin >> a >> b;
    if (u[0] == 'B') {
      buy[a] += b;
    } else {
      sell[a] += b;
    }
  }
  vector<pair<int, int> > buy2, sell2;
  for (auto cur : buy) buy2.push_back(cur);
  for (auto cur : sell) sell2.push_back(cur);
  sort(buy2.begin(), buy2.end(), cmp);
  sort(sell2.begin(), sell2.end());
  vector<pair<int, pair<int, int> > > ans;
  for (i = 0; i < min(((int)sell2.size()), m); i++) {
    ans.push_back(pair<int, pair<int, int> >(0, sell2[i]));
  }
  for (i = 0; i < min(((int)buy2.size()), m); i++) {
    ans.push_back(pair<int, pair<int, int> >(1, buy2[i]));
  }
  sort(ans.begin(), ans.end(), cmp2);
  for (auto cur : ans) {
    cout << ((cur.first == 0) ? ("S ") : ("B ")) << cur.second.first << " "
         << cur.second.second << "\n";
  }
  return 0;
}
