#include <bits/stdc++.h>
const int maxn = 1e6 + 7;
long long a[maxn];
long long b[maxn];
long long ans;
unsigned int countSetBits(long long n) {
  unsigned int count = 0;
  while (n) {
    n &= (n - 1);
    count++;
  }
  return count;
}
int by(long long* arr, int s, int e, long long num) {
  int mid = (s + e) / 2;
  if (s > e) return mid;
  if (arr[mid] == num) {
    by(arr, mid + 1, e, num);
  } else if (arr[mid] > num) {
    by(arr, s, mid - 1, num);
  } else {
    by(arr, mid + 1, e, num);
  }
}
using namespace std;
int main() {
  int s, p;
  cin >> p >> s;
  map<long long, long long> m1, m2;
  for (int i = 0; i < p; i++) {
    char a;
    long long asom, bsom;
    cin >> a >> asom >> bsom;
    if (a == 'B') {
      m1[asom] += bsom;
    } else
      m2[asom] += bsom;
  }
  int z = s;
  if (m2.size() != 0) {
    auto it = m2.begin();
    auto bt = m2.end();
    vector<pair<long long, long long>> v;
    int i = 0;
    while (s--) {
      v.push_back(make_pair(it->first, it->second));
      it++;
      if (it == bt) break;
      i++;
    }
    s = z;
    i = v.size() - 1;
    while (i >= 0) {
      cout << "S " << v[i].first << " " << v[i].second;
      if (s) cout << endl;
      i--;
    }
  }
  if (m1.size() != 0) {
    auto it = m1.end();
    it--;
    s = z;
    auto bt = m1.begin();
    bt--;
    while (s--) {
      if (s == z - 1) cout << endl;
      cout << "B " << it->first << " " << it->second;
      it--;
      if (it == bt) break;
      if (s) cout << endl;
    }
  }
  return 0;
}
