#include <bits/stdc++.h>
using namespace std;
int sa[100001], ba[100001];
int n, s;
int main() {
  scanf("%d %d", &n, &s);
  for (int i = 0; i < n; i++) {
    char c;
    int p, q;
    scanf("%c", &c);
    scanf("%c %d %d", &c, &p, &q);
    if (c == 'B')
      ba[p] += q;
    else
      sa[p] += q;
  }
  vector<pair<int, int> > sv, bv;
  for (int i = 0; i < 100001; i++) {
    if (sa[i] > 0) sv.push_back(make_pair(i, sa[i]));
    if (ba[i] > 0) bv.push_back(make_pair(i, ba[i]));
  }
  sort(sv.rbegin(), sv.rend());
  sort(bv.rbegin(), bv.rend());
  int start = 0;
  if (sv.size() > s) start = sv.size() - s;
  for (int i = start, idx = 0; idx < s; i++, idx++) {
    if (i == sv.size()) break;
    printf("S %d %d\n", sv[i].first, sv[i].second);
  }
  for (int i = 0; i < s; i++) {
    if (i == bv.size()) break;
    printf("B %d %d\n", bv[i].first, bv[i].second);
  }
  return 0;
}
