#include <bits/stdc++.h>
using namespace std;
int B[100001], S[100001];
vector<pair<int, int> > buy;
vector<pair<int, int> > sell;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, s;
  cin >> n >> s;
  int countS = 0;
  int countB = 0;
  while (n--) {
    char ch;
    cin >> ch;
    if (ch == 'B') {
      countB++;
      int a, b;
      cin >> a >> b;
      B[a] += b;
    } else {
      countS++;
      int a, b;
      cin >> a >> b;
      S[a] += b;
    }
  }
  int cur = 0;
  for (int i = 0; i < 100001 && cur != s; i++) {
    if (S[i] != 0) {
      sell.push_back(make_pair(i, S[i]));
      cur++;
    }
  }
  sort(sell.begin(), sell.end(), greater<pair<int, int> >());
  for (int i = 0; i < sell.size(); i++) {
    cout << "S " << sell[i].first << " " << sell[i].second << endl;
  }
  cur = 0;
  for (int i = 100000; i >= 0 && cur != s; i--) {
    if (B[i] != 0) {
      cout << "B " << i << " " << B[i] << endl;
      cur++;
    }
  }
  return 0;
}
