/*
	[NWERC'10] STOCK PRICES
	by: Jan Kuipers
*/

#include <iostream>
#include <set>

using namespace std;

int main () {

	int runs;
	cin >> runs;

	while (runs--) {
		int N;
		cin >> N;
		
		int last = 0;
		multiset<int, greater<int> > buy;
		multiset<int> sell;
		
		while (N--) {
			
			string order,dummy;
			int n,x;
			
			cin >> order >> n >> dummy >> dummy >> x;
			
			while (n--)
				if (order=="buy")
					buy.insert(x);
				else
					sell.insert(x);
			
			while (buy.size()>0 && sell.size()>0 && *buy.begin() >= *sell.begin()) {
				last = *sell.begin();
				buy.erase(buy.begin());
				sell.erase(sell.begin());
			}
			
			if (sell.size()>0) cout << *sell.begin();	else cout << "-";
			cout << " ";
			if (buy.size()>0) cout << *buy.begin();	else cout << "-";
			cout << " ";
			if (last>0) cout << last; else cout << "-";
			cout << endl;
		}
	}
	
	return 0;
}
