N = int(eval(input()))

S = []

for i in range(N):

    S.append(str(eval(input())))

import collections

L = []

for s in S:

    S_dict = collections.Counter(s)

#     print(S_dict.keys())

    for i in list(S_dict.keys()):

        L.append(i)

# print(L)



ans = ""

for i in "abcdefghijklmnopqrstuvwxyz":

    if L.count(i) == N:

        check = 10 ** 18

        for j in S:

            check = min(j.count(i), check)

        ans += i * check

print(ans)
n = int(eval(input()))

L = []

for i in range(n):

    L.append(eval(input()))



ans = ''

for i in 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ':

    tmp = []

    for j in range(n):

        tmp.append(L[j].count(i))

    ans += i * min(tmp)

print(ans)

N = int(eval(input()))
S = []
for i in range(N):
    S.append(str(eval(input())))
import collections

L = []
for s in S:
    S_dict = collections.Counter(s)
    #     print(S_dict.keys())
    for i in list(S_dict.keys()):
        L.append(i)
# print(L)
ans = ""
for i in "abcdefghijklmnopqrstuvwxyz":
    if L.count(i) == N:
        check = 10**18
        for j in S:
            check = min(j.count(i), check)
        ans += i * check
print(ans)

n = int(eval(input()))
L = []
for i in range(n):
    L.append(eval(input()))
ans = ""
for i in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ":
    tmp = []
    for j in range(n):
        tmp.append(L[j].count(i))
    ans += i * min(tmp)
print(ans)

-N = int(eval(input())) -S = [] -for i in range(N): -    S.append(str(eval(input()))) -import collections - +n = int(eval(input())) -for s in S: -    S_dict = collections.Counter(s) -    #     print(S_dict.keys()) -    for i in list(S_dict.keys()): -        L.append(i) -# print(L) +for i in range(n): +    L.append(eval(input())) -for i in "abcdefghijklmnopqrstuvwxyz": -    if L.count(i) == N: -        check = 10**18 -        for j in S: -            check = min(j.count(i), check) -        ans += i * check +for i in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ": +    tmp = [] +    for j in range(n): +        tmp.append(L[j].count(i)) +    ans += i * min(tmp)