#include <bits/stdc++.h>
using namespace std;
long long p[100005], q[100005];
char d[100005];
map<long long, long long> m1;
map<long long, long long> m2;
vector<pair<long long, long long>> ans1;
vector<pair<long long, long long>> ans2;
vector<pair<long long, long long>> ans3;
long long buy[100005];
long long sell[100005];
int main() {
  long long n, s, i, j, k;
  cin >> n >> s;
  for (i = 0; i < n; i++) {
    cin >> d[i] >> p[i] >> q[i];
    if (d[i] == 'B') {
      m1[p[i]] += q[i];
    } else {
      m2[p[i]] += q[i];
    }
  }
  map<long long, long long>::iterator iter;
  for (iter = m2.begin(); iter != m2.end(); iter++) {
    ans1.push_back(make_pair(iter->first, iter->second));
  }
  for (iter = m1.begin(); iter != m1.end(); iter++) {
    ans2.push_back(make_pair(iter->first, iter->second));
  }
  vector<pair<long long, long long>>::iterator it;
  sort(ans1.begin(), ans1.end());
  sort(ans2.begin(), ans2.end());
  long long size1 = ans1.size();
  long long size2 = ans2.size();
  for (i = 0; i < (min(s, size1)); i++) {
    ans3.push_back(make_pair(ans1[i].first, ans1[i].second));
  }
  sort(ans3.begin(), ans3.end());
  long long size3 = ans3.size();
  for (i = 0; i < (min(s, size3)); i++) {
    cout << "S " << ans3[size3 - 1 - i].first << " "
         << ans3[size3 - 1 - i].second << endl;
  }
  for (i = 0; i < (min(s, size2)); i++) {
    cout << "B " << ans2[size2 - 1 - i].first << " "
         << ans2[size2 - 1 - i].second << endl;
  }
  return 0;
}
