#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T pow(T a, T b, long long m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans % m;
}
struct order {
  long long price;
  long long qty;
};
bool vis[2][100005];
int ind[2][100005];
bool cmp(order a, order b) {
  if (a.price != b.price) {
    return a.price < b.price;
  } else
    return a.qty < b.qty;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, s;
  cin >> n >> s;
  order st[2][n];
  char dir;
  int pr, qt;
  int k1 = 0, k2 = 0;
  for (int i = 0; i < n; i++) {
    cin >> dir >> pr >> qt;
    if (dir == 'B') {
      if (vis[0][pr]) {
        int id = ind[0][pr];
        st[0][id].qty += qt;
      } else {
        st[0][k1].price = pr;
        st[0][k1].qty = qt;
        vis[0][pr] = 1;
        ind[0][pr] = k1;
        k1++;
      }
    } else {
      if (vis[1][pr]) {
        int id = ind[1][pr];
        st[1][id].qty += qt;
      } else {
        st[1][k2].price = pr;
        st[1][k2].qty = qt;
        vis[1][pr] = 1;
        ind[1][pr] = k2;
        k2++;
      }
    }
  }
  sort(st[0], st[0] + k1, cmp);
  sort(st[1], st[1] + k2, cmp);
  order ans[2 * s];
  for (int i = 0; i < 2 * s; i++) {
    ans[i].price = -1;
  }
  int l = s - 1;
  for (int i = k1 - 1; i >= 0; i--) {
    if (l < 0) break;
    ans[l] = st[0][i];
    l--;
  }
  l = s;
  for (int i = 0; i < k2; i++) {
    if (l == 2 * s) break;
    ans[l] = st[1][i];
    l++;
  }
  for (int i = 2 * s - 1; i >= 0; i--) {
    if (ans[i].price != -1) {
      if (i >= s)
        cout << 'S' << " " << ans[i].price << " " << ans[i].qty << "\n";
      else
        cout << 'B' << " " << ans[i].price << " " << ans[i].qty << "\n";
    }
  }
}
