#include <bits/stdc++.h>
using namespace std;
bool op_gr(const pair<int, int>& left, const pair<int, int>& right) {
  return left.first > right.first;
}
int main() {
  int n, s;
  scanf("%d %d", &n, &s);
  char x;
  map<int, int> M1;
  map<int, int> M2;
  vector<pair<int, int> > B(1000, make_pair(0, 0));
  vector<pair<int, int> > S(1000, make_pair(0, 0));
  int j, l;
  int in_B = 0, in_S = 0;
  for (int i = 0; i < n; ++i) {
    scanf(" %c", &x);
    if (x == 'B') {
      scanf("%d %d", &j, &l);
      if (M1.find(j) == M1.end()) {
        M1[j] = in_B;
        B[in_B++] = make_pair(j, l);
      } else {
        B[M1[j]].second += l;
      }
    } else {
      scanf("%d %d", &j, &l);
      if (M2.find(j) == M2.end()) {
        M2[j] = in_S;
        S[in_S++] = make_pair(j, l);
      } else {
        S[M2[j]].second += l;
      }
    }
  }
  int ct = 0;
  int i = 0;
  sort(S.begin(), S.end());
  sort(B.begin(), B.end(), op_gr);
  stack<pair<int, int> > st;
  while (ct < s && i < S.size()) {
    if (S[i].second > 0) {
      st.push(S[i]);
      ct++;
    }
    i++;
  }
  while (ct--) {
    printf("%c %d %d\n", 'S', st.top().first, st.top().second);
    st.pop();
  }
  ct = 0;
  i = 0;
  while (ct < s && i < B.size()) {
    if (B[i].second > 0) {
      printf("%c %d %d\n", 'B', B[i].first, B[i].second);
      ct++;
    }
    i++;
  }
  return 0;
}
