Polycarp has come up with a new game to play with you. He calls it "A missing bigram".

A bigram of a word is a sequence of two adjacent letters in it.

For example, word "abbaaba" contains bigrams "ab", "bb", "ba", "aa", "ab" and "ba".

The game goes as follows. First, Polycarp comes up with a word, consisting only of lowercase letters 'a' and 'b'. Then, he writes down all its bigrams on a whiteboard in the same order as they appear in the word. After that, he wipes one of them off the whiteboard.

Finally, Polycarp invites you to guess what the word that he has come up with was.

Your goal is to find any word such that it's possible to write down all its bigrams and remove one of them, so that the resulting sequence of bigrams is the same as the one Polycarp ended up with.

The tests are generated in such a way that the answer exists. If there are multiple answers, you can print any of them.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 2000$) — the number of testcases.

The first line of each testcase contains a single integer $n$ ($3 \le n \le 100$) — the length of the word Polycarp has come up with.

The second line of each testcase contains $n-2$ bigrams of that word, separated by a single space. Each bigram consists of two letters, each of them is either 'a' or 'b'.

Additional constraint on the input: there exists at least one string such that it is possible to write down all its bigrams, except one, so that the resulting sequence is the same as the sequence in the input. In other words, the answer exists.


-----Output-----

For each testcase print a word, consisting of $n$ letters, each of them should be either 'a' or 'b'. It should be possible to write down all its bigrams and remove one of them, so that the resulting sequence of bigrams is the same as the one Polycarp ended up with.

The tests are generated in such a way that the answer exists. If there are multiple answers, you can print any of them.


-----Examples-----

Input
4
7
ab bb ba aa ba
7
ab ba aa ab ba
3
aa
5
bb ab bb
Output
abbaaba
abaabaa
baa
bbabb


-----Note-----

The first two testcases from the example are produced from the word "abbaaba". As listed in the statement, it contains bigrams "ab", "bb", "ba", "aa", "ab" and "ba".

In the first testcase, the $5$-th bigram is removed.

In the second testcase, the $2$-nd bigram is removed. However, that sequence could also have been produced from the word "abaabaa". It contains bigrams "ab", "ba", "aa", "ab", "ba" and "aa". The missing bigram is the $6$-th one.

In the third testcase, all of "baa", "aab" and "aaa" are valid answers.

Source: codeforces | Difficulty: EASY
Tags: Implementation


Solutions:
t = int(input())
for _ in range(t):
	(n, l) = (int(input()), input().split())
	x = l[0]
	for i in range(1, n - 2):
		if l[i][0] == l[i - 1][-1]:
			x = x + l[i][1]
		else:
			x = x + l[i]
	x = x if len(x) == n else x + 'a'
	print(x)


for _ in range(int(input())):
	n = int(input())
	a = input().split()
	res = a[0]
	if n == 3:
		print('b' + res)
	else:
		for i in range(1, len(a)):
			str2 = a[i]
			str1 = a[i - 1]
			if str2[0] == str1[1]:
				res += str2[1]
			else:
				res += a[i]
		if len(res) != n:
			print(res + 'b')
		else:
			print(res)


for _ in range(int(input())):
	n = int(input()) - 2
	(b, i) = (input().split(), 1)
	while i < n and b[i][0] == b[i - 1][1]:
		i += 1
	b.append(b[-1][1] + 'a')
	b = b[:i] + [b[i - 1][1] + b[i][0]] + b[i:n] + [b[n - 1][1]]
	print(''.join(b[::2]))


def main():
	n = int(input())
	bigram = input().split()
	for i in range(n - 3):
		if bigram[i][1] == bigram[i + 1][0]:
			continue
		else:
			bigram.insert(i + 1, bigram[i][1] + bigram[i + 1][0])
			print(*[j[0] for j in bigram] + [bigram[-1][1]], sep='')
			return
	print(*[j[0] for j in bigram] + [bigram[-1][1] * 2], sep='')
for _ in range(int(input())):
	main()


import sys
t = int(sys.stdin.readline())
ans = []
for _ in range(t):
	n = int(sys.stdin.readline())
	arr = sys.stdin.readline().split()
	res = arr[0]
	for s in arr[1:]:
		if s[0] == res[-1]:
			res += s[1]
		else:
			res += s
	if len(res) < n:
		res += 'a'
	ans.append(res)
print('\n'.join(ans))


for _ in range(int(input())):
	n = int(input())
	s = input().split()
	r = s[0]
	for i in s[1:]:
		if r[-1] != i[0]:
			r += i
		else:
			r += i[1]
	if len(r) != n:
		r += 'a'
	print(r)


t = int(input())
from collections import Counter
for _ in range(t):
	n = int(input())
	bis = input().split()
	sbis = ''.join(bis)
	if len(bis) == 1:
		print(bis[0] + 'a')
		continue
	s = [bis[0]]
	i = 1
	while 1:
		if len(s) >= n or i >= len(bis):
			break
		if s[-1][-1] == bis[i][0]:
			s.append(bis[i][1])
		else:
			s.append(bis[i])
		i += 1
	print(''.join(s) + sbis[-1] * (n - len(''.join(s))))


t = int(input())
for _ in range(t):
	n = int(input())
	(*b,) = map(str, input().split())
	ans = b[0][0]
	flag = False
	for i in range(1, n - 2):
		if b[i][0] == b[i - 1][1]:
			ans += b[i][0]
		else:
			flag = True
			ans += b[i - 1][1] + b[i][0]
	ans += b[-1][1]
	if flag:
		print(ans)
	else:
		print(ans + b[-1][1])


def listToString(s):
	str1 = ''
	for ele in s:
		str1 += ele
	return str1
t = int(input())
while t > 0:
	m = []
	lst = []
	n = int(input())
	m = list(map(str, input().strip().split()))[:n - 2]
	marker = 0
	lst.append(m[0][0])
	for y in range(0, n - 3):
		if m[y][1] == m[y + 1][0]:
			lst.append(m[y][1])
		elif m[y][1] != m[y + 1][0]:
			lst.append(m[y][1])
			lst.append(m[y + 1][0])
			marker = 1
	lst.append(m[n - 3][1])
	if marker == 0:
		lst.append('a')
	print(listToString(lst))
	t -= 1


def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def msi():
	return map(str, input().split())

def li():
	return list(mi())
t = ii()
for _ in range(t):
	m = ii()
	a = input().split()
	n = len(a)
	if n == 1:
		print(a[0] + 'a')
	else:
		res = a[0]
		for i in range(n - 1):
			if a[i][1] == a[i + 1][0]:
				res += a[i + 1][1]
			else:
				res += a[i + 1]
		if len(res) == m:
			print(res)
		else:
			print(res + 'a')


def solver():

	def flatten(bigrams, elem, pos=None):
		final_string = ''
		if pos is None:
			for i in bigrams:
				final_string = final_string + i[0]
			final_string = final_string + elem
		else:
			for i in range(len(bigrams)):
				final_string = final_string + bigrams[i][0]
				if i == pos:
					final_string = final_string + elem[0]
			final_string = final_string + bigrams[-1][-1]
		return final_string
	n = int(input())
	for i in range(n):
		j = int(input())
		bigram_list = str(input()).split()
		missing_bigram = None
		counter = None
		for k in range(j - 3):
			first_char = bigram_list[k][1]
			second_char = bigram_list[k + 1][0]
			if first_char != second_char:
				missing_bigram = first_char + second_char
				counter = k
		if missing_bigram is None:
			final_elem = bigram_list[-1][-1]
			print(flatten(bigram_list, final_elem + final_elem))
		else:
			print(flatten(bigram_list, missing_bigram, counter))
solver()


for i in range(int(input())):
	n = int(input())
	tec = input().split()
	ans = tec[0]
	last = ans[-1]
	fl = False
	for j in tec[1:]:
		if j[0] == last:
			ans += j[1]
			last = j[1]
		else:
			ans += j
			last = j[1]
			fl = True
	if not fl:
		ans += 'a'
	print(ans)


def solve(A, n):
	N = len(A)
	ans = A[0][0]
	for i in range(1, N):
		if A[i][0] != A[i - 1][1]:
			ans += A[i - 1][1]
			ans += A[i][0]
		else:
			ans += A[i][0]
	ans += A[-1][1]
	ans += 'a' * (n - len(ans))
	print(ans)
N = int(input())
for _ in range(N):
	n = int(input())
	A = [x for x in input().split(' ')]
	solve(A, n)


t = int(input())
for i in range(t):
	n = int(input())
	ss = input()
	s = ss.split(' ')
	ans = []
	t = False
	ans.append(s[0][0])
	for j in range(0, n - 3):
		if s[j][1] != s[j + 1][0]:
			t = True
			ans.append(s[j][1])
			ans.append(s[j + 1][0])
		else:
			ans.append(s[j][1])
	ans.append(s[n - 3][1])
	if t == False:
		ans.append('a')
	for x in ans:
		print(x, end='')
	print()


def answer():
	n = int(input())
	s = list(input().split())
	x = [''] * (n - 1)
	cnt = 0
	if n == 3:
		print(s[0] + 'a')
		return
	for i in range(n - 3):
		if s[i][1] != s[i + 1][0]:
			x[cnt] = s[i]
			cnt += 1
			x[cnt] = s[i][1] + s[i + 1][0]
		else:
			x[cnt] = s[i]
		cnt += 1
	x[cnt] = s[-1]
	if cnt == i + 1:
		x[-1] = s[-1][1] + 'a'
	ans = x[0][0]
	for i in range(n - 1):
		ans += x[i][1]
	print(ans)
