#include <bits/stdc++.h>
using namespace std;
map<int, int> mp1, mp2;
map<int, int>::reverse_iterator it1;
map<int, int>::iterator it2;
typedef struct ans {
  int p, q;
  char d;
  friend bool operator<(ans a, ans b) { return a.p > b.p; }
  ans(int p = 0, int q = 0, char d = 0) : p(p), q(q), d(d) {}
} ans;
ans A[1000];
int n, s;
int main() {
  cin >> n >> s;
  char d[10];
  int p, q;
  for (int i = 0; i < n; i++) {
    scanf("%s%d%d", d, &p, &q);
    if (d[0] == 'S') {
      mp1[p] += q;
    } else
      mp2[p] += q;
  }
  int i = 0, c = 0;
  for (it2 = mp1.begin(); it2 != mp1.end() && i < s; it2++, i++) {
    A[c++] = ans((*it2).first, (*it2).second, 'S');
  }
  i = 0;
  for (it1 = mp2.rbegin(); it1 != mp2.rend() && i < s; it1++, i++) {
    A[c++] = ans((*it1).first, (*it1).second, 'B');
  }
  sort(A, A + c);
  for (int i = 0; i < c; i++) printf("%c %d %d\n", A[i].d, A[i].p, A[i].q);
  return 0;
}
