for i in range(input()):
	string = raw_input()
	print "".join([string[0],string[-1]])
2fe177acff25532ef209bee67ed1469dadb908ab
for i in range(input()):
	string = raw_input()
	print "".join([string[0],string[-1]])