for _ in range(int(input())):
	answer()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class SegmentTree:

	def __init__(self, data, default, func):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		start += self._size
		stop += self._size
		res_left = res_right = self._default
		while start < stop:
			if start & 1:
				res_left = self._func(res_left, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res_right = self._func(self.data[stop], res_right)
			start >>= 1
			stop >>= 1
		return self._func(res_left, res_right)

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict, deque
from math import ceil, floor, sqrt, log2, gcd, pi
from heapq import heappush, heappop
from bisect import bisect_left, bisect
from functools import reduce
from copy import deepcopy
from itertools import permutations
import sys
abc = 'abcdefghijklmnopqrstuvwxyz'
ABC = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
dig = '012345678901'
odd = '13579'
mod = 998244353
for _ in range(int(input())):
	n = int(input())
	arr = list(input().split())
	ans = ''
	for i in arr:
		if ans != '' and ans[-1] == i[0]:
			ans += i[1]
		else:
			ans += i
	if len(ans) != n:
		ans += (n - len(ans)) * 'a'
	print(ans)


t = int(input())
for x in range(t):
	n = int(input())
	row = input().split()
	for i in range(1, len(row)):
		if row[i - 1][1] != row[i][0]:
			row.insert(i, row[i - 1][1] + row[i][0])
			break
	if len(row) == n - 2:
		row.append(row[-1][1] + 'a')
	ans = [b[0] for b in row] + [row[-1][1]]
	ans = ''.join(ans)
	assert len(ans) == n
	check = []
	for i in range(n - 1):
		check.append(ans[i:i + 2])
	assert check == row
	print(ans)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
sys.setrecursionlimit(100000000)

def solve():
	n = int(input())
	s = ''.join(map(str, input().split()))
	ans = ''
	for i in range(1, len(s) - 1, 2):
		if s[i] != s[i + 1]:
			ans = ans + s[i] + s[i + 1]
		else:
			ans += s[i]
	res = s[0] + ans + s[-1]
	if len(res) < n:
		return res + 'a'
	else:
		return res

def main():
	t = int(input())
	while t:
		print(solve())
		t -= 1
main()


def fun(li, n):
	st = ''
	if len(li) == 1:
		x = n - len(li[0])
		st = li[0] + li[0][1] * x
		return st
	else:
		for i in range(len(li)):
			if i == 0:
				st = st + li[0]
			elif li[i][0] == pre:
				st = st + li[i][1]
			else:
				st = st + li[i]
			pre = li[i][1]
		if len(st) != n:
			y = n - len(st)
			st = st + st[-1] * y
		return st
t = int(input())
for z in range(t):
	n = int(input())
	li = [x for x in input().split()]
	res = fun(li, n)
	print(res)


s = ''
verb = ''
missd = False
(t, n) = (int(input()), 0)
for i in range(t):
	n = int(input())
	s = input().split()
	verb += s[0]
	for j in range(1, n - 2):
		if s[j][0] != verb[-1]:
			verb += s[j]
			missd = True
		else:
			verb += s[j][1]
	if not missd:
		verb += 'b'
	print(verb)
	verb = ''
	missd = False


def bigram(n, bi):
	a = []
	a.append(bi[0][0])
	if len(bi) == 1:
		a.append(bi[0][1])
		a.append(bi[0][1])
		print(''.join(a))
		return
	for i in range(1, len(bi)):
		if bi[i][0] != bi[i - 1][1]:
			a.append(bi[i - 1][1])
		a.append(bi[i][0])
	a.append(bi[-1][1])
	while len(a) < n:
		a.append(a[-1])
	print(''.join(a))
t = int(input())
for _ in range(t):
	n = int(input())
	bi = input().split()
	bigram(n, bi)


t = int(input())
while t:
	t -= 1
	n = int(input())
	dat = list(map(str, input().split()))
	ans = dat[0]
	for i in range(1, len(dat)):
		if dat[i][0] != dat[i - 1][1]:
			ans += dat[i]
		else:
			ans += dat[i][1]
	if len(ans) != n:
		ans += 'a'
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = []
	ans = ''
	if n == 3:
		g = input()
		print(g + 'a')
	else:
		l = list(map(str, input().split()))
		ans += l[0][0]
		for x in range(1, n - 2):
			if l[x][0] == l[x - 1][1]:
				ans += l[x][0]
			else:
				ans += l[x - 1][1]
				ans += l[x][0]
		ans += l[-1][1]
		if len(ans) != n:
			ans += 'a'
		print(ans)


class Solution:

	def find(self, j, arr):
		string = arr[0]
		for i in range(1, len(arr), 1):
			if arr[i][0] == string[-1]:
				string += arr[i][1]
			else:
				string += arr[i]
		while len(string) < j:
			string += 'a'
		print(string[:j])
t = int(input())
obj = Solution()
for _ in range(t):
	j = int(input())
	obj.find(j, input().split())


def solution():
	n = int(input())
	a = list(input().split())
	s = a[0]
	for i in range(1, n - 2):
		if a[i][0] != s[-1]:
			s += a[i]
			continue
		s += a[i][1]
	if len(s) != n:
		s += 'a'
	print(s)
t = int(input())
for _ in range(t):
	solution()


import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def word_from_bigrams(bigrams):
	all_bigrams = []
	added = False
	for i in range(len(bigrams) - 1):
		all_bigrams += [bigrams[i]]
		if bigrams[i][1] != bigrams[i + 1][0]:
			all_bigrams += [bigrams[i][1] + bigrams[i + 1][0]]
			added = True
	all_bigrams += [bigrams[-1]]
	if not added:
		all_bigrams += [bigrams[-1][1] + 'a']
	s = ''
	for i in range(len(all_bigrams) - 1):
		s += all_bigrams[i][0]
	s += all_bigrams[-1]
	sys.stdout.write(f'{s}\n')
for _ in range(int(input())):
	n = int(input())
	bigrams = input().decode().split()
	word_from_bigrams(bigrams)


t = int(input())
for i in range(t):
	n = int(input())
	bigrams = list(input().strip().split())
	if n == 3:
		print(bigrams[0] + 'a')
		continue
	newl = []
	for (ind, bg) in enumerate(bigrams[:n - 3]):
		if bg[1] != bigrams[ind + 1][0]:
			newl.append(bg)
			newl.append(bg[1] + bigrams[ind + 1][0])
		else:
			newl.append(bg)
	newl.append(bigrams[-1])
	res = newl[0]
	for bg in newl[1:]:
		res += bg[1]
	if len(res) < n:
		res += res[0]
	print(res)


import sys
import math

def run(function):

	def wrapper(*args, **kwargs):
		testcases = int(input())
		for _ in range(testcases):
			function(*args, **kwargs)
	return wrapper

def map_input(datatype=int):
	return map(datatype, input().split())

def list_input(datatype=int):
	return list(map(datatype, input().split()))

@run
def solve():
	n = int(input())
	arr = list_input(str)
	ans = ' '
	for i in arr:
		if i[0] == ans[-1]:
			ans += i[1]
		else:
			ans += i
	ans = ans[1:]
	if len(ans) < n:
		while len(ans) != n:
			ans += 'a'
	print(ans)
solve()


t = int(input())
for i in range(t):
	n = int(input())
	a = [x for x in input().split()]
	s = a[0][0]
	for j in range(len(a) - 1):
		if a[j][1] == a[j + 1][0]:
			s += a[j][1]
		else:
			s += a[j][1] + a[j + 1][0]
	s += a[-1][1]
	if len(s) == n:
		print(s)
	else:
		print(s + s[-1])


import itertools
from math import floor, log, log2, ceil, sqrt
from itertools import groupby
from decimal import Decimal, getcontext
import sys
from collections import deque
primes = set()
maxN = 1000001

def generatePrimes():
	used = [False] * maxN
	for i in range(2, maxN):
		if not used[i]:
			primes.add(i)
			for j in range(i, maxN, i):
				used[j] = True

def isPrime(n):
	if n < 2:
		return True
	x = 2
	while x * x <= n:
		if n % x == 0:
			return False
		x += 1
	return True
t = int(input())
res = []
for _ in range(t):
	n = int(input())
	arr = list(input().split())
	ans = ''
	exists = False
	for i in range(n - 2):
		if i == 0:
			ans += arr[0]
		else:
			if arr[i][0] != arr[i - 1][1]:
				exists = True
				ans += arr[i][0]
			ans += arr[i][1]
	if not exists:
		ans += 'a'
	res.append(ans)
for i in range(t):
	print(res[i])


for i in range(int(input())):
	n = int(input())
	s = list(map(str, input().split()))
	ans = s[0]
	for i in range(1, n - 2):
		if s[i][0] == s[i - 1][1]:
			ans += s[i][1]
		else:
			ans += s[i]
	if len(ans) == n:
		print(ans)
	else:
		ans += 'b'
		print(ans)


def getInts():
	return list(map(int, input().split()))
[T] = getInts()
for case in range(T):
	[n] = getInts()
	bigs = input()
	bigs = list(bigs.split(' '))
	if n == 3:
		print(bigs[0] + 'a')
		continue
	ans = [bigs[0][0]]
	hasFound = False
	for i in range(1, len(bigs)):
		if bigs[i - 1][1] != bigs[i][0]:
			ans.append(bigs[i - 1][1])
			ans.append(bigs[i][0])
			hasFound = True
		else:
			ans.append(bigs[i][0])
	if hasFound:
		ans.append(bigs[-1][-1])
	else:
		ans.append(bigs[-1][-1])
		ans.append('a')
	print(''.join(ans))


for _ in range(int(input())):
	n = int(input())
	s = input().split()
	for i in range(n - 3):
		if s[i][1] != s[i + 1][0]:
			s.insert(i + 1, s[i][1] + s[i + 1][0])
			break
	else:
		s.append(s[-1][1] + 'a')
	print(s[0][0], end='')
	for i in range(n - 1):
		print(s[i][1], end='')
	print()


def sample():
	return
for i in range(int(input())):
	sample()
	num = int(input())
	st = list(map(str, input().split()))
	lst = ''
	for i in range(len(st) - 1):
		if st[i][1] == st[i + 1][0]:
			lst = lst + st[i][0]
		else:
			lst = lst + st[i]
	lst = lst + st[-1]
	if len(lst) < num:
		lst = lst + 'a' * (num - len(lst))
	print(lst)


def solve(bigrams, length):
	prev = bigrams[0]
	for (i, bigram) in enumerate(bigrams[1:]):
		if prev[1] != bigram[0]:
			bigrams.insert(i + 1, f'{prev[1]}{bigram[0]}')
			break
		prev = bigram
	ans = bigrams[0]
	for bigram in bigrams[1:-2]:
		ans += bigram[1]
	ans += bigrams[-1]
	while len(ans) < length:
		ans += 'a'
	print(ans[:length])
C = int(input())
for _ in range(C):
	L = int(input())
	bigrams = input().split(' ')
	solve(bigrams, L)


deekht2 = int(input())
while deekht2 != 0:
	dcrtg = int(input())
	vfty7 = input().split()
	deeklai9 = vfty7[0]
	for i in vfty7[1:]:
		if deeklai9[-1] != i[0]:
			deeklai9 += i
		else:
			deeklai9 += i[1]
	if len(deeklai9) != dcrtg:
		deeklai9 += 'a'
	print(deeklai9)
	deekht2 -= 1


for _ in range(int(input())):
	n = int(input())
	l = input().split()
	ans = l[0]
	f = 0
	for i in range(1, n - 2):
		if l[i][0] == l[i - 1][1]:
			ans += l[i][1]
		else:
			f = 1
			ans += l[i]
	if f == 1:
		print(ans)
	else:
		print(ans + 'a')


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(str, input().split()))
	ans = ''
	first = True
	found = False
	ans += A[0][0]
	for (idx, (before, after)) in enumerate(zip(A, A[1:])):
		if before[1] == after[0]:
			ans += before[1]
		else:
			ans += before[1]
			ans += after[0]
			found = True
		if idx == n - 4:
			ans += after[1]
			if found == False:
				ans += after[1]
	if len(A) == 1:
		ans += A[0]
	print(ans)


def main():
	t = int(input())
	while t:
		x = int(input())
		l = input().split()
		res = l[0][0]
		flag = 0
		for i in range(len(l)):
			if i == len(l) - 1:
				res += l[i][-1]
				break
			if l[i][-1] == l[i + 1][0]:
				res += l[i][-1]
			else:
				flag = 1
				res += l[i][-1]
				res += l[i + 1][0]
		if flag == 0 and len(res) != x:
			res += res[-1]
		print(res)
		t -= 1
main()


for s in [*open(0)][2::2]:
	(a, b) = zip(*s.split())
	(r, *a) = a
	for (x, y) in zip(b, a):
		r += (x + y)[x == y:]
	print((r + 2 * b[-1])[:len(b) + 2])


T = int(input())
for t in range(T):
	n = int(input())
	bis = [s for s in input().split()]
	ans = None
	for i in range(n - 3):
		if bis[i][1] == bis[i + 1][0]:
			continue
		ans = (i, bis[i][1] + bis[i + 1][0])
	if ans:
		bis = bis[:ans[0] + 1] + [ans[1]] + bis[ans[0] + 1:]
		word = ''.join([b[0] for b in bis])
		word += bis[len(bis) - 1][1]
		print(word)
	else:
		word = ''.join([b[0] for b in bis])
		word += bis[len(bis) - 1][1] + 'a'
		print(word)


from sys import stdin
test = int(stdin.readline())
for t in range(test):
	n = int(stdin.readline())
	strings = stdin.readline().rstrip().split()
	ans = strings[0]
	for i in range(1, len(strings)):
		if ans[-1] == strings[i][0]:
			ans = ans + strings[i][1:]
		else:
			ans = ans + strings[i]
	if len(ans) == n:
		print(ans)
	else:
		print(ans + 'a')


for i in range(int(input())):
	n = int(input())
	b = list(input().split())
	ans = []
	ans.append(b[0][0])
	for i in range(len(b) - 1):
		if b[i][1] == b[i + 1][0]:
			ans.append(b[i][1])
		else:
			ans.append(b[i][1] + b[i + 1][0])
	ans.append(b[-1][1])
	if len(''.join(ans)) != n:
		ans.append('a')
	print(''.join(ans))


def main(t):
	n = int(input())
	arr = input().split()
	flag = False
	for i in range(n - 3):
		if arr[i][1] != arr[i + 1][0]:
			arr.insert(i + 1, arr[i][1] + arr[i + 1][0])
			flag = True
			break
	if not flag:
		arr.append(arr[-1][0] + 'a')
	ans = [arr[0]]
	for i in range(1, len(arr)):
		ans.append(arr[i][1])
	print(''.join(ans))
T = int(input())
t = 1
while t <= T:
	main(t)
	t += 1


t = int(input())
while t:
	n = int(input())
	bigrams = input().split()
	res = bigrams[0]
	for i in range(len(bigrams) - 1):
		if bigrams[i][1] != bigrams[i + 1][0]:
			res += bigrams[i + 1]
			continue
		res += bigrams[i + 1][1]
	if len(res) != n:
		res += 'b'
	print(res)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	s = input()
	if len(s) == 2:
		s = s + 'a'
	else:
		s = s.replace('b b', 'b')
		s = s.replace('a a', 'a')
		s = s.replace('a b', 'ab')
		s = s.replace('b a', 'ba')
		if len(s) < n:
			s = s + 'a'
	print(s)


tc = int(input())
for case in range(tc):
	n = int(input())
	parejas = [i for i in input().split()]
	my_str = parejas[0]
	for pos in range(1, len(parejas)):
		if parejas[pos][0] != my_str[-1]:
			my_str += parejas[pos]
		else:
			my_str += parejas[pos][1]
	if len(my_str) != n:
		my_str += 'a'
	print(my_str)


def find_word(bigram_arr):
	idx = 1
	prev_elem = bigram_arr[0]
	arr_size = size - 2
	for j in range(1, arr_size):
		if prev_elem[1:] != bigram_arr[j][:1]:
			temp_elem = prev_elem[1:] + bigram_arr[j][:1]
			bigram_arr.insert(idx, temp_elem)
			break
		idx += 1
		prev_elem = bigram_arr[j]
	word = bigram_arr[0][::1]
	for k in range(1, len(bigram_arr)):
		word = word + bigram_arr[k][1:]
	word_size = len(word)
	if word_size != size:
		flag = True
		while flag:
			lst_alpha = word[word_size - 1]
			word = word + lst_alpha
			if len(word) == size:
				flag = False
	print(word)
