#include <bits/stdc++.h>
using namespace std;
int N, S;
int bArray[100011], sArray[100011];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> N >> S;
  for (int i = 0; i < N; ++i) {
    char dir;
    int p, q;
    cin >> dir >> p >> q;
    if (dir == 'B') {
      bArray[p] += q;
    } else {
      sArray[p] += q;
    }
  }
  vector<pair<int, int> > Bp, Sp;
  int cntB = 0, cntS = 0;
  for (int i = 100000; i >= 0 && cntB < S; --i) {
    if (bArray[i] != 0) {
      cntB++;
      Bp.push_back(make_pair(i, bArray[i]));
    }
  }
  for (int i = 0; i < 100001 && cntS < S; ++i) {
    if (sArray[i] != 0) {
      cntS++;
      Sp.push_back(make_pair(i, sArray[i]));
    }
  }
  for (int i = Sp.size() - 1; i >= 0; --i) {
    cout << "S " << Sp[i].first << " " << Sp[i].second << '\n';
  }
  for (int i = 0; i < Bp.size(); ++i) {
    cout << "B " << Bp[i].first << " " << Bp[i].second << '\n';
  }
}
