#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n, s;
  cin >> n >> s;
  vector<pair<long long int, long long int> > vp;
  char ch;
  long long int p, v;
  map<long long int, long long int> bp, sp;
  vector<long long int> by, sy;
  for (long long int i = 0; i < n; i++) {
    cin >> ch >> p >> v;
    if (ch == 'B')
      bp[p] += v;
    else
      sp[p] += v;
  }
  for (auto it : bp) {
    if (it.second > 0) by.push_back(it.first);
  }
  for (auto it : sp) {
    if (it.second > 0) sy.push_back(it.first);
  }
  sort(by.begin(), by.end(), greater<long long int>());
  sort(sy.begin(), sy.end());
  vector<pair<long long int, long long int> > ans1, ans2;
  long long int cnt = s;
  for (auto it : by) {
    ans1.push_back({it, bp[it]});
    cnt--;
    if (cnt == 0) break;
  }
  cnt = s;
  for (auto it : sy) {
    ans2.push_back({it, sp[it]});
    cnt--;
    if (cnt == 0) break;
  }
  sort(ans2.begin(), ans2.end(),
       greater<pair<long long int, long long int> >());
  for (auto it : ans2) {
    cout << 'S' << " " << it.first << " " << it.second << "\n";
  }
  for (auto it : ans1) {
    cout << "B"
         << " " << it.first << " " << it.second << "\n";
  }
}
