#include <bits/stdc++.h>
using namespace std;
template <class T>
string toStr(const T &x) {
  stringstream s;
  s << x;
  return s.str();
}
template <class T>
int toInt(const T &x) {
  stringstream s;
  s << x;
  int r;
  s >> r;
  return r;
}
int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int main() {
  int n, s;
  cin >> n >> s;
  map<int, int> sell;
  map<int, int> buy;
  char d;
  int p, q;
  for (int i = 0; i < n; ++i) {
    cin >> d >> p >> q;
    if (d == 'S')
      sell[p] += q;
    else
      buy[p] += q;
  }
  vector<pair<int, pair<int, int> > > v;
  vector<pair<int, pair<int, int> > > vv;
  for (__typeof(sell).begin() x = (sell).begin(); x != (sell).end(); ++x) {
    int tot = x->first;
    v.push_back(make_pair(tot, make_pair(x->first, x->second)));
  }
  for (__typeof(buy).begin() x = (buy).begin(); x != (buy).end(); ++x) {
    int tot = x->first;
    vv.push_back(make_pair(tot, make_pair(x->first, x->second)));
  }
  sort(v.begin(), v.end());
  sort(vv.begin(), vv.end());
  vector<string> ans;
  int tot = s;
  for (int i = 0; i < v.size() && tot-- > 0; ++i) {
    ans.push_back("S " + toStr(v[i].second.first) + " " +
                  toStr(v[i].second.second));
  }
  for (int i = ans.size() - 1; i >= 0; --i) cout << ans[i] << '\n';
  tot = s;
  for (int i = vv.size() - 1; i >= 0 and tot-- > 0; --i) {
    cout << "B " << vv[i].second.first << " " << vv[i].second.second << '\n';
  }
  return 0;
}
