import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	auto n = readln.chomp.to!int;
	foreach (_; 0..n) {
		auto str = readln.chomp;
		char[] res;
		res ~= str[0];
		char pre = res[0];
		for (int p = 1; p < str.length; p += 3) {
			if (str[p..p+2] == "->" && res[$-1] == pre) {
				res ~= str[p+2];
			} else if (str[p..p+2] == "<-" && res[0] == pre) {
				res = str[p+2] ~ res;
			}
			pre = str[p+2];
		}
		res.writeln;

	}
}