t = int(input())
for i in range(t):
	size = int(input())
	user_input = input().split()
	find_word(user_input)


for t in range(int(input())):
	n = int(input())
	b = input()
	b = b.replace('b b', 'b')
	b = b.replace('a a', 'a')
	b = b.replace(' ', '')
	while len(b) != n:
		b += 'a'
	print(b)


import sys
import math
from collections import deque, Counter
from sys import stdin
int1 = lambda x: int(x) - 1
stinput = lambda : stdin.readline()[:-1]
ii = lambda : int(stinput())
mi = lambda : map(int, stdin.readline().split())
li = lambda : list(mi())
mi1 = lambda : map(int1, stdin.readline().split())
li1 = lambda : list(mi1())
mis = lambda : map(str, stdin.readline().split())
lis = lambda : list(mis())
from collections import defaultdict
import heapq
mod = 10 ** 9 + 7
Mod = 998244353
INF = 10 ** 18
ans = 0
t = ii()
for _ in range(t):
	n = ii()
	x = lis()
	ans = []
	for i in x[0]:
		ans.append(i)
	for s in x[1:]:
		(i, j) = (s[0], s[1])
		if ans[-1] == i:
			ans.append(j)
		else:
			ans.append(i)
			ans.append(j)
	ans.append('a' * (n - len(ans)))
	print(''.join(ans))


n = int(input())
while n != 0:
	x = int(input())
	lst = input().split()
	st = lst[0][0]
	for it in lst:
		if it[0] != st[-1]:
			st += it
		else:
			st += it[1]
	if len(st) < x:
		st += 'a' * (x - len(st))
	print(st)
	n -= 1


Test_case = int(input())
output = []
for t in range(Test_case):
	Polycrab = ''
	length = int(input())
	bigrams = input()
	seq = bigrams.split()
	for index in range(length - 3):
		if seq[index][1] != seq[index + 1][0]:
			seq.insert(index + 1, seq[index][1] + seq[index + 1][0])
	for bigram in seq[:-1]:
		Polycrab += bigram[0]
	Polycrab += seq[-1]
	if len(seq) == length - 2:
		Polycrab += 'a'
	output.append(Polycrab)
for res in output:
	print(res)


t = int(input())
for i in range(t):
	n = int(input())
	a = input().split()
	u = 0
	st = ''
	for i in range(len(a) - 1):
		if a[i][1] != a[i + 1][0]:
			u = i
			st = a[i][1] + a[i + 1][0]
	b = []
	if st != '':
		for i in range(u + 1):
			b.append(a[i])
		b.append(st)
		for i in range(u + 1, len(a)):
			b.append(a[i])
	if st == '':
		b = a.copy()
		st = a[len(a) - 1][1] * 2
		b.append(st)
	srt = ''
	for i in b:
		srt += i[0]
	srt += b[len(b) - 1][1]
	print(srt)


for _ in range(int(input())):
	n = int(input())
	x = input().split()
	k = ''
	for i in x:
		if not len(k):
			k += i
			continue
		if k[-1] == i[0]:
			k += i[1]
		else:
			k += i
	k = k + 'a' * (n - len(k))
	print(k)


def create_string(bgrm_list):
	size = len(bgrm_list)
	ret_str = ''
	for ele in bgrm_list:
		ret_str += ele[0]
	ret_str += bgrm_list[size - 1][1]
	return ret_str

def mismatch(bgrm_list):
	mis_ind = -1
	size = len(bgrm_list)
	for i in range(1, size):
		if bgrm_list[i][0] != bgrm_list[i - 1][1]:
			mis_ind = i
	return mis_ind
t = int(input())
for i in range(t):
	n = int(input())
	og_bgrm = input()
	bgrm_list = og_bgrm.split()
	mis_ind = mismatch(bgrm_list)
	if mis_ind == -1:
		inserter = ''
		inserter += bgrm_list[n - 3][1]
		inserter += inserter[0]
		bgrm_list.append(inserter)
	else:
		inserter = ''
		inserter += bgrm_list[mis_ind - 1][1]
		inserter += bgrm_list[mis_ind][0]
		bgrm_list.insert(mis_ind, inserter)
	ret_str = create_string(bgrm_list)
	print(ret_str)


import sys
from typing import List

def solve(arr: List, n):
	ans = ''
	ans = arr[0][0] + arr[0][1]
	k = len(arr)
	i = 1
	while i < k:
		ele = arr[i]
		if ele[0] != arr[i - 1][1]:
			ele = arr[i - 1][1] + ele[0]
			arr.insert(i, ele)
		ans += ele[1]
		k = len(arr)
		i += 1
	if len(ans) == n:
		return ans
	else:
		return ans + 'a'
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	arr = list(sys.stdin.readline().strip().split())
	ans = solve(arr, n)
	print(ans)


q = int(input())
while q != 0:
	n = int(input())
	s = input().split()
	r = s[0]
	for i in s[1:]:
		if r[-1] != i[0]:
			r += i
		else:
			r += i[1]
	if len(r) != n:
		r += 'a'
	print(r)
	q -= 1


sr = lambda : input()
ir = lambda : int(sr())
lr = lambda : list(map(int, sr().split()))
inf = 10 ** 18
mod = 998244353
test = ir()
for t in range(test):
	n = ir()
	a = sr().split()
	if n == 3:
		print(''.join(['a', a[0]]))
	else:
		flg = False
		pre = a[0][1]
		ans = [a[0]]
		for c in a[1:]:
			if pre == c[0]:
				ans.append(c[1])
			else:
				ans.append(c)
				flg = True
			pre = c[1]
		if not flg:
			ans.append('a')
		print(''.join(ans))


t = int(input())
while t > 0:
	n = int(input())
	l = input().split()
	s = l[0]
	for i in range(1, n - 2):
		if l[i - 1][1] == l[i][0]:
			s = s + l[i][1]
		else:
			s = s + l[i]
	if len(s) == n:
		print(s)
	else:
		s = s + 'a'
		print(s)
	t = t - 1


t = int(input())
for i in range(0, t):
	n = int(input())
	b = list(map(str, input().split()))
	s = b[0]
	for j in range(0, n - 3):
		if b[j][1] == b[j + 1][0]:
			s += b[j + 1][1]
		else:
			s += b[j + 1][0] + b[j + 1][1]
	if len(s) != n:
		s += 'a'
	print(s)


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(str, input().split()))
	s = lst[0]
	for j in range(1, len(lst)):
		if lst[j][0] == s[len(s) - 1]:
			s += lst[j][1]
		else:
			s += lst[j]
	if len(s) != n:
		dif = n - len(s)
		s += 'a' * dif
	print(s)


def check(l1, l2):
	l3 = [l1[0], l1[1], l1[2], l1[0] + l1[1], l1[0] + l1[2], l1[1] + l1[2], l1[1] + l1[2] + l1[0]]
	return l3 == l2
for _ in range(int(input())):
	n = int(input())
	l = input().split()
	ans = ''
	for i in range(len(l) - 1):
		ans += l[i][0]
		if l[i][1] != l[i + 1][0]:
			ans += l[i][1]
	ans += l[-1][0]
	ans += l[-1][1]
	if len(ans) < n:
		ans += 'a' * (n - len(ans))
	print(ans)


import sys
from bisect import bisect_left as lb
from bisect import bisect_right as rb
from collections import deque
from queue import PriorityQueue as pq
from math import gcd
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
lii = lambda : list(map(int, list(ip())))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab, bc, cd: ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x: print(x)
prinT = lambda x: print(x)
f = lambda : sys.stdout.flush()
inv = lambda x: pow(x, mod - 2, mod)
dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]
mod = 10 ** 9 + 7
mod1 = 998244353
for _ in range(ii()):
	n = ii()
	a = input().split()
	ans = []
	ans.append(a[0][0])
	for i in range(n - 3):
		if a[i][1] != a[i + 1][0]:
			ans.append(a[i][1])
			ans.append(a[i + 1][0])
		else:
			ans.append(a[i][1])
	ans.append(a[-1][-1])
	if len(ans) != n:
		ans.append('b')
	print(''.join(ans))


for i in range(int(input())):
	n = int(input())
	l = list(map(str, input().split()))
	res = l[0]
	for i in l[1:]:
		if res[-1] == i[0]:
			res += i[1]
		else:
			res += i
	while len(res) != n:
		if res[-1] == 'a':
			res += 'b'
		else:
			res += 'a'
	print(res)


def solve(n, tempstr):
	inmid = -1
	for i in range(len(tempstr) - 1):
		if tempstr[i][1] != tempstr[i + 1][0]:
			inmid = i + 1
			break
	ans = ''
	if inmid != -1:
		for i in range(len(tempstr)):
			if i == 0 or i == inmid:
				ans += tempstr[i]
			else:
				ans += tempstr[i][1]
		if len(ans) < n:
			ans += tempstr[-1][1]
		print(ans)
		return
	else:
		for i in range(len(tempstr)):
			ans += tempstr[i][0]
		ans += tempstr[len(tempstr) - 1][1]
		ans += ans[-1]
		print(ans)
		return
t = int(input())
while t > 0:
	n = int(input())
	tempstr = input().split(' ')
	solve(n, tempstr)
	t -= 1


n = int(input())
for _ in range(n):
	t = int(input())
	a = list(input().split())
	if len(a) != 1:
		for i in range(1, len(a)):
			if a[i][0] != a[i - 1][1]:
				a.insert(i, a[i - 1][0] + a[i][0])
				break
		print(a[0], end='')
		for i in range(1, len(a)):
			print(a[i][1], end='')
		if len(a) + 1 != t:
			print(a[-1][1])
		else:
			print()
	else:
		print('a' + a[0])


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	arr = list(map(str, stdin.readline().split()))
	ans = ''
	f = 0
	n = len(arr)
	for i in range(n - 1):
		if arr[i][1] != arr[i + 1][0]:
			ans += arr[i][0]
			ans += arr[i][1]
			f = 1
		else:
			ans += arr[i][0]
	ans += arr[-1]
	if f == 0:
		ans += 'a'
	print(ans)


t = int(input())
l = []
while t:
	t = t - 1
	n = int(input())
	s = ''
	s1 = list(input().split())
	for i in s1:
		if s == '':
			s = s + i
		elif s[-1] == i[0]:
			s = s + i[1]
		else:
			s = s + i
	if len(s) != n:
		while len(s) != n:
			s = s + 'a'
	l.append(s)
for i in l:
	print(i)


k = int(input())
for i in range(k):
	n = int(input())
	ans = list()
	l = input().split()
	ans.append(l[0][0])
	for (x, y) in zip(l[:-1], l[1:]):
		if x[1] == y[0]:
			ans.append(x[1])
		else:
			ans.append(x[1])
			ans.append(y[0])
	ans.append(l[-1][1])
	if len(ans) < n:
		ans.append('a')
	print(''.join(ans))


testcase = int(input())
g = 0
while testcase > 0:
	n_length = int(input())
	strr = input().split()
	r = strr[0]
	for i in strr[1:]:
		if r[-1] != i[0]:
			r += i
			g += 1
		else:
			r += i[1]
	if len(r) != n_length:
		r += 'a'
	print(r)
	testcase -= 1


t = int(input())
while t:
	t -= 1
	n = int(input())
	s = input()
	s = s.replace('b b', 'b')
	s = s.replace('a a', 'a')
	s = s.replace(' ', '')
	if n > len(s):
		s += 'a' * (n - len(s))
	print(s)


for _ in range(int(input())):
	n = int(input())
	l = list(map(str, input().split()))
	flag = False
	ans = ''
	j = 0
	for i in range(n - 2):
		if i == 0:
			ans += l[i]
		elif ans[j] == l[i][0]:
			ans += l[i][1]
		else:
			ans += l[i]
			j += 1
			flag = True
		j += 1
	if flag == False:
		ans += 'a'
	print(ans)


for i in range(int(input())):
	n = int(input())
	s = list(input().split())
	ans = s[0]
	flag = False
	for el in s[1:]:
		if el[0] == ans[-1]:
			ans += el[1]
		else:
			ans += el
			flag = True
	if flag:
		print(ans)
	else:
		print(ans + 'a')


import sys, os, io
import math
from collections import defaultdict

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def solve():
	n = ii()
	l = [i for i in input().split()]
	new = []
	new.append(l[0][0])
	for i in range(len(l) - 1):
		if l[i][1] == l[i + 1][0]:
			new.append(l[i][1])
		else:
			new.append(l[i][1])
			new.append(l[i + 1][0])
	new.append(l[-1][-1])
	if len(new) != n:
		new.append(new[-1])
	print(''.join(new))
t = 1
t = ii()
for _ in range(t):
	solve()


try:
	import sys
	import math
	import collections
	M = 10 ** 9 + 7

	def solve():
		n = int(input())
		arr = list(map(str, input().split()))
		string = '' + arr[0]
		for i in range(1, len(arr)):
			if arr[i - 1][1] == arr[i][0]:
				string += arr[i][1]
			else:
				string += arr[i]
		if len(string) == n:
			return string
		else:
			return string + 'a' * (n - len(string))
	test = int(input())
	count1 = 1
	while count1 <= test:
		ans = solve()
		sys.stdout.write(str(ans) + '\n')
		count1 += 1
