#include <bits/stdc++.h>
using namespace std;
long long int power(long long int b, long long int e) {
  long long int x = 1;
  while (e > 0) {
    if (e & 1) x = x * b;
    b = b * b;
    e = e / 2;
  }
  return x;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int mult(long long int A, long long int B) {
  if (B == 0) return 0;
  long long int u = mult(A, B / 2);
  long long int res;
  if (B % 2 == 0)
    res = u + u;
  else
    res = u + u + A;
  while (res >= 1000000007) res -= 1000000007;
  return res;
}
long long int t, i, j, k, l, m, n;
map<long long int, long long int> buy;
map<long long int, long long int> sell;
int main() {
  char c;
  scanf("%lld %lld", &n, &m);
  for (i = 0; i < n; i++) {
    cin >> c >> j >> k;
    if (c == 'B')
      buy[j] += k;
    else
      sell[j] += k;
  }
  long long int temp = m;
  if (!sell.empty()) {
    map<long long int, long long int>::iterator it = sell.end();
    it--;
    long long int sz = sell.size();
    if (temp < sz)
      while (sz != temp) {
        sz--;
        it--;
      }
    for (; it != sell.begin(); it--) {
      if (temp == 0) break;
      cout << 'S' << " " << it->first << " " << it->second << "\n";
      temp--;
    }
    if (temp != 0) {
      it = sell.begin();
      cout << 'S' << " " << it->first << " " << it->second << "\n";
    }
  }
  if (!buy.empty()) {
    temp = m;
    map<long long int, long long int>::iterator it = buy.end();
    it--;
    for (; it != buy.begin(); it--) {
      if (temp == 0) break;
      cout << 'B' << " " << it->first << " " << it->second << "\n";
      temp--;
    }
    if (temp != 0) {
      it = buy.begin();
      cout << 'B' << " " << it->first << " " << it->second << "\n";
    }
  }
  return 0;
}
