#include <bits/stdc++.h>
using namespace std;
int n, ns;
vector<pair<char, pair<long long, long long> > > v, b, s;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  cin >> n >> ns;
  for (int i = 0; i < n; i++) {
    char c;
    int pi, qi;
    cin >> c >> pi >> qi;
    v.push_back(make_pair(c, make_pair(pi, qi)));
  }
  sort(v.begin(), v.end());
  for (int i = n - 1; i >= 0; i--) {
    if (v[i].first == 'B') {
      if (b.size() > 0 && b.back().second.first == v[i].second.first) {
        b.back().second.second += v[i].second.second;
      } else
        b.push_back(make_pair(
            v[i].first, make_pair(v[i].second.first, v[i].second.second)));
    } else if (v[i].first == 'S') {
      if (s.size() > 0 && s.back().second.first == v[i].second.first) {
        s.back().second.second += v[i].second.second;
      } else
        s.push_back(make_pair(
            v[i].first, make_pair(v[i].second.first, v[i].second.second)));
    }
  }
  if (s.size() >= ns) {
    int u;
    u = s.size() - ns;
    for (int i = u; i < s.size(); i++)
      cout << s[i].first << " " << s[i].second.first << " "
           << s[i].second.second << endl;
  } else
    for (int i = 0; i < s.size(); i++) {
      cout << s[i].first << " " << s[i].second.first << " "
           << s[i].second.second << endl;
    }
  if (b.size() >= ns)
    for (int i = 0; i < ns; i++)
      cout << b[i].first << " " << b[i].second.first << " "
           << b[i].second.second << endl;
  else
    for (int i = 0; i < b.size(); i++) {
      cout << b[i].first << " " << b[i].second.first << " "
           << b[i].second.second << endl;
    }
  return 0;
}