except EOFError:
	print('')


import sys
input = sys.stdin.readline
T = int(input())
R = []
for _ in range(T):
	N = int(input())
	l = input()[:-1].split()
	s = ''
	is_selected = False
	for c in l:
		if s == '':
			s += c
		elif s[-1] == c[0]:
			s += c[1]
		else:
			is_selected = True
			s += c
	if len(s) < N:
		s += 'a'
	R.append(s)
print('\n'.join(R))


import sys

def get_string():
	return sys.stdin.readline().strip()

def get_ints():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_strings():
	return list(sys.stdin.readline().strip().split())

def get_num():
	return int(sys.stdin.readline().strip())
t = get_num()
for _ in range(t):
	n = get_num()
	arr = get_strings()
	ans = arr[0]
	found = False
	for i in range(1, len(arr)):
		if ans[-1] != arr[i][0]:
			found = True
			ans += arr[i]
		else:
			ans += arr[i][1]
	if not found:
		ans += 'a'
	print(ans)


n = int(input())
for i in range(n):
	le = int(input())
	l = list(map(str, input().split()))
	st = l[0]
	for i in range(1, len(l)):
		a = l[i]
		b = l[i - 1]
		if a[0] == b[1]:
			st = st + a[1]
		else:
			st = st + a
	if len(st) != le:
		st = st + 'a'
	print(st)


t = int(input())
for _ in range(t):
	n = int(input())
	ans = ''
	stringArr = input().split()
	ans += stringArr[0]
	matchFound = False
	for i in range(1, n - 2):
		if stringArr[i - 1][1] != stringArr[i][0]:
			matchFound = True
			ans += stringArr[i]
		else:
			ans += stringArr[i][1]
	if matchFound == False:
		ans += 'a'
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	a = s.split()
	ans = ''
	ans += a[0]
	for i in range(1, len(a)):
		p = a[i]
		if ans[-1] == p[0]:
			ans += p[-1]
		else:
			ans += p
	if len(ans) == n:
		print(ans)
	elif len(ans) == 2:
		print(ans + 'a')
	else:
		print(ans + 'a' * (n - len(ans)))


z = int(input())
for _ in range(z):
	n = int(input())
	s = input()
	s = s.split(' ')
	s = ''.join(s)
	k = ''
	c = 0
	for i in range(1, len(s) - 1, 2):
		if s[i] != s[i + 1]:
			c = 1
			k += s[i] + s[i + 1]
		else:
			k += s[i]
	if c == 1:
		print(s[0] + k + s[len(s) - 1])
	else:
		print(s[0] + k + s[len(s) - 1] + 'a')


for _ in range(int(input())):
	n = int(input())
	n = n - 2
	lst = [str(x) for x in input().split()]
	if n == 1:
		print(lst[0] + 'b')
	else:
		ans = ''
		checker = False
		for i in range(n - 1):
			if lst[i][1] == lst[i + 1][0]:
				ans += lst[i][0]
			else:
				ans += lst[i][0]
				ans += lst[i][1]
				checker = True
		if not checker:
			print(ans + lst[-1] + 'b')
		else:
			print(ans + lst[-1])


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')

def solve():
	T = int(input())
	for i in range(T):
		word_len = int(input())
		bigrams = list(map(list, input().split()))
		ans = []
		ans.append(bigrams[0][0])
		for i in range(1, word_len - 2):
			if bigrams[i][0] == bigrams[i - 1][1]:
				ans.append(bigrams[i - 1][1])
			else:
				ans.append(bigrams[i - 1][1])
				ans.append(bigrams[i][0])
		ans.append(bigrams[word_len - 3][1])
		if len(ans) < word_len:
			ans.append('a')
		print(''.join(ans))
solve()


for t in range(int(input())):
	N = int(input())
	arr = list(map(str, input().split()))
	ans = arr[0]
	for i in range(1, len(arr)):
		if arr[i][0] == ans[-1]:
			ans += arr[i][1]
		else:
			ans += arr[i]
	if len(ans) != N:
		ans = 'a' + ans
	print(ans)


def solve(n, arr):
	ans = arr[0][0]
	for i in range(1, len(arr)):
		if arr[i - 1][1] == arr[i][0]:
			ans += arr[i - 1][1]
		else:
			ans += arr[i - 1][1] + arr[i][0]
	if len(ans) == n - 2:
		return ans + arr[-1][1] * 2
	return ans + arr[-1][1]
for i in range(int(input())):
	print(solve(int(input()), input().split()))


def bigram(n, ls):
	ans = ls[0]
	for i in range(1, len(ls), 1):
		if ls[i][0] == ans[-1]:
			ans += ls[i][1]
		else:
			ans += ls[i]
	if len(ans) < n:
		ans += 'a'
	return ans

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		ls = list(input().split())
		print(bigram(n, ls))
main()


for _ in range(int(input())):
	n_letters = int(input())
	words = input().split()
	new_word = ' '
	for word in words:
		if word[0] == new_word[-1]:
			new_word += word[1]
		else:
			new_word += word
	if len(new_word) - 1 < n_letters:
		new_word += 'a'
	print(new_word[1:])


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(str, input().split()))
	s = l[0][0]
	p = len(l)
	for i in range(p - 1):
		if l[i][1] == l[i + 1][0]:
			s += l[i][1]
		else:
			s += l[i][1] + l[i + 1][0]
	s += l[-1][1]
	p = len(s)
	while p != n:
		s = 'a' + s
		p += 1
	print(s)


t = int(input())
for _ in range(t):
	n = int(input())
	l = input().split()
	res = []
	res.append(l[0][0])
	for i in range(n - 3):
		if l[i][1] == l[i + 1][0]:
			res.append(l[i][1])
		else:
			res.append(l[i][1])
			res.append(l[i + 1][0])
	res.append(l[-1][1])
	s = ''.join(res)
	if len(s) == n:
		print(s)
	else:
		s += s[-1]
		print(s)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	d = list(input().strip().split())
	nd = []
	for i in range(len(d) - 1):
		nd.append(d[i])
		if d[i][1] != d[i + 1][0]:
			nd.append(d[i][1] + d[i + 1][0])
	nd.append(d[-1])
	for i in range(len(nd)):
		if i % 2 == 0:
			print(nd[i], end='')
			n -= 2
	if n > 0:
		print(nd[-1][1] * n)
	elif n < 0:
		print('error')
	else:
		print()


t = int(input())
s = ''

def read_input():
	return input().split()

def calc(s):
	r = s[0]
	for i in s[1:]:
		if r[-1] != i[0]:
			r += i
		else:
			r += i[1]
	return r

def display(r, n):
	if len(r) != n:
		r += 'a'
	print(r)
while t != 0:
	n = int(input())
	s = read_input()
	r = calc(s)
	display(r, n)
	t -= 1


t = int(input())
for i in range(t):
	r = ''
	n = int(input())
	ch = str(input())
	l = ch.split()
	p = 0
	if n > 3:
		for i in range(n - 3):
			r = r + l[i][0]
			if l[i][1] != l[i + 1][0]:
				p += 1
				r = r + l[i][1]
		if p == 0:
			print(r + l[n - 3] + 'b')
		else:
			print(r + l[n - 3])
	else:
		g = ch[0] + ch
		print(g)


import sys
input = iter(sys.stdin.read().splitlines()).__next__

def solve(N, A):
	res = A[0][0]
	mismatch_found = False
	for i in range(1, N - 2):
		if A[i - 1][1] != A[i][0]:
			mismatch_found = True
			res += A[i - 1][1]
		res += A[i][0]
	res += A[-1][1]
	if not mismatch_found:
		res += 'a'
	return res
TC = int(input())
for tc in range(TC):
	N = int(input())
	A = list(input().split())
	res = solve(N, A)
	print(res)


for _ in range(int(input())):
	n = int(input())
	li = list(input().split())
	if len(li) == 1:
		print('a' + li[0])
		continue
	ans = ''
	for i in range(len(li)):
		if i == 0:
			ans += li[i][0]
		elif li[i][0] != li[i - 1][-1]:
			ans += li[i - 1][-1] + li[i][0]
		else:
			ans += li[i][0]
	if len(ans) != n:
		if len(ans) - n == -1:
			print(ans + li[-1][-1])
		else:
			print(ans + li[-1][-1] + 'a')
	else:
		print(ans)


cases = int(input())
for i in range(cases):
	n = int(input())
	arr = list(input().split())
	count = n
	new = ''
	previous = ''
	for (i, item) in enumerate(arr):
		if i == 0:
			new += item[0]
			previous = item
			count -= 1
			continue
		if item[0] == previous[1]:
			new += item[0]
			count -= 1
		else:
			new += previous[1] + item[0]
			count -= 2
		previous = item
	if i == n - 3:
		new += item[1]
		count -= 1
	if count > 0:
		new += 'a'
	print(new)


import random
from collections import Counter, defaultdict
from copy import deepcopy as dc
import math
try:
	t = int(input())
	for tt in range(1, t + 1):
		n = int(input())
		a = list(map(str, input().split()))
		s = ''
		i = 0
		while i < len(a) - 1:
			if a[i][-1] == a[i + 1][0]:
				s += a[i][0]
			else:
				s += a[i]
			i += 1
		s += a[-1]
		while len(s) < n:
			s += 'b'
		print(s)
except EOFError as e:
	pass


import os, sys
from io import BytesIO, IOBase
from types import GeneratorType
from bisect import *
from collections import defaultdict, deque, Counter
import math, string
from heapq import *
from operator import add
from itertools import accumulate
BUFSIZE = 8192
sys.setrecursionlimit(10 ** 5)

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
inf = float('inf')
en = lambda x: list(enumerate(x))
ceil_ = lambda a, b: (a + b - 1) // b
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())

def solve():
	n = ii()
	arr = input().split()
	s = ''
	f = 1
	n = len(arr)
	for i in range(n - 1):
		if arr[i][1] != arr[i + 1][0]:
			f = 0
			s += arr[i][0] + arr[i][1]
		else:
			s += arr[i][0]
	s += arr[-1]
	if f:
		s += s[-1]
	print(s)
for _ in ' ' * ii():
	solve()


import sys

def parseInput():
	rawInput = sys.stdin.read().split('\n')
	rawInput = rawInput[1:-1]
	inputs = rawInput[1::2]
	return inputs

def createOriginalString(bigrams):
	extraBigramAdded = False
	originalString = ''
	for bigram in bigrams.split():
		if originalString == '':
			originalString = bigram
		elif bigram[0] == originalString[-1]:
			originalString += bigram[1]
		else:
			originalString += bigram
			extraBigramAdded = True
	if extraBigramAdded == False:
		originalString += 'a'
	return originalString
for bigrams in parseInput():
	print(createOriginalString(bigrams))


x = int(input())

def abhishek(LIST, m):
	txt = LIST[0]
	for i in range(len(LIST) - 1):
		if LIST[i][1] == LIST[i + 1][0]:
			txt += LIST[i + 1][1]
		else:
			txt += LIST[i + 1]
	if len(txt) == m:
		print(txt)
	else:
		print(txt + 'a')

def main():
	for _ in range(x):
		n = int(input())
		LIST = input().split()
		abhishek(LIST, n)
main()


import math
import os
import sys
from sys import *
from decimal import *
from io import BytesIO, IOBase
import threading
from itertools import *
from collections import *
from array import *
import random
M = 10 ** 9 + 7
import heapq
import bisect
from functools import lru_cache
from queue import PriorityQueue
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def inpu():
	return int(inp())

def regularbracket(t):
	p = 0
	for i in t:
		if i == '(':
			p += 1
		else:
			p -= 1
		if p < 0:
			return False
	else:
		if p > 0:
			return False
		else:
			return True

def binarySearchcount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def binarySearch(arr, n, key):
	left = 0
	right = n - 1
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] == key:
			return mid
		if arr[mid] <= key:
			left = mid + 1
		else:
			right = mid - 1
	return -1

def ternarysearch(arr, n, key):
	(l, r) = (0, n - 1)
	while l <= r:
		mid = (-l + r) // 3 + l
		mid2 = mid + (-l + r) // 3
		if arr[mid] == key:
			return mid
		if arr[mid2] == key:
			return mid2
		if arr[mid] > key:
			r = mid - 1
		elif arr[mid2] < key:
			l = mid2 + 1
		else:
			l = mid + 1
			r = mid2 - 1
	return -1

def reverse1(string):
	pp = ''
	for i in string[::-1]:
		pp += i
	if pp == string:
		return True
	return False

def reverse2(list1):
	l = []
	for i in list1[::-1]:
		l.append(i)
	if l == list1:
		return True
	return False

def sumofdigits(n):
	n = str(n)
	s1 = 0
	for i in n:
		s1 += int(i)
	return s1

def perfect_square(n):
	s = math.sqrt(n)
	if s == int(s):
		return True
	return False

