#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  vector<pair<int, int> > temp;
  int sell[100100], buy[100100], ctr, n, s;
  for (int(i) = 0; (i) < (100100); (i)++) buy[i] = sell[i] = 0;
  cin >> n >> s;
  for (int(i) = 0; (i) < (n); (i)++) {
    int a, b;
    char ch;
    cin >> ch >> a >> b;
    if (ch == 'S')
      sell[a] += b;
    else
      buy[a] += b;
  }
  ctr = 0;
  for (int(i) = 0; (i) < (100010); (i)++) {
    if (sell[i] > 0 and ctr < s) {
      temp.push_back(make_pair(i, sell[i]));
      ctr++;
    }
  }
  int sz = temp.size();
  for (int(i) = 0; (i) < (sz); (i)++)
    cout << "S " << temp[sz - i - 1].first << " " << temp[sz - i - 1].second
         << "\n";
  ctr = 0;
  for (int i = 100010; i >= 0; i--) {
    if (buy[i] > 0 and ctr < s) {
      cout << "B " << i << " " << buy[i] << "\n";
      ctr++;
    }
  }
  return 0;
}
