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