#include <bits/stdc++.h>
using namespace std;
vector<int> arr1(100005, 0);
vector<int> arr2(100005, 0);
pair<int, int> arr3[50001];
int main() {
  int n, s, p, q, i, l1 = 0, l2 = 0, c;
  char ch;
  cin >> n >> s;
  while (n--) {
    cin >> ch >> p >> q;
    if (ch == 'S')
      arr1[p] += q;
    else
      arr2[p] += q;
  }
  c = 0, i = 0;
  while (i < 100005 && c < s) {
    if (arr1[i] != 0) {
      arr3[l1].first = i;
      arr3[l1].second = arr1[i];
      l1++;
      c++;
    }
    i++;
  }
  for (i = l1 - 1; i >= 0; i--) {
    cout << "S"
         << " " << arr3[i].first << " " << arr3[i].second << "\n";
  }
  i = 100005;
  c = 0;
  while (i >= 0 && c < s) {
    if (arr2[i] != 0) {
      cout << "B"
           << " " << i << " " << arr2[i] << "\n";
      c++;
    }
    i--;
  }
  return 0;
}
