#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s, bs = 0;
  cin >> n >> s;
  char d;
  std::vector<std::pair<int, int>> pq;
  int p, q;
  for (int i = 0; i < n; ++i) {
    cin >> d >> p >> q;
    pq.push_back(std::make_pair(p, q));
    if (d == 'B') {
      ++bs;
    }
  }
  std::sort(pq.begin(), pq.end());
  int s1 = s;
  vector<pair<int, int>> aggregated;
  for (int i = n - 1; i >= bs; --i) {
    int curr_p = pq[i].first;
    int curr_q = pq[i].second;
    for (int j = i - 1; j >= bs; --j) {
      if (pq[j].first == curr_p) {
        curr_q += pq[j].second;
      } else {
        i = j + 1;
        break;
      }
      if (j == bs) {
        i = bs;
      }
    }
    aggregated.push_back(make_pair(curr_p, curr_q));
  }
  int x;
  if (s > aggregated.size()) {
    x = 0;
  } else {
    x = aggregated.size() - s;
  }
  for (int i = x; i < aggregated.size(); ++i) {
    cout << "S " << aggregated[i].first << " " << aggregated[i].second;
    if (i == aggregated.size() - 1 && bs == 0) {
      break;
    }
    cout << endl;
  }
  int s2 = s;
  for (int i = bs - 1; i >= 0; --i) {
    int curr_p = pq[i].first;
    int curr_q = pq[i].second;
    for (int j = i - 1; j >= 0; --j) {
      if (pq[j].first == curr_p) {
        curr_q += pq[j].second;
      } else {
        i = j + 1;
        break;
      }
      if (j == 0) {
        i = 0;
      }
    }
    cout << "B " << curr_p << " " << curr_q;
    --s2;
    if (s2 == 0 || i == 0) {
      break;
    }
    cout << endl;
  }
  return 0;
}
