#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-6;
const int INF = (int)(INT_MAX - 100);
const long long mod = (int)(1e+9 + 7);
const int N = (int)(1e5);
int main() {
  int n, s;
  cin >> n >> s;
  char d;
  int p, k;
  map<int, int, greater<int> > C;
  map<int, int> V;
  for (int i = 0; i < n; i++) {
    cin >> d >> p >> k;
    if (d == 'B')
      C[p] += k;
    else
      V[p] += k;
  }
  k = 0;
  vector<pair<int, int> > ans;
  for (pair<int, int> x : V) {
    if (k == s) break;
    k++;
    ans.push_back({x.first, x.second});
  }
  reverse(ans.begin(), ans.end());
  for (pair<int, int> x : ans)
    cout << "S " << x.first << " " << x.second << '\n';
  k = 0;
  for (pair<int, int> x : C) {
    if (k == s) break;
    k++;
    cout << "B " << x.first << " " << x.second << '\n';
  }
  return 0;
}
