#include <bits/stdc++.h>
using namespace std;
const int N = 2000;
struct asd {
  char ch;
  int x, y, p;
} a[N], v[N];
bool cmp(asd p1, asd p2) { return (p1.x < p2.x); }
bool cmp1(asd p1, asd p2) { return (p1.x > p2.x); }
int main() {
  int n, s;
  cin >> n >> s;
  for (int i = 1; i <= n; i++) {
    char ch;
    int x, y;
    cin >> a[i].ch >> a[i].x >> a[i].y;
    a[i].p = i;
  }
  sort(a + 1, a + 1 + n, cmp);
  int kol = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i].ch == 'S' && a[i].x == v[kol].x) {
      v[kol].y += a[i].y;
      continue;
    }
    if (a[i].ch == 'S' && kol + 1 <= s) {
      v[++kol] = a[i];
      continue;
    }
  }
  int kol1 = 0;
  for (int i = n; i >= 1; i--) {
    if (a[i].ch == 'B' && a[i].x == v[kol].x) {
      v[kol].y += a[i].y;
      continue;
    }
    if (a[i].ch == 'B' && kol1 + 1 <= s) {
      v[++kol] = a[i];
      kol1++;
      continue;
    }
  }
  sort(v + 1, v + 1 + kol, cmp1);
  for (int i = 1; i <= kol; i++) {
    cout << v[i].ch << " " << v[i].x << " " << v[i].y << endl;
  }
  return 0;
}
