#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
long long abss(long long x) {
  if (x < 0) return -x;
  return x;
}
vector<int> sell, b;
vector<pair<int, long long> > bdob, sdob, fin;
long long freb[100001], fres[100001];
int main() {
  int n, s, p, q;
  cin >> n >> s;
  char ch;
  for (int i = 0; i < n; ++i) {
    cin >> ch >> p >> q;
    if (ch == 'B') {
      if (freb[p] == 0) b.push_back(p);
      freb[p] += q;
    } else {
      if (fres[p] == 0) sell.push_back(p);
      fres[p] += q;
    }
  }
  for (int i = 0; i < b.size(); ++i)
    bdob.push_back(make_pair(b[i], freb[b[i]]));
  for (int i = 0; i < sell.size(); ++i)
    sdob.push_back(make_pair(sell[i], fres[sell[i]]));
  sort(bdob.begin(), bdob.end());
  sort(sdob.begin(), sdob.end());
  reverse(bdob.begin(), bdob.end());
  int temp = s, z = 0;
  while (temp && z < sdob.size()) {
    fin.push_back(make_pair(sdob[z].first, sdob[z].second));
    z++;
    temp--;
  }
  sort(fin.begin(), fin.end());
  reverse(fin.begin(), fin.end());
  for (int i = 0; i < fin.size(); ++i) {
    cout << "S " << fin[i].first << " " << fin[i].second << endl;
  }
  temp = s, z = 0;
  while (temp && z < bdob.size()) {
    cout << "B " << bdob[z].first << " " << bdob[z].second << endl;
    z++;
    temp--;
  }
}
