#include <bits/stdc++.h>
int price_buy[1001], price_sell[1001];
int vol_sell[1001], vol_buy[1001];
int s, b;
int orders, depth;
void init() {
  int i;
  for (i = 0; i < b; i++) {
    price_buy[i] = 0;
    vol_buy[i] = 0;
  }
  for (i = 0; i < s; i++) {
    price_sell[i] = 0;
    vol_sell[i] = 0;
  }
  s = b = 0;
}
int partition(int low, int high, int A[1001], int B[1001]) {
  int pivot, i, j, temp1, temp2;
  pivot = A[low];
  i = low;
  j = high + 1;
  while (1) {
    do {
      ++i;
    } while (A[i] <= pivot && i <= high);
    do {
      --j;
    } while (A[j] > pivot);
    if (i >= j) break;
    temp1 = A[i];
    temp2 = B[i];
    A[i] = A[j];
    B[i] = B[j];
    A[j] = temp1;
    B[j] = temp2;
  }
  temp1 = A[low];
  temp2 = B[low];
  A[low] = A[j];
  B[low] = B[j];
  A[j] = temp1;
  B[j] = temp2;
  return j;
}
void quicksort(int low, int high, int A[1001], int B[1001]) {
  int j;
  if (low < high) {
    j = partition(low, high, A, B);
    quicksort(low, j - 1, A, B);
    quicksort(j + 1, high, A, B);
  }
}
int check(int price, char ch) {
  int i;
  if (ch == 'B') {
    for (i = 0; i < b; i++) {
      if (price_buy[i] == price) {
        return i;
      }
    }
    return b;
  } else {
    for (i = 0; i < s; i++) {
      if (price_sell[i] == price) {
        return i;
      }
    }
    return s;
  }
}
void readcase() {
  int i, index;
  int price, vol;
  char ch, enter;
  for (i = 0; i < orders; i++) {
    getchar();
    scanf("%c %d %d", &ch, &price, &vol);
    index = check(price, ch);
    if (ch == 'B') {
      price_buy[index] = price;
      vol_buy[index] += vol;
      if (index == b) b++;
    } else {
      price_sell[index] = price;
      vol_sell[index] += vol;
      if (index == s) s++;
    }
  }
}
void sort_ascending() {
  quicksort(0, s - 1, price_sell, vol_sell);
  quicksort(0, b - 1, price_buy, vol_buy);
}
void print_answer() {
  int i;
  if (s >= depth) {
    for (i = depth - 1; i >= 0; i--) {
      printf("S %d %d\n", price_sell[i], vol_sell[i]);
    }
  } else {
    for (i = s - 1; i >= 0; i--) {
      printf("S %d %d\n", price_sell[i], vol_sell[i]);
    }
  }
  if (b >= depth) {
    for (i = b - 1; depth > 0; i--, depth--) {
      printf("B %d %d\n", price_buy[i], vol_buy[i]);
    }
  } else {
    for (i = b - 1; i >= 0; i--) {
      printf("B %d %d\n", price_buy[i], vol_buy[i]);
    }
  }
}
void solvecase() {
  sort_ascending();
  print_answer();
}
int main() {
  while (scanf("%d %d", &orders, &depth) == 2) {
    readcase();
    solvecase();
    init();
  }
}
