#include <bits/stdc++.h>
using namespace std;
const int INF = numeric_limits<int>::max();
const long long LINF = numeric_limits<long long>::max();
const double DINF = numeric_limits<double>::max();
double eps = 1e-2;
struct call {
  char type;
  long long p;
  long long q;
};
bool cmpb(call a, call b) { return a.p >= b.p; }
bool cmps(call a, call b) { return a.p <= b.p; }
void solve() {
  int n, s;
  cin >> n >> s;
  vector<call> by, sl;
  for (int i = 0; i < n; ++i) {
    char t;
    long long pr, qu;
    cin >> t >> pr >> qu;
    call temp;
    temp.type = t;
    temp.p = pr;
    temp.q = qu;
    if (t == 'B') {
      bool is = false;
      int wh = 0;
      for (int i = 0; i < (int)by.size(); ++i) {
        if (by[i].p == pr) {
          is = true;
          wh = i;
        }
      }
      if (!is)
        by.push_back(temp);
      else
        by[wh].q += qu;
    } else if (t == 'S') {
      bool is = false;
      int wh = 0;
      for (int i = 0; i < (int)sl.size(); ++i) {
        if (sl[i].p == pr) {
          is = true;
          wh = i;
        }
      }
      if (!is)
        sl.push_back(temp);
      else
        sl[wh].q += qu;
    }
  }
  sort(by.begin(), by.end(), &cmpb);
  sort(sl.begin(), sl.end(), &cmps);
  vector<call> slans;
  for (int i = 0; i < (int)sl.size() && i < s; ++i) slans.push_back(sl[i]);
  sort(slans.begin(), slans.end(), &cmpb);
  for (int i = 0; i < (int)slans.size(); ++i)
    cout << slans[i].type << ' ' << slans[i].p << ' ' << slans[i].q << "\n";
  for (int i = 0; i < (int)by.size() && i < s; ++i)
    cout << by[i].type << ' ' << by[i].p << ' ' << by[i].q << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  for (int k = 0; k < t; ++k) {
    solve();
  }
  return 0;
}
