#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long int n, k, i, a, b, sizes = 0;
  char ch;
  map<long long int, long long int> ms, mb;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> ch >> a >> b;
    if (ch == 'S') {
      if (ms[a] == 0) sizes++;
      ms[a] = ms[a] + b;
    } else {
      mb[a] = mb[a] + b;
    }
  }
  string j[sizes];
  i = sizes - 1;
  for (auto it = ms.rbegin(); it != ms.rend(); it++) {
    j[i] = "S " + to_string(it->first) + " " + to_string(it->second);
    i--;
  }
  for (i = k - 1; i >= 0; i--) {
    if (i < sizes) {
      cout << j[i] << endl;
    }
  }
  i = 0;
  for (auto it1 = mb.rbegin(); it1 != mb.rend(); it1++) {
    if (i < k) {
      cout << "B " << it1->first << " " << it1->second << endl;
    } else
      break;
    i++;
  }
  return 0;
}
