n=int(eval(input()))

s=[[] for i in range(n)]

for i in range(n):

    s[i]=list(eval(input()))

s1=list(set(s[0]))

s1.sort()

#print(s1)



stmin=[50]*len(s1)

for i in range(n):

    st=[0]*len(s1)

    for ii in range(len(s1)):

        for sij in s[i]:

            if s1[ii]==sij :

                st[ii]+=1

        stmin[ii]=min(stmin[ii],st[ii])



t=""

for i in range(len(s1)):

    for ii in range(stmin[i]):        

        t=t+s1[i]

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

s=[""]*n

for i in range(n):

    s[i]=eval(input())

ss=list(set(s[0]))

ss.sort()



stmin=[50]*len(ss)

for si in s:

    for ii in range(len(ss)):

        stmin[ii]=min(stmin[ii],si.count(ss[ii]))



t=""

for i in range(len(ss)):

    t=t+ss[i]*stmin[i]

print(t)

n = int(eval(input()))
s = [[] for i in range(n)]
for i in range(n):
    s[i] = list(eval(input()))
s1 = list(set(s[0]))
s1.sort()
# print(s1)
stmin = [50] * len(s1)
for i in range(n):
    st = [0] * len(s1)
    for ii in range(len(s1)):
        for sij in s[i]:
            if s1[ii] == sij:
                st[ii] += 1
        stmin[ii] = min(stmin[ii], st[ii])
t = ""
for i in range(len(s1)):
    for ii in range(stmin[i]):
        t = t + s1[i]
print(t)

n = int(eval(input()))
s = [""] * n
for i in range(n):
    s[i] = eval(input())
ss = list(set(s[0]))
ss.sort()
stmin = [50] * len(ss)
for si in s:
    for ii in range(len(ss)):
        stmin[ii] = min(stmin[ii], si.count(ss[ii]))
t = ""
for i in range(len(ss)):
    t = t + ss[i] * stmin[i]
print(t)

-s = [[] for i in range(n)] +s = [""] * n -    s[i] = list(eval(input())) -s1 = list(set(s[0])) -s1.sort() -# print(s1) -stmin = [50] * len(s1) -for i in range(n): -    st = [0] * len(s1) -    for ii in range(len(s1)): -        for sij in s[i]: -            if s1[ii] == sij: -                st[ii] += 1 -        stmin[ii] = min(stmin[ii], st[ii]) +    s[i] = eval(input()) +ss = list(set(s[0])) +ss.sort() +stmin = [50] * len(ss) +for si in s: +    for ii in range(len(ss)): +        stmin[ii] = min(stmin[ii], si.count(ss[ii])) -for i in range(len(s1)): -    for ii in range(stmin[i]): -        t = t + s1[i] +for i in range(len(ss)): +    t = t + ss[i] * stmin[i]