#include <bits/stdc++.h>
using namespace std;
int n, s;
vector<pair<int, int> > B, S;
char c;
int p, q;
int main() {
  scanf("%d %d\n", &n, &s);
  for (int i = 0; i < n; ++i) {
    scanf("%c %d %d\n", &c, &p, &q);
    if (c == 'B') {
      bool ok = false;
      for (int j = 0; j < B.size(); ++j) {
        if (B[j].first == p) {
          B[j].second += q;
          ok = true;
        }
      }
      if (!ok) {
        B.push_back(make_pair(p, q));
      }
    } else {
      bool ok = false;
      for (int j = 0; j < S.size(); ++j) {
        if (S[j].first == p) {
          S[j].second += q;
          ok = true;
        }
      }
      if (!ok) {
        S.push_back(make_pair(p, q));
      }
    }
  }
  sort(B.begin(), B.end());
  sort(S.begin(), S.end());
  int t = S.size();
  int tt = B.size();
  for (int i = s > t ? t - 1 : s - 1; i >= 0; --i) {
    printf("S %d %d\n", S[i].first, S[i].second);
  }
  for (int i = B.size() - 1; i >= 0 && i >= tt - s; --i) {
    printf("B %d %d\n", B[i].first, B[i].second);
  }
}
