#include <bits/stdc++.h>
using namespace std;
bool ssort(pair<long long, long long> a, pair<long long, long long> b) {
  return (a.first < b.first);
}
bool bsort(pair<long long, long long> a, pair<long long, long long> b) {
  return (a.first > b.first);
}
int main() {
  long long n, s, q, p;
  char d;
  cin >> n >> s;
  set<pair<long long, long long> > ss, bs;
  map<long long, long long> sm, bm;
  for (int i = 0; i < n; ++i) {
    cin >> d >> p >> q;
    if (d == 'S') {
      if (sm[p] == 0) {
        sm[p] += q;
        ss.insert(make_pair(p, q));
      } else {
        ss.erase(make_pair(p, sm[p]));
        sm[p] += q;
        ss.insert(make_pair(p, sm[p]));
      }
    } else {
      if (bm[p] == 0) {
        bm[p] += q;
        bs.insert(make_pair(p, q));
      } else {
        bs.erase(make_pair(p, bm[p]));
        bm[p] += q;
        bs.insert(make_pair(p, bm[p]));
      }
    }
  }
  vector<pair<long long, long long> > bv, sv;
  for (auto it = ss.begin(); it != ss.end(); ++it) {
    sv.push_back(*it);
  }
  for (auto it = bs.begin(); it != bs.end(); ++it) {
    bv.push_back(*it);
  }
  sort(sv.begin(), sv.end(), ssort);
  sort(sv.begin(), sv.begin() + min(s, (long long)sv.size()), bsort);
  sort(bv.begin(), bv.end(), bsort);
  for (int i = 0; i < min((long long)sv.size(), s); ++i) {
    cout << "S " << sv[i].first << " " << sv[i].second << endl;
  }
  for (int i = 0; i < min((long long)bv.size(), s); ++i) {
    cout << "B " << bv[i].first << " " << bv[i].second << endl;
  }
  return 0;
}