def roman_number(x):
	if x > 15999:
		return
	value = [5000, 4000, 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
	symbol = ['F', 'MF', 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
	roman = ''
	i = 0
	while x > 0:
		div = x // value[i]
		x = x % value[i]
		while div:
			roman += symbol[i]
			div -= 1
		i += 1
	return roman

def soretd(s):
	for i in range(1, len(s)):
		if s[i - 1] > s[i]:
			return False
	return True

def countRhombi(h, w):
	ct = 0
	for i in range(2, h + 1, 2):
		for j in range(2, w + 1, 2):
			ct += (h - i + 1) * (w - j + 1)
	return ct

def countrhombi2(h, w):
	return h * h // 4 * (w * w // 4)

def binpow(a, b):
	if b == 0:
		return 1
	else:
		res = binpow(a, b // 2)
	if b % 2 != 0:
		return res * res * a
	else:
		return res * res

def coprime_to_n(n):
	result = n
	i = 2
	while i * i <= n:
		if n % i == 0:
			while n % i == 0:
				n //= i
			result -= result // i
		i += 1
	if n > 1:
		result -= result // n
	return result

def luckynumwithequalnumberoffourandseven(x, n, a):
	if x >= n and str(x).count('4') == str(x).count('7'):
		a.append(x)
	elif x < 1000000000000.0:
		luckynumwithequalnumberoffourandseven(x * 10 + 4, n, a)
		luckynumwithequalnumberoffourandseven(x * 10 + 7, n, a)
	return a

def luckynum(x, l, r, a):
	if x >= l and x <= r:
		a.append(x)
	if x > r:
		a.append(x)
		return a
	if x < 10000000000.0:
		luckynum(x * 10 + 4, l, r, a)
		luckynum(x * 10 + 7, l, r, a)
	return a

def luckynuber(x, n, a):
	p = set(str(x))
	if len(p) <= 2:
		a.append(x)
	if x < n:
		luckynuber(x + 1, n, a)
	return a

def interact(type, x):
	if type == 'r':
		inp = input()
		return inp.strip()
	else:
		print(x, flush=True)

def findTrailingZeros(n):
	count = 0
	while n >= 5:
		n //= 5
		count += n
	return count

def mergeSort(arr):
	if len(arr) > 1:
		mid = len(arr) // 2
		L = arr[:mid]
		R = arr[mid:]
		mergeSort(L)
		mergeSort(R)
		i = j = k = 0
		while i < len(L) and j < len(R):
			if L[i] < R[j]:
				arr[k] = L[i]
				i += 1
			else:
				arr[k] = R[j]
				j += 1
			k += 1
		while i < len(L):
			arr[k] = L[i]
			i += 1
			k += 1
		while j < len(R):
			arr[k] = R[j]
			j += 1
			k += 1

def solven(p, l, a, b, n, res):
	if p > n or l > 10:
		return
	if p > 0:
		res.add(p)
	solven(p * 10 + a, l + 1, a, b, n)
	solven(p * 10 + b, l + 1, a, b, n)

def subsetsUtil(A, subset, index, d):
	print(*subset)
	s = sum(subset)
	d.append(s)
	for i in range(index, len(A)):
		subset.append(A[i])
		subsetsUtil(A, subset, i + 1, d)
		subset.pop(-1)
	return d

def subsetSums(arr, l, r, d, sum=0):
	if l > r:
		d.append(sum)
		return
	subsetSums(arr, l + 1, r, d, sum + arr[l])
	subsetSums(arr, l + 1, r, d, sum)
	return d

def print_factors(x):
	factors = []
	for i in range(1, x + 1):
		if x % i == 0:
			factors.append(i)
	return factors

def calc(X, d, ans, D):
	if len(X) == 0:
		return
	i = X.index(max(X))
	ans[D[max(X)]] = d
	Y = X[:i]
	Z = X[i + 1:]
	calc(Y, d + 1, ans, D)
	calc(Z, d + 1, ans, D)

def generate(st, s):
	if len(s) == 0:
		return
	if s not in st:
		st.add(s)
		for i in range(len(s)):
			t = list(s).copy()
			t.remove(s[i])
			t = ''.join(t)
			generate(st, t)
	return

def largestincreasingsubsequence(A):
	l = [1] * len(A)
	for i in range(1, len(l)):
		for k in range(i):
			if A[k] <= A[i]:
				l[i] = max(l[i], l[k] + 1)
	return max(l)

def findOR(nums, N):
	prefix_sum = 0
	result = 0
	for i in range(N):
		result |= nums[i]
		prefix_sum += nums[i]
		result |= prefix_sum
	return result

def OR(a, n):
	ans = a[0]
	for i in range(1, n):
		ans |= a[i]
	return ans

def toString(List):
	return ''.join(List)

def permute(a, l, r, p):
	if l == r:
		p.append(toString(a))
	else:
		for i in range(l, r + 1):
			(a[l], a[i]) = (a[i], a[l])
			permute(a, l + 1, r, p)
			(a[l], a[i]) = (a[i], a[l])

def squareRoot(number, precision):
	start = 0
	(end, ans) = (number, 1)
	while start <= end:
		mid = int((start + end) / 2)
		if mid * mid == number:
			ans = mid
			break
		if mid * mid < number:
			start = mid + 1
		else:
			end = mid - 1
	increment = 0.1
	for i in range(0, precision):
		while ans * ans <= number:
			ans += increment
		ans = ans - increment
		increment = increment / 10
	return ans

def countRectangles(l, w):
	squareSide = math.gcd(l, w)
	return int(l * w / (squareSide * squareSide))

def count_same_digit(L, R):
	tmp = 0
	ans = 0
	n = int(math.log10(R) + 1)
	for i in range(0, n):
		tmp = tmp * 10 + 1
		for j in range(1, 10):
			if L <= tmp * j and tmp * j <= R:
				ans += 1
	return ans

def findCrossOver(arr, low, high, x):
	if arr[high] <= x:
		return high
	if arr[low] > x:
		return low
	mid = (low + high) // 2
	if arr[mid] <= x and arr[mid + 1] > x:
		return mid
	if arr[mid] < x:
		return findCrossOver(arr, mid + 1, high, x)
	return findCrossOver(arr, low, mid - 1, x)

def Kclosest(arr, x, k, n, ans):
	l = findCrossOver(arr, 0, n - 1, x)
	r = l + 1
	count = 0
	if arr[l] == x:
		l -= 1
	while l >= 0 and r < n and (count < k):
		if x - arr[l] < arr[r] - x:
			ans.append(arr[l])
			l -= 1
		else:
			ans.append(arr[r])
			r += 1
		count += 1
	while count < k and l >= 0:
		ans.append(arr[l])
		l -= 1
		count += 1
	while count < k and r < n:
		ans.append(arr[r])
		r += 1
		count += 1
	return ans

def dfs(root, nodeVal, nodeConnection, visited):
	leftVal = nodeVal[root][0]
	rightVal = nodeVal[root][1]
	solution = []
	if nodeConnection[root]:
		visited.add(root)
		for i in nodeConnection[root]:
			if i not in visited:
				solution.append(dfs(i, nodeVal, nodeConnection, visited))
		leftMax = 0
		rightMax = 0
		for i in solution:
			(l, r) = i
			leftMax += max(abs(leftVal - l[0]) + l[1], abs(leftVal - r[0]) + r[1])
			rightMax += max(abs(rightVal - l[0]) + l[1], abs(rightVal - r[0]) + r[1])
		return ((leftVal, leftMax), (rightVal, rightMax))
	else:
		return ((leftVal, 0), (rightVal, 0))

def luckynumber(x, n, a):
	if x > 0:
		a.append(x)
	if x > 10 ** 9:
		return a
	elif x < 1000000000000.0:
		luckynumber(x * 10 + 4, n, a)
		luckynumber(x * 10 + 7, n, a)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def query1(l, r):
	if l >= r:
		return -1
	print('?', l + 1, r + 1)
	sys.stdout.flush()
	return int(input()) - 1

def answer(p):
	print('!', p + 1)
	sys.stdout.flush()
	exit()

def buildPrefix(MAX, prefix):
	prime = [1] * (MAX + 1)
	p = 2
	while p * p <= MAX:
		if prime[p] == 1:
			i = p * 2
			while i <= MAX:
				prime[i] = 0
				i += p
		p += 1
	for p in range(2, MAX + 1):
		prefix[p] = prefix[p - 1]
		if prime[p] == 1:
			prefix[p] += 1

def query(L, R, prefix):
	return prefix[R] - prefix[L - 1]

def maxSubArraySum(a, size):
	max_so_far = a[0]
	curr_max = a[0]
	for i in range(1, size):
		curr_max = max(a[i], curr_max + a[i])
		max_so_far = max(max_so_far, curr_max)
	return max_so_far

def solvepp(n, k):
	if n == 1 and k == 1:
		return 0
	mid = 2 ** (n - 1) // 2
	if k <= mid:
		return solvepp(n - 1, k)
	else:
		return solvepp(n - 1, k - mid) == 0

def solvr(s, p):
	if len(s) == 0:
		print(p, end=' ')
		return
	op1 = p
	op2 = p + s[0]
	s = s[1:]
	solvr(s, op1)
	solvr(s, op2)
	return

def paranthesis(n, m, ans, l):
	if n == 0 and m == 0:
		print(ans)
		return
	if n != 0:
		op1 = ans + '('
		paranthesis(n - 1, m, op1, l)
	if m > n:
		op2 = ans + ')'
		paranthesis(n, m - 1, op2, l)

def rse(arr, n):
	stack = []
	ans = []
	for i in range(n - 1, -1, -1):
		if len(stack) == 0:
			ans.append(n)
		else:
			while len(stack) != 0:
				if stack[-1][0] >= arr[i]:
					stack.pop()
				else:
					break
			if len(stack) == 0:
				ans.append(n)
			else:
				ans.append(stack[-1][1])
		stack.append([arr[i], i])
	ans.reverse()
	return ans

def lse(arr, n):
	stack = []
	ans = []
	for i in range(n):
		if len(stack) == 0:
			ans.append(-1)
		else:
			while len(stack) != 0:
				if stack[-1][0] >= arr[i]:
					stack.pop()
				else:
					break
			if len(stack) == 0:
				ans.append(-1)
			else:
				ans.append(stack[-1][1])
		stack.append([arr[i], i])
	return ans

def mah(arr):
	max1 = 0
	p = rse(arr, len(arr))
	q = lse(arr, len(arr))
	for i in range(len(arr)):
		a = (p[i] - q[i] - 1) * arr[i]
		max1 = max(a, max1)
	return max1

def lcs(s, r):
	rr = len(r)
	ss = len(s)
	l = [[0] * (rr + 1) for i in range(ss + 1)]
	for i in range(1, ss + 1):
		for j in range(1, rr + 1):
			if s[i - 1] == r[j - 1]:
				l[i][j] = l[i - 1][j - 1] + 1
			else:
				l[i][j] = max(l[i - 1][j], l[i][j - 1])
	return l[ss][rr]

def subsetsum(arr, sum, len):
	dp = [[False] * (sum + 1) for i in range(len + 1)]
	for i in range(len + 1):
		dp[i][0] = True
	for i in range(1, len + 1):
		for j in range(1, sum + 1):
			if arr[i - 1] > j:
				dp[i][j] = dp[i - 1][j]
			else:
				dp[i][j] = dp[i - 1][j] or dp[i - 1][j - arr[i - 1]]
	return dp[len][sum]

def matrixmincost(cost, n, m):
	dp = [[0 for x in range(m)] for x in range(n)]
	for i in range(n):
		for j in range(m):
			if i == 0 and j == 0:
				dp[i][j] = cost[i][j]
			elif i == 0 and j != 0:
				dp[i][j] = dp[i][j - 1] + cost[i][j]
			elif j == 0 and i != 0:
				dp[i][j] = dp[i - 1][j] + cost[i][j]
			else:
				dp[i][j] = cost[i][j] + min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1])
	return dp[n - 1][m - 1]

def coinchange(n, arr, len1):
	dp = [0] * (n + 1)
	dp[0] = 1
	for i in range(len1):
		for j in range(arr[i], n + 1):
			dp[j] += dp[j - arr[i]]
	return dp[n]

class Graph(object):

	def __init__(self, vertices):
		self.graph = defaultdict(list)
		self.V = vertices

	def addEdge(self, u, v):
		self.graph[u].append(v)
		self.graph[v].append(u)

	def connectedComponents(self):
		unvisited = set(range(self.V))
		queue = deque()
		count = 0
		while len(unvisited) > 0:
			count += 1
			v = next(iter(unvisited))
			unvisited.remove(v)
			queue.append(v)
			while len(queue) > 0:
				v = queue.popleft()
				for w in self.graph[v]:
					if w in unvisited:
						unvisited.remove(w)
						queue.append(w)
		return count

def maxSumIS(arr, n):
	msis = arr.copy()
	for i in range(1, n):
		for j in range(i):
			if arr[i] > arr[j] and msis[i] < msis[j] + arr[i]:
				msis[i] = msis[j] + arr[i]
	c = max(msis)
	p = 5
	return c

def binarysearch2(arr, target):
	lo = 0
	hi = len(arr) - 1
	while lo <= hi:
		mid = (lo + hi) // 2
		if arr[mid] == target:
			if mid != len(arr) - 1:
				if arr[mid + 1] != target:
					return mid
				else:
					lo += 1
			else:
				return mid
			continue
		if arr[mid] > target:
			hi = mid - 1
		else:
			lo = mid + 1

def nge(arr, n):
	stack = []
	ans = []
	for i in range(n - 1, -1, -1):
		if len(stack) == 0:
			ans.append(-1)
		else:
			while len(stack) > 0:
				if stack[-1][0] < arr[i]:
					stack.pop()
				else:
					break
			if len(stack) == 0:
				ans.append(-1)
			else:
				ans.append(stack[-1][1])
		stack.append([arr[i], i])
	ans.reverse()
	return ans

def nse(arr, n):
	stack = []
	ans = []
	for i in range(n - 1, -1, -1):
		if len(stack) == 0:
			ans.append(-1)
		else:
			while len(stack) > 0:
				if stack[-1][0] > arr[i]:
					stack.pop()
				else:
					break
			if len(stack) == 0:
				ans.append(-1)
			else:
				ans.append(stack[-1][1])
		stack.append([arr[i], i])
	ans.reverse()
	return ans

def alperm(nums, path, result):
	if not nums:
		result.add(tuple(path))
		return
	for i in range(0, len(nums)):
		alperm(nums[:i] + nums[i + 1:], path + [nums[i]], result)
	return result

def minsum(arr, n, m, res, l):
	if n == 1 and m == 1:
		res += arr[0][0]
		l.append(res)
	else:
		if n != 1:
			p = res + arr[n - 1][m - 1]
			minsum(arr, n - 1, m, p, l)
		if m != 1:
			p = res + arr[n - 1][m - 1]
			minsum(arr, n, m - 1, p, l)
	return min(l)

def catalan(n):
	if n == 0 or n == 1:
		return 1
	catalan = [0] * (n + 1)
	catalan[0] = 1
	catalan[1] = 1
	for i in range(2, n + 1):
		for j in range(i):
			catalan[i] += catalan[j] * catalan[i - j - 1]
	return catalan[n]

def find_shortest_path(graph, start, end, path):
	path = path + [start]
	if start == end:
		return path
	if start not in graph:
		return None
	shortest = None
	for node in graph[start]:
		if node not in path:
			newpath = find_shortest_path(graph, node, end, path)
			if newpath:
				if not shortest or len(newpath) < len(shortest):
					shortest = newpath
	return shortest

def test(n, d):
	a = random.randint(1, n - 2)
	p = pow(a, d, n)
	if p == 1 or p == n - 1:
		return True
	while d != n - 1:
		d *= 2
		p = pow(p, 2, n)
		if p == n - 1:
			return True
	return False

def isprime(n):
	if n == 1:
		return False
	if n == 2:
		return True
	if n == 3:
		return True
	d = n - 1
	while d % 2 == 0:
		d //= 2
	for i in range(5):
		if test(n, d) == False:
			return False
	return True

def muin(a, m):
	(x, y, mo) = (1, 0, m)
	if m == 1:
		return 0
	while m > 0:
		(x, y) = (y, x - a // m * y)
		(a, m) = (m, a % m)
	if x < 0:
		return mo + x
	else:
		return x

def good(l, c):
	ch = chr(c)
	if len(l) == 1:
		return 1 if ch != l[0] else 0
	k = len(l) // 2
	lm = k - l[:k].count(ch) + good(l[k:], c + 1)
	rm = k - l[k:].count(ch) + good(l[:k], c + 1)
	return min(lm, rm)

def facto(fact):
	(fact[0], fact[1]) = (1, 1)
	for i in range(2, 10 ** 5 + 1):
		fact[i] = fact[i - 1] * i % M

def comb(n, r, fact):
	return fact[n] * pow(fact[n - r] * fact[r], M - 2, M) % M

def numberToBase(n, b):
	if n == 0:
		return 0
	digits = []
	while n:
		digits.append(n % b)
		n //= b
	return sum(digits)

def main():
	tt = 1
	tt = inpu()
	for _ in range(tt):
		n = inpu()
		arr = list(map(str, input().split()))
		ans = ''
		for i in range(n - 2):
			if i == 0:
				ans += arr[i]
			elif arr[i][0] == ans[-1][-1]:
				ans += arr[i][1]
			else:
				ans += arr[i]
		if len(ans) == n:
			print(ans)
			continue
		else:
			print('b' + ans)
main()


for _ in range(int(input())):
	n = int(input())
	big = input().split(' ')
	k = 0
	for i in range(n - 3):
		if big[i][1] != big[i + 1][0]:
			big.insert(i + 1, big[i][1] + big[i + 1][0])
			k = 1
			break
	if k != 1:
		big.append(big[-1][-1] * 2)
	ans = big[0]
	for i in range(1, len(big)):
		ans += big[i][1]
	print(ans)


import os
import sys
from io import BytesIO, IOBase
alphabets = 'abcdefghijklmnopqrstuvwxyz'
from sys import maxsize
from itertools import permutations
import math
Modulo = 10 ** 9 + 7

def arr_input():
	return list(map(int, input().split()))

def mul_input():
	return map(int, input().split())

def int_inp():
	return int(input())
from math import gcd
from collections import Counter
from functools import reduce

def solution():
	n = int_inp()
	s = list(map(str, input().split()))
	if len(s) == 1:
		print(s[0] + s[0][1])
		return
	count = 0
	st = s[0][0]
	for i in range(1, len(s)):
		if s[i][0] != s[i - 1][1]:
			count += 1
			st = st + s[i - 1][1] + s[i][0]
		else:
			st += s[i][0]
	st += s[-1][1]
	if count == 0:
		st = st + s[-1][1]
	print(st)

def main():
	testcases = int(input())
	for _ in range(testcases):
		solution()

def main1():
	testcases = 1
	for _ in range(testcases):
		solution()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	n = int(input())
	q = input().split()
	ans = ''
	flag = 0
	for i in range(len(q)):
		if i and q[i][0] != q[i - 1][1]:
			ans += q[i - 1][1]
			ans += q[i][0]
			flag = 1
		else:
			ans += q[i][0]
	ans += q[-1][1]
	if not flag:
		ans += 'a'
	print(ans)


for _ in range(int(input())):
	n = int(input())
	s = list(input().split())
	out = ''
	out += s[0]
	fg = 1
	for i in range(1, n - 2):
		if out[len(out) - 1] != s[i][0]:
			out += s[i]
			fg = 0
		else:
			out += s[i][1]
	if len(out) != n:
		if out[0] == 'a':
			while len(out) < n:
				out += 'b'
		else:
			while len(out) < n:
				out += 'a'
	print(out)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = input().split(' ')
	if len(arr) == 1:
		print(arr[0] + 'a')
		continue
	ans = arr[0][0]
	for i in range(1, n - 2):
		if arr[i - 1][1] != arr[i][0]:
			ans += arr[i - 1][1] + arr[i][0]
		else:
			ans += arr[i - 1][1]
	ans += arr[n - 3][1]
	if len(ans) < n:
		ans += 'a' * (n - len(ans))
	print(ans)


def Solve(l, n):
	s = l[0]
	for i in range(1, len(l)):
		if l[i][0] != s[-1]:
			s = s + l[i][0] + l[i][1]
		else:
			s = s + l[i][1]
	if len(s) != n:
		s = 'b' * (n - len(s)) + s
	return s
for _ in range(int(input())):
	n = int(input())
	l = list(map(str, input().split()))
	print(Solve(l, n))


for _ in range(int(input())):
	n = int(input())
	a = list(map(str, input().split()))
	if n == 3:
		if 'b' not in a[0]:
			print(a[0] + 'b')
		elif 'a' not in a[0]:
			print(a[0] + 'a')
		else:
			print(a[0] + 'b')
	else:
		ans = a[0]
		k = 0
		for i in range(1, n - 2):
			if k < n - 4:
				if a[i][0] == a[i - 1][1]:
					ans += a[i][1]
					k += 1
				else:
					ans += a[i]
			else:
				ans += a[i]
		print(ans)


n = int(input())
lengths = []
bigrams = []
for a in range(n):
	lengths.append(int(input()))
	bigrams.append(input().split(' '))
word = ''
for (q, i) in enumerate(bigrams):
	word = ''
	counter = 0
	for j in range(len(i)):
		currentletter = i[j][0]
		if j == 0:
			word += currentletter
		else:
			prevletter = i[j - 1][1]
			if currentletter != prevletter:
				counter += 1
				if prevletter == 'a':
					word += 'ab'
				else:
					word += 'ba'
			else:
				word += i[j][0]
		if j == lengths[q] - 3:
			word += i[j][1]
	if counter == 0:
		word += 'a'
	print(word)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(str, input().split()))
	if n == 3:
		print(a[0] + 'a')
	elif n == 4:
		print(a[0] + a[1])
	else:
		s = a[0]
		k = 0
		for j in range(1, len(a) - 1):
			if k == 0:
				if a[j + 1][0] != a[j][1]:
					s += a[j][1] + a[j + 1][0]
					k = 1
				elif s[-1] != a[j][0]:
					s += a[j]
					k = 1
				else:
					s += a[j][1]
			else:
				s += a[j][1]
		if k == 1:
			s += a[-1][1]
		else:
			s += a[-1][1] + 'a'
		print(s)


for _ in range(int(input())):
	n = int(input())
	t = ''
	ls = list(map(str, input().split()))
	t = t + ls[0][0]
	for i in range(n - 3):
		if ls[i][1] == ls[i + 1][0]:
			t += ls[i][1]
		else:
			t += ls[i][1] + ls[i + 1][0]
	t += ls[-1][1]
	if len(t) < n:
		if 'a' not in t:
			t += 'a'
		elif 'b' not in t:
			t += 'b'
		else:
			t += ls[-1][1]
	if n == 3:
		if 'b' not in ls[0]:
			t = 'baa'
		elif 'a' not in ls[0]:
			t = 'abb'
		else:
			t = ls[0] + ls[0][1]
	print(t)


for ii in range(int(input())):
	n = int(input())
	a = list(input().split())
	ans = a[0][0]
	for jj in range(1, n - 2):
		if a[jj - 1][-1] == a[jj][0]:
			ans += a[jj - 1][1]
		else:
			ans += a[jj - 1][1] + a[jj][0]
	ans += a[-1][-1]
	if len(ans) != n:
		ans += 'a'
	print(ans)


t = int(input())
for _ in range(t):
	l = int(input())
	st = [str(i) for i in input().split()]
	s = st[0]
	for i in range(1, len(st)):
		if s[-1] == st[i][0]:
			s = s + st[i][1]
		else:
			s = s + st[i]
	if len(s) != l:
		for j in range(l - len(s)):
			s = s + 'a'
	print(s)


for i in range(int(input())):
	count = int(input())
	a = input().split()
	word = a[0][0]
	flag = False
	for k in range(count - 3):
		word += a[k][1]
		if a[k][1] != a[k + 1][0]:
			word += a[k + 1][0]
			flag = True
	word += a[-1][1]
	if not flag:
		word += 'b'
	print(word)


import sys, os, io
import math
from collections import defaultdict

def ij():
	return int(input())

def li():
	return list(map(int, input().split()))
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	n = ij()
	l = [i for i in input().split()]
	newer = []
	newer.append(l[0][0])
	for i in range(len(l) - 1):
		if l[i][1] == l[i + 1][0]:
			newer.append(l[i][1])
		else:
			newer.append(l[i][1])
			newer.append(l[i + 1][0])
	newer.append(l[-1][-1])
	if len(newer) != n:
		newer.append(newer[-1])
	print(''.join(newer))
test = 1
test = ij()
for _ in range(test):
	solve()


T = int(input())
for t in range(T):
	n = int(input())
	bigrams = [i for i in input().split()]
	ans = bigrams[0]
	prv = bigrams[0][0]
	nxt = bigrams[0][1]
	done = 0
	i = 1
	while i < len(bigrams):
		if bigrams[i][0] == nxt:
			prv = bigrams[i][0]
			nxt = bigrams[i][1]
			ans += bigrams[i][1]
		else:
			ans += bigrams[i][0]
			done = 1
			prv = nxt
			nxt = bigrams[i][0]
			i -= 1
		i += 1
	if done == 0:
		ans += 'a'
	print(ans)


testcase = int(input())
g = 0
while testcase > 0:
	length_of_word = int(input())
	bigram = input().split()
	polycarp = bigram[0]
	for i in bigram[1:]:
		if polycarp[-1] != i[0]:
			polycarp += i
		else:
			polycarp += i[1]
	if len(polycarp) != length_of_word:
		polycarp += 'a'
	print(polycarp)
	testcase -= 1
	g += 1


t = int(input())
for i in range(t):
	n = int(input())
	bigrams = input().split()
	word = bigrams[0]
	for j in bigrams[1:]:
		word += j[1] if word[-1] == j[0] else j
	print(word.ljust(n, 'a'))


t = int(input())
for j in range(t):
	n = int(input())
	mas = list(input().split())
	p = mas[0][1]
	s = mas[0]
	for i in range(1, len(mas)):
		if mas[i][0] != p:
			s += mas[i]
		else:
			s = s + mas[i][1]
		p = mas[i][1]
	if len(s) < n:
		if s[-1] == 'a':
			s += 'b'
		else:
			s += 'a'
	print(s)


def bigram(n, bigrams):
	a = ''
	for i in range(n - 2):
		char = bigrams[i]
		if i == 0:
			a += char
		else:
			l = a[-1]
			if char[0] == l:
				a += char[-1]
			else:
				a += char
	if len(a) != n:
		a += 'a'
	return a
t = int(input())
for i in range(t):
	n = int(input())
	bigrams = input().split()
	result = bigram(n, bigrams)
	print(result)


for _ in range(int(input())):
	n = int(input())
	l = input().split()
	if n == 3:
		print(l[0] + l[0][1])
		continue
	f = 0
	for i in range(len(l) - 1):
		if l[i][1] != l[i + 1][0]:
			ind = i
			f = 1
	if f:
		if l[ind][1] == 'b':
			l.insert(ind + 1, 'ba')
		else:
			l.insert(ind + 1, 'ab')
		ans = l[0]
		for i in range(1, len(l)):
			ans += l[i][1]
		print(ans)
	else:
		ans = l[0]
		for i in range(1, len(l)):
			ans += l[i][1]
		ans += l[-1][1]
		print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = [s for s in input().split()]
	res = ''
	for i in arr:
		if not res:
			res += i
		elif i[0] == res[-1]:
			res += i[1]
		else:
			res += i
	if len(res) != n:
		res += 'a'
	print(res)


for asdfasf in range(int(input())):
	n = int(input())
	bi = input().split()
	last = bi[0][0]
	s = [last]
	for it in bi:
		if last != it[0]:
			s.append(it)
		else:
			s.append(it[1])
		last = it[1]
	st = ''.join(s)
	if len(st) < n:
		st += 'a'
	print(st)


T = int(input())
res = []
for _ in range(T):
	tmp = ''
	n = int(input())
	d = input().split()
	r = d[0][1]
	tmp += d[0][0]
	for i in range(1, len(d)):
		if r == d[i][0]:
			r = d[i][1]
		else:
			tmp += r
			r = d[i][1]
		tmp += d[i][0]
	tmp += d[-1][1]
	if len(tmp) == n:
		res.append(tmp)
	else:
		res.append(tmp + 'a')
for i in res:
	print(i)


import sys

def solve(li, x):
	ans = li[0][0]
	flag = 0
	for i in range(len(li) - 1):
		if li[i][1] != li[i + 1][0]:
			flag = 1
			missing = str(li[i][1] + li[i + 1][0])
			ans += missing
		else:
			ans += li[i][1]
	ans += li[-1][1]
	if flag == 0:
		ans += 'a'
		return ans
	return ans
n = int(input())
for _ in range(n):
	x = int(input())
	numbers = [x for x in input().split()]
	print(solve(numbers, x))


n = int(input())
for i in range(n):
	m = int(input())
	arr = input().split()
	arr2 = str(arr.pop(0))
	for j in range(m - 3):
		if arr2[-1] == arr[j][0]:
			arr2 = arr2 + arr[j][-1]
		elif arr2[-1] != arr[j][0]:
			arr2 = arr2 + arr[j]
			j += 1
	if len(arr2) < m:
		arr2 += arr2[-1]
	print(arr2)


t = int(input())
for k in range(t):
	add = False
	n = int(input())
	x = input().split()
	s = x[0]
	for i in range(1, n - 2):
		if s[-1] == x[i][0]:
			s += x[i][1]
		else:
			s += x[i]
			add = True
	if not add:
		s += 'a'
	print(s)


n = int(input())
l = []
p = []
for i in range(n):
	g = input()
	y = input()
	p.append(g)
	l.append(y)
for i in l:
	y = i.split()
	o = []
	p = len(y) - 1
	flag = True
	if len(y) == 1:
		o.append(y[0])
		o.append('a')
		v = ''.join(o)
		print(v)
	else:
		for j in range(p):
			s = y[j]
			u = y[j + 1]
			if j == 0:
				o.append(s[0])
			if s[1] == u[0]:
				o.append(s[1])
			else:
				flag = False
				o.append(s[1])
				o.append(u[0])
			o.append
		h = y[-1][-1]
		o.append(h)
		v = ''.join(o)
		if flag:
			print(v + 'a')
		else:
			print(v)


import heapq
import sys
import math
from collections import deque
from bisect import bisect_left, bisect_right
I = sys.stdin.readline
II = lambda : int(I())
IN = lambda x: map(int, x.split())
FN = lambda x: map(float, x.split())
L = lambda x: list(IN(x))
M = 1000000007
P = print
T = True
F = False
for _ in range(II()):
	n = II()
	l = list(I().split())
	c = l[0][0]
	ans = []
	f = True
	for i in range(len(l)):
		if f and c != l[i][0]:
			ans.append(c)
			f = False
		c = l[i][1]
		ans.append(l[i][0])
	ans.append(l[-1][1])
	if f:
		ans.append(l[-1][1])
	print(*ans, sep='')


for _ in range(int(input())):
	n = int(input())
	a = input().split()
	s = a[0]
	t = True
	for i in range(1, n - 2):
		if a[i][0] != s[i] and t:
			s += a[i]
			t = False
		else:
			s += a[i][1]
	if t:
		s += s[-1]
	print(s)


import sys
input = sys.stdin.readline
ri = lambda : int(input())
rl = lambda : list(map(int, input().split()))
rs = lambda : input().strip('\r\n')

def solve():
	n = ri()
	s = list(map(str, input().split()))
	ans = s[0]
	flag = 0
	for i in range(1, len(s)):
		if s[i][0] == s[i - 1][-1]:
			ans += s[i][-1]
		else:
			flag = 1
			ans += s[i]
	if not flag:
		ans += s[-1][-1]
	return ans
for _ in range(ri()):
	print(solve())


import sys
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	n = int(input())
	a = input().split()
	if len(a) == 1:
		print(a[0] + 'a')
		continue
	ans = ''
	idx = -1
	for i in range(len(a) - 1):
		if a[i][1] == a[i + 1][0]:
			idx = i
		else:
			break
	if idx == len(a) - 2:
		ans = a[0]
		for i in range(1, len(a)):
			ans += a[i][1]
		ans += 'a'
	elif idx == -1:
		ans += a[0] + a[1]
		for i in range(2, len(a)):
			ans += a[i][1]
	else:
		idx += 1
		ans += a[0][0]
		for i in range(1, idx + 1):
			ans += a[i][0]
		ans += a[idx][1]
		ans += a[idx + 1]
		for i in range(idx + 2, len(a)):
			ans += a[i][1]
	print(ans)


t = int(input(''))
while t != 0:
	a = int(input(''))
	li1 = list(input('').split(' '))
	cnt = 0
	p1 = li1[0]
	print(p1[0], end='')
	cnt = cnt + 1
	for k in range(0, len(li1) - 1):
		s = li1[k]
		p = li1[k + 1]
		if s[1] == p[0]:
			print(p[0], end='')
			cnt = cnt + 1
		else:
			print(s[1], end='')
			print(p[0], end='')
			cnt = cnt + 2
	p2 = li1[len(li1) - 1]
	print(p2[1], end='')
	cnt = cnt + 1
	diff = a - cnt
	if diff == 1:
		print('a', end='')
	print('')
	t = t - 1


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	x = input().split()
	result = x[0][0]
	if len(x) == 1:
		print(x[0] + 'a')
		continue
	for i in range(1, len(x)):
		if x[i - 1][-1] == x[i][0]:
			result += x[i][0]
		else:
			result += x[i - 1][-1] + x[i][0]
	result = result + x[-1][-1] + ''.join(['a' for i in range(n - len(result) - 1)])
	print(result)


t = int(input())
while t != 0:
	n = int(input())
	arr = input().split()
	s = ''
	flag = False
	for i in range(len(arr) - 1):
		if arr[i][1] != arr[i + 1][0]:
			s += arr[i]
			flag = True
		else:
			s += arr[i][0]
	s += arr[-1]
	if not flag:
		s += 'b'
	print(s)
	t -= 1


def solve(n, bigrams):
	ans = [bigrams[0][0]]
	for (i, bi) in enumerate(bigrams[1:], 1):
		if bigrams[i - 1][1] != bi[0]:
			ans.append('a' if bi[0] == 'b' else 'b')
		ans.append(bi[0])
	ans.append(bigrams[-1][1])
	ans = ''.join(ans)
	if len(ans) != n:
		ans += 'a'
	return ans
ans = []
for _ in range(int(input())):
	ans.append(solve(int(input()), list(input().split())))
print(*ans, sep='\n')


tst = int(input())
for i in range(tst):
	n = int(input())
	arr = list(input().split(' '))
	ans = arr[0]
	for i in range(1, len(arr)):
		if arr[i - 1][1] == arr[i][0]:
			ans += arr[i][1]
		else:
			ans += arr[i]
	if len(ans) == n:
		print(ans)
	else:
		print(ans + 'a')


n = int(input())
for i in range(n):
	l = int(input())
	ar = list(map(str, input().split()))
	a = ar[0]
	q = 0
	for g in range(1, len(ar)):
		if ar[g][0] != ar[g - 1][1]:
			for h in range(1, g):
				a += ar[h][1]
			a += ar[g]
			for h in range(g + 1, len(ar)):
				a += ar[h][1]
			q = 1
			print(a)
			break
	if q == 0:
		a = ar[0]
		for i in range(1, len(ar)):
			a += ar[i][1]
		a += ar[-1][1]
		print(a)


import sys
for _ in range(int(input())):
	n = int(input())
	l = list(map(str, input().split()))
	ans = l[0][0]
	for i in range(1, n - 2):
		ans += l[i - 1][1]
		if l[i - 1][1] != l[i][0]:
			ans += l[i][0]
	ans += l[n - 3][1]
	if len(ans) != n:
		ans += l[n - 3][1]
	print(ans)


for _ in range(int(input())):
	n = int(input())
	big = input().split()
	ans = ''
	for i in range(n - 2):
		ans += big[i][0]
		if i < n - 3 and big[i][1] != big[i + 1][0]:
			ans += big[i][1]
	ans += big[-1][1]
	if len(ans) < n:
		ans += 'b'
	print(ans)


for _ in range(int(input())):
	n = int(input())
	lst = [*map(str, input().split())]
	s = '' + lst[0]
	for i in range(1, len(lst)):
		if s[-1] == lst[i][0]:
			s += lst[i][1]
		else:
			s += lst[i]
	if len(s) < n:
		s += s[-1] * (n - len(s))
	print(s)


t = int(input())
for i in range(t):
	n = int(input())
	b = input().split(' ')
	if n == 3:
		print(b[0] + 'a')
		continue
	s = [b[0][0]]
	flag = False
	for idx in range(len(b) - 1):
		prev = b[idx]
		curr = b[idx + 1]
		if prev[1] == curr[0]:
			s.append(prev[1])
		else:
			flag = True
			s.append(prev[1])
			s.append(curr[0])
	s.append(b[-1][1])
	if not flag:
		s.append('a')
	print(''.join(s))


def solve():
	n = int(input())
	arr = [s for s in input().split()]
	missing = None
	idx = -1
	for i in range(1, len(arr)):
		if arr[i][0] != arr[i - 1][1]:
			missing = '%s%s' % (arr[i - 1][1], arr[i][0])
			idx = i
	if not missing:
		missing = arr[-1][1] + 'a'
		arr.append(missing)
	s = arr[0][0]
	for i in range(len(arr)):
		if i == idx:
			s += missing[1]
		s += arr[i][1]
	print(s)
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	n = int(input())
	s = [str(x) for x in input().split()]
	res = ''
	res += s[0]
	f = 1
	for i in range(1, n - 2):
		if res[len(res) - 1] != s[i][0]:
			res += s[i]
			f = 0
		else:
			res += s[i][1]
	if len(res) != n:
		if res[0] == 'a':
			while len(res) < n:
				res += 'b'
		else:
			while len(res) < n:
				res += 'a'
	print(res)


import sys
int1 = lambda x: int(x) - 1
pDB = lambda *x: print(*x, end='\n', file=sys.stderr)
p2D = lambda x: print(*x, sep='\n', end='\n\n', file=sys.stderr)

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def LI1():
	return list(map(int1, sys.stdin.readline().split()))

def LLI1(rows_number):
	return [LI1() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline().rstrip()
inf = 4294967295
md = 998244353

def solve():
	n = II()
	ss = SI().split()
	ans = ss[0][0]
	for i in range(n - 3):
		if ss[i][1] == ss[i + 1][0]:
			ans += ss[i][1]
		else:
			ans += ss[i][1] + ss[i + 1][0]
	ans += ss[-1][1]
	if len(ans) < n:
		ans += ans[-1]
	print(ans)
for testcase in range(II()):
	solve()


t = int(input())
for i in range(t):
	n = int(input())
	a = input().split()
	output = ''
	missing = 0
	for ind in range(n - 2):
		anow = a[ind]
		if ind == 0:
			aprev = anow
			output += anow
		elif anow[0] != aprev[1]:
			output += anow
			missing = 1
		else:
			output += anow[1]
		aprev = anow
	if missing == 0:
		output += 'a'
	print(output)


a = input()
i = int(a)
for x in range(i):
	j = int(input())
	l = input().split(' ')
	res = l[0][0]
	for y in l:
		if res[-1] != y[0]:
			res += y[0]
		res += y[1]
	if len(res) < j:
		res += 'a'
	print(res)


t = int(input())
for i in range(t):
	n = int(input())
	b = input().split()
	word = ''
	flag = True
	for el in b:
		if len(word) == 0:
			word = el
			continue
		if word[-1] == el[0]:
			word += el[1]
		else:
			flag = False
			word += el
	if flag:
		word += 'a'
	print(word)


for i in range(int(input())):
	n = int(input())
	l = input().split()
	f = False
	s = ''
	s += l[0][0]
	for i in range(1, len(l)):
		if l[i][0] == l[i - 1][1]:
			s += l[i][0]
		else:
			f = True
			s += l[i - 1][1] + l[i][0]
		if i == len(l) - 1:
			s += l[i][1]
	if len(l) == 1:
		s += l[0][1]
	if not f:
		s += 'a'
	print(s)


def getint():
	return [int(i) for i in input().split()]

def get():
	return int(input())

def getstr():
	return [i for i in input().split()]

def S():
	for test in range(int(input())):
		solve()
import math
import itertools as it
import bisect
import time
import collections as ct

def lower_bound(a, x):
	l = -1
	r = len(a)
	while l + 1 != r:
		mid = l + r >> 1
		if a[mid] < x:
			l = mid
		else:
			r = mid
	return r

def upper_bound(a, x):
	l = -1
	r = len(a)
	while l + 1 != r:
		mid = l + r >> 1
		if a[mid] <= x:
			l = mid
		else:
			r = mid
	return r

def solve():
	n = get()
	a = getstr()
	s = a[0]
	for i in range(1, n - 2):
		if a[i][0] == s[-1]:
			s += a[i][1]
		else:
			s += a[i]
	if len(s) != n:
		s += 'a'
	print(s)
S()


def solve():
	n = int(input())
	ans = []
	a = list(input().split())
	ans.append(a[0])
	for i in range(len(a) - 1):
		s1 = a[i]
		s2 = a[i + 1]
		if s1[1] == s2[0]:
			ans.append(s2[1])
			check = 0
		else:
			ans.append(s2[0])
			ans.append(s2[1])
			check = 1
	if len(ans) < n - 1:
		if 'aa' in a and (a[-1] == 'ba' or a[-1] == 'aa'):
			ans.append('a')
		elif 'ab' in a and (a[-1] == 'aa' or a[-1] == 'ba'):
			ans.append('b')
		elif 'ba' in a and (a[-1] == 'bb' or a[-1] == 'ab'):
			ans.append('a')
		elif 'bb' in a and (a[-1] == 'ab' or a[-1] == 'bb'):
			ans.append('b')
		elif 'ab' in a and a[-1] == 'ab':
			ans.append('b')
		else:
			ans.append('a')
	for i in ans:
		print(i, end='')
	print()
for i in range(int(input())):
	solve()


def op():
	n = int(input())
	a = input().split()
	ans = a[0]
	for i in range(1, n - 2):
		if a[i - 1][1] != a[i][0]:
			ans += a[i]
		else:
			ans += a[i][1]
	if len(ans) != n:
		ans += 'a'
	print(ans)
for i in range(int(input())):
	op()


import sys
input = sys.stdin.readline
for __ in range(int(input())):
	n = int(input())
	arr = list(input().split())
	answer = ''
	for x in arr:
		if answer and answer[-1] == x[0]:
			answer += x[1]
		else:
			answer += x
	if len(answer) == n:
		print(answer)
	else:
		print(answer + answer[-1])


t = int(input())
for i in range(t):
	s = ''
	find = 0
	n = int(input())
	bigram = input().split()
	for j in range(n - 3):
		s += bigram[j][0]
		if bigram[j][1] != bigram[j + 1][0]:
			s += bigram[j][1]
			find = 1
	s += bigram[n - 3]
	if find == 0:
		s += 'a'
	print(s)


t = int(input())
for i in range(t):
	n = int(input())
	arr = input().split()
	ans = ''
	num = 0
	for j in range(len(arr)):
		if j > 0:
			if arr[j - 1][1] != arr[j][0]:
				if arr[j][0] == 'a':
					ans += 'b'
				else:
					ans += 'a'
		if j == len(arr) - 1:
			ans += arr[j]
		else:
			ans += arr[j][0]
	if len(ans) != n:
		if ans[-1] == 'a':
			ans += 'b'
		else:
			ans += 'a'
	print(ans)


for test in range(int(input())):
	n = int(input())
	arr = [x for x in input().split()]
	flag = False
	ans = ''
	for i in range(len(arr)):
		if i == 0:
			ans += arr[i][0]
		elif arr[i][0] == arr[i - 1][1]:
			ans += arr[i][0]
		else:
			flag = True
			ans += arr[i - 1][1] + arr[i][0]
	ans += arr[-1][1]
	if flag == False:
		ans += 'a'
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	bigrams = list(map(str, input().split(' ')))
	yesval = 'yes'
	word = ''
	length = 0
	for theta in range(n - 2):
		word = word + bigrams[theta][0]
	word = word + bigrams[n - 3][1]
	for delta in range(n - 3):
		if bigrams[delta][1] != bigrams[delta + 1][0]:
			pos = delta
			yesval = 'no'
			break
	if yesval == 'no':
		word = word[:pos + 1] + bigrams[pos][1] + word[pos + 1:]
	else:
		word = word + 'a'
	print(word)


t = int(input())
for i in range(t):
	le = int(input())
	l = input().split(' ')
	l1 = []
	s = l[0]

	def split(word):
		return [char for char in word]
	for i in range(1, len(l)):
		a = split(l[i])
		if s[-1] != a[0]:
			s = s + l[i]
		else:
			s = s + a[1]
	if len(s) >= le:
		print(s[0:le])
	else:
		v = le - len(s)
		for i in range(v):
			s = s + 'a'
		print(s)


for _ in range(int(input())):
	n = int(input())
	l = list(map(str, input().split()))
	s = '' + l[0]
	length = 1
	for i in range(1, len(l)):
		if s[length] == l[i][0]:
			s += l[i][1]
			length += 1
		else:
			s += l[i]
			length += 2
	nm = n - len(s)
	if n == 0:
		print(s)
	else:
		print(s + 'a' * nm)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(input().split())
	ans = [arr[0][0], arr[0][1]]
	found = False
	for j in range(1, len(arr)):
		if arr[j][0] == arr[j - 1][1]:
			ans.append(arr[j][1])
		else:
			found = True
			ans.append('' + arr[j][0] + arr[j][1])
	if not found:
		ans.append('a')
	print(''.join(ans))


import sys
from collections import deque
import heapq
import bisect
import copy
MOD = 1000000007
NO = lambda : print('NO')
YES = lambda : print('YES')
_1 = lambda : print(-1)
ari = lambda : [int(_) for _ in input().split()]
cin = lambda : int(input())
cis = lambda : input()
show = lambda x: print(x)
fast = lambda : sys.stdin.readline()
test_case = 1
test_case = int(input())
sys.setrecursionlimit(10 ** 6)

def ans():
	n = cin()
	arr = cis().split()
	cont = ''.join(arr)
	if len(cont) < n:
		print('b' * (n - len(cont)) + cont)
	else:
		need = len(cont) - n
		result = arr[0]
		intial = arr[0]
		for i in range(1, len(arr)):
			val = arr[i]
			if need > 0:
				if intial[-1] == arr[i][0]:
					need -= 1
					val = arr[i][1:]
			result += val
			intial = arr[i]
		print(result)
	return
for _ in range(test_case):
	ans()


import sys
import bisect
import math
from collections import deque
input = lambda : sys.stdin.readline().strip()
mod = 10 ** 9 + 7

def solve():
	n = int(input())
	a = input().split()
	for i in range(1, len(a)):
		if a[i][0] != a[i - 1][-1]:
			return ''.join((a[j][0] for j in range(i))) + a[i - 1][1] + ''.join((a[j][0] for j in range(i, len(a)))) + a[-1][1]
	return ''.join((x[0] for x in a)) + a[-1][1] * 2
t = 1
t = int(input())
for _ in range(t):
	print(solve())


for _ in range(int(input())):
	n = int(input())
	lst = input().split()
	a = [lst[0][0]]
	f = lst[0][0]
	for i in lst:
		if f != i[0]:
			a.append(i)
		else:
			a.append(i[1])
		f = i[1]
	ans = ''.join(a)
	if len(ans) < n:
		print(ans + 'a')
	else:
		print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(str, input().split()))
	z = ''
	z = z + str(a[0])
	m = 0
	if len(a) == 1:
		q = str(a[0])
		z = z + str(q[0])
		print(z)
	else:
		for j in range(len(a) - 1):
			x = str(a[j])
			y = str(a[j + 1])
			p = x[1]
			q = y[0]
			if p == q:
				z = z + str(y[1])
			else:
				z = z + str(a[j + 1])
			if len(z) == n:
				m = 1
				break
		if m == 1:
			print(z)
		else:
			z = z + str(y[1])
			print(z)


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
from collections import OrderedDict
from collections import defaultdict
import bisect
import math
from sys import setrecursionlimit

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def fre_count(mylist):
	return Counter(mylist)

def lcm(a, b):
	return a / gcd(a, b) * b

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		arr = [x for x in input().split()]
		ans = ''
		for i in range(1, len(arr)):
			if arr[i][0] == arr[i - 1][1]:
				arr[i - 1] = arr[i - 1][0]
		ans = ''.join(arr)
		if len(ans) < n:
			ans = 'a' + ans
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


T = int(input())
for _ in range(T):
	n = int(input())
	ans = ''
	flag = 0
	B = list(input().split())
	ans += B[0][0]
	for i in range(n - 3):
		if B[i][1] == B[i + 1][0]:
			ans += B[i][1]
		else:
			ans += B[i][1]
			ans += B[i + 1][0]
			flag = 1
	ans += B[-1][1]
	if flag == 0:
		ans += 'b'
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(str, input().split()))
	s = ''
	for i in range(1, n - 2):
		s += a[i][0] if a[i][0] == a[i - 1][1] else a[i - 1][1] + a[i][0]
	print(a[0][0] + s + a[n - 3][1] if len(s) == n - 2 else a[0][0] + s + a[n - 3][1] + a[n - 3][1])


