import java.util.*; public class Main { public static void main(String[] args) {
Scanner cin = new Scanner(System.in); while (cin.hasNext()) {
Map<Integer,Integer> S = new TreeMap<>(new Comparator<Integer>(){ @Override public int compare(Integer o1, Integer o2) { return o2-o1;
}
});
Map<Integer,Integer> B = new TreeMap<>(new Comparator<Integer>(){ @Override public int compare(Integer o1, Integer o2) { return o2-o1;
}
}); int n = cin.nextInt(); int s = cin.nextInt(); for (int i = 0; i <n; i++) {
String flagB = cin.next(); if (flagB.equals("B")){ int one = cin.nextInt(); int two = cin.nextInt(); if (B.containsKey(one)){
B.put(one,B.get(one)+two);
}else {
B.put(one,two);
}
}else { int one = cin.nextInt(); int two = cin.nextInt(); if (S.containsKey(one)){
S.put(one,S.get(one)+two);
}else {
S.put(one,two);
}
}
} // 显示 int countS = 0;
Iterator itS = S.keySet().iterator(); while (itS.hasNext()&&countS<s){
Object key = itS.next();
Object value = S.get(key);
System.out.println("S "+key+" "+value);
countS++;
} int countB = 0;
Iterator itB = B.keySet().iterator(); while (itB.hasNext()&&countB<s){
Object key = itB.next();
Object value = B.get(key);
System.out.println("B "+key+" "+value);
countB++;
}
}
}
}