N = int(eval(input()))

al=[chr(ord('a') + i) for i in range(26)]

out = [1000]*26

for i in range(N):

    S = list(eval(input()))

    LS = len(S)

    tmp = [0]*26

    for j in range(LS):

        tmp[ord(S[j])-ord("a")]+=1

    for j in range(26):

        out[j]=min(out[j],tmp[j])

S = ""

for i in range(26):

    S += out[i]*chr(ord("a")+i)

print(S)

N = int(eval(input()))

al = [chr(ord('a') + i) for i in range(26)]

out = dict(list(zip(al,[100]*26)))

for i in range(N):

    S = list(eval(input()))

    tmp = dict(list(zip(al,[0]*26)))

    for T in S:

        tmp[T] += 1

    for key in list(out.keys()):

        out[key]=min(out[key],tmp[key])

outS = ""

for key in list(out.keys()):

    outS += key*out[key]

print(outS)

N = int(eval(input()))
al = [chr(ord("a") + i) for i in range(26)]
out = [1000] * 26
for i in range(N):
    S = list(eval(input()))
    LS = len(S)
    tmp = [0] * 26
    for j in range(LS):
        tmp[ord(S[j]) - ord("a")] += 1
    for j in range(26):
        out[j] = min(out[j], tmp[j])
S = ""
for i in range(26):
    S += out[i] * chr(ord("a") + i)
print(S)

N = int(eval(input()))
al = [chr(ord("a") + i) for i in range(26)]
out = dict(list(zip(al, [100] * 26)))
for i in range(N):
    S = list(eval(input()))
    tmp = dict(list(zip(al, [0] * 26)))
    for T in S:
        tmp[T] += 1
    for key in list(out.keys()):
        out[key] = min(out[key], tmp[key])
outS = ""
for key in list(out.keys()):
    outS += key * out[key]
print(outS)

-out = [1000] * 26 +out = dict(list(zip(al, [100] * 26))) -    LS = len(S) -    tmp = [0] * 26 -    for j in range(LS): -        tmp[ord(S[j]) - ord("a")] += 1 -    for j in range(26): -        out[j] = min(out[j], tmp[j]) -S = "" -for i in range(26): -    S += out[i] * chr(ord("a") + i) -print(S) +    tmp = dict(list(zip(al, [0] * 26))) +    for T in S: +        tmp[T] += 1 +    for key in list(out.keys()): +        out[key] = min(out[key], tmp[key]) +outS = "" +for key in list(out.keys()): +    outS += key * out[key] +print(outS)