t = int(input())
ans = []
for i in range(0, t):
	n = int(input())
	l = input()
	d = str(l)
	d = d + ' '
	w = str(d[0])
	z = []
	for j in range(0, int(len(d))):
		if str(d[j]) == ' ':
			continue
		else:
			z.append(str(d[j]))
	for k in range(1, int(len(z)) - 2, 2):
		if str(z[k]) == str(z[k + 1]):
			w = w + str(z[k])
		else:
			w = w + str(z[k]) + str(z[k + 1])
	w = w + str(z[int(len(z) - 1)])
	if n == 3:
		w = 'a' + w
	elif int(len(w)) != n:
		w = w + str(z[int(len(z) - 1)])
	ans.append(w)
for q in range(0, int(len(ans))):
	print(ans[q])


t = int(input())
for _ in range(t):
	n = int(input())
	a = input().split()
	b = [a[0]]
	fl = 0
	for i in range(n - 3):
		if a[i][1] != a[i + 1][0]:
			b.append(a[i][1] + a[i + 1][0])
			fl = 1
		b.append(a[i + 1])
	if not fl:
		b.append(a[n - 3][1] + 'a')
	s = ''
	for i in range(0, n - 1, 2):
		s += b[i]
	if n % 2 == 1:
		s += b[-1][1]
	print(s)


for _ in range(int(input())):
	n = int(input())
	s = input()
	s = s.replace('b b', 'b')
	s = s.replace('a a', 'a')
	s = s.replace(' ', '')
	while len(s) != n:
		s += 'a'
	print(s)


test = int(input())
while test > 0:
	test -= 1
	n = int(input())
	s = ''
	s1 = input().split()
	l = len(s1)
	if l > 1:
		s += s1[0][0]
		for i in range(1, l):
			if s1[i - 1][1] == s1[i][0]:
				s += s1[i][0]
			else:
				s += s1[i - 1][1] + s1[i][0]
		s += s1[l - 1][1]
		if len(s) != n:
			s += 'a'
		print(s)
	else:
		s += s1[0][0] + s1[0][1] + 'b'
		print(s)


def main():
	T = int(input())
	for t in range(T):
		n = int(input())
		w = list(input().strip().split(' '))
		word = w[0]
		for l in w[1:]:
			if l[0] == word[-1]:
				word += l[1]
			else:
				word += l
		if len(word) != n:
			word += 'a'
		print(word)
main()