#include <bits/stdc++.h>
using namespace std;
template <class T>
T MAX(T a, T b) {
  return a > b ? a : b;
}
template <class T>
T MIN(T a, T b) {
  return a < b ? a : b;
}
template <class T1>
void deb(T1 p) {
  cout << "Debugging: " << p << endl;
}
template <class T1, class T2>
void deb(T1 p, T2 q) {
  cout << "Debugging: " << p << "\t" << q << endl;
}
template <class T1, class T2, class T3>
void deb(T1 p, T2 q, T3 r) {
  cout << "Debugging: " << p << "\t " << q << "\t " << r << endl;
}
template <class T1, class T2, class T3, class T4>
void deb(T1 p, T2 q, T3 r, T4 s) {
  cout << "Debugging: " << p << "\t " << q << "\t " << r << "\t " << s << endl;
}
long long int POOW(int b, int p) {
  if (p == 0) return 1;
  return b * POOW(b, p - 1);
}
const int xx[] = {0, 0, 1, -1, -1, 1, -1, 1};
const int yy[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int kx[] = {-2, -1, 1, 2, 2, 1, -1, -2};
const int ky[] = {1, 2, 2, 1, -1, -2, -2, -1};
vector<pair<int, int> > va, vb;
int main() {
  int sell[100005] = {0}, buy[100005] = {0}, n, s, i, j, k, a, b, d;
  char c;
  scanf("%d", &n);
  scanf("%d", &s);
  getchar();
  for (i = 0; i < n; i++) {
    scanf("%c %d %d", &c, &a, &b);
    getchar();
    if (c == 'S') {
      sell[a] += b;
    } else {
      buy[a] += b;
    }
  }
  for (i = 0; i < 100002; i++) {
    if (sell[i]) va.push_back(make_pair(i, sell[i]));
    if (buy[i]) vb.push_back(make_pair(i, buy[i]));
  }
  sort(va.begin(), va.end());
  sort(vb.begin(), vb.end());
  i = s - 1;
  if (i >= va.size()) i = va.size() - 1;
  for (j = 0; i >= 0 and j < s; i--, j++)
    cout << "S " << va[i].first << " " << va[i].second << endl;
  i = vb.size() - s;
  for (k = vb.size() - 1, j = 0; k >= i and j < s and k >= 0; k--, j++)
    cout << "B " << vb[k].first << " " << vb[k].second << endl;
  return 0;
}
