for i in range(int(input())): s = input() print(s[0]+s[-1])