N = int(eval(input()))

S = [[] for i in range(N)]

for i in range(N):

	S[i] += list(eval(input()))



res=""

for i in range(97,97+26):

	c = chr(i)

	curr = 50 

	for j in range(N):

		curr = min(curr,S[j].count(c))

	res += c*curr



print(res)
N = int(eval(input()))

S = [eval(input()) for i in range(N)]

MAX_LEN = 50



res = ""

for i in range(ord('a'), ord('a')+26):

	c = chr(i)

	curr = MAX_LEN

	for j in range(N):

		curr = min(curr,S[j].count(c))

	res += c * curr



print(res)
N = int(eval(input()))
S = [[] for i in range(N)]
for i in range(N):
    S[i] += list(eval(input()))
res = ""
for i in range(97, 97 + 26):
    c = chr(i)
    curr = 50
    for j in range(N):
        curr = min(curr, S[j].count(c))
    res += c * curr
print(res)

N = int(eval(input()))
S = [eval(input()) for i in range(N)]
MAX_LEN = 50
res = ""
for i in range(ord("a"), ord("a") + 26):
    c = chr(i)
    curr = MAX_LEN
    for j in range(N):
        curr = min(curr, S[j].count(c))
    res += c * curr
print(res)

-S = [[] for i in range(N)] -for i in range(N): -    S[i] += list(eval(input())) +S = [eval(input()) for i in range(N)] +MAX_LEN = 50 -for i in range(97, 97 + 26): +for i in range(ord("a"), ord("a") + 26): -    curr = 50 +    curr = MAX_LEN