#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 9, mod = 1e9 + 7, inf = 1e17;
map<long long, int> mp;
set<long long> st;
vector<string> ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, s, p, v;
  set<int> sell, buy;
  map<int, int> selll, buyy;
  cin >> n >> s;
  char c;
  for (int i = 0; i < n; i++) {
    cin >> c >> p >> v;
    if (c == 'S') {
      selll[p] += v;
      sell.insert(p);
    } else {
      buyy[p] += v;
      buy.insert(p * -1);
    }
  }
  int fe = s;
  set<int> ans;
  for (auto el : sell) {
    if (fe)
      ans.insert(el * -1);
    else
      break;
    fe--;
  }
  int f = s;
  for (auto el : ans) {
    if (f)
      cout << "S " << el * -1 << " " << selll[el * -1] << "\n";
    else
      break;
  }
  for (auto el : buy) {
    if (s)
      cout << "B " << el * -1 << " " << buyy[el * -1] << "\n";
    else
      break;
    s--;
  }
}
