#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, j, k, t, n, m, a, b, c, x, y, z, s;
  cin >> n >> s;
  char ch;
  map<long long int, long long int> map1;
  map<long long int, long long int> map2;
  for (i = 1; i <= n; i++) {
    cin >> ch >> x >> y;
    if (ch == 'B') {
      map1[x] += y;
    } else
      map2[x] += y;
  }
  map<long long int, long long int>::reverse_iterator it;
  long long int cnt = 0;
  if (map2.size() <= s) {
    for (it = map2.rbegin(); it != map2.rend(); it++) {
      cnt++;
      cout << "S"
           << " " << it->first << " " << it->second;
      printf("\n");
      if (cnt >= s) break;
    }
  } else {
    long long int t1 = map2.size() - s;
    it = map2.rbegin();
    if (t1) {
      for (; it != map2.rend();) {
        it++;
        t1--;
        if (t1 <= 0) break;
      }
    }
    for (; it != map2.rend(); it++) {
      cnt++;
      cout << "S"
           << " " << it->first << " " << it->second;
      printf("\n");
      if (cnt >= s) break;
    }
  }
  map<long long int, long long int>::reverse_iterator it1;
  cnt = 0;
  for (it1 = map1.rbegin(); it1 != map1.rend(); it1++) {
    cnt++;
    cout << "B"
         << " " << it1->first << " " << it1->second;
    printf("\n");
    if (cnt >= s) break;
  }
  return 0;
}
