#include <bits/stdc++.h>
using namespace std;
long long int agg[2][100001];
pair<long long int, long long int> srt[100001];
const int N = 100000;
void task() {
  int n, s;
  cin >> n >> s;
  char d;
  long long int p, q;
  for (int i = 0; i < n; i++) {
    cin >> d;
    if (d == 'S')
      d = 0;
    else
      d = 1;
    cin >> p;
    cin >> q;
    agg[d][p] += q;
  }
  int cnt = 0;
  for (int i = 0; i <= N; i++) {
    if (agg[0][i] != 0 && cnt < s) {
      srt[cnt] = make_pair(i, agg[0][i]);
      cnt++;
    }
  }
  for (int i = cnt - 1; i >= 0; i--) {
    cout << 'S' << " " << srt[i].first << " " << srt[i].second << "\n";
  }
  cnt = 0;
  for (int i = N; i >= 0; i--) {
    if (agg[1][i] != 0 && cnt < s) {
      cout << 'B' << " " << i << " " << agg[1][i] << "\n";
      cnt++;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  task();
  return 0;
}
