#include <bits/stdc++.h>
using namespace std;
struct stock {
  int price;
  int n;
};
int main() {
  int t, i, s, j;
  cin >> t >> s;
  char d;
  int temp_s[100005];
  int temp_b[100005];
  stock buy[1000];
  stock sell[1000];
  for (i = 0; i < 100005; i++) {
    temp_s[i] = 0;
    temp_b[i] = 0;
  }
  int p, num;
  int count = 0;
  for (i = 0, j = 0; i + j < t;) {
    cin >> d >> p >> num;
    if (d == 'S') {
      sell[i].price = p;
      sell[i].n = num;
      if (temp_s[p] == 0) count++;
      temp_s[p] += num;
      i++;
    } else {
      buy[i].price = p;
      buy[i].n = num;
      temp_b[p] += num;
      j++;
    }
  }
  int count_s = 0;
  int temp = 0;
  int count_b = 0;
  for (i = 100000; i >= 0; i--) {
    if (count_s == s) break;
    if (temp_s[i] != 0) {
      if (count <= s) {
        cout << "S ";
        cout << i << " ";
        cout << temp_s[i] << endl;
        count_s++;
      } else
        count--;
    }
  }
  for (i = 100000; i >= 0; i--) {
    if (count_b == s) break;
    if (temp_b[i] != 0) {
      cout << "B ";
      cout << i << " ";
      cout << temp_b[i] << endl;
      count_b++;
    }
  }
  return 0;
}
