n=int(eval(input()))

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

ans=""

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

    small=float("inf")

    for j in range(n):

        cnt=0

        for k in range(len(s[j])):

            if s[j][k]==chr(i):

                cnt+=1

        small=min(small,cnt)

    for l in range(small):

        ans+=chr(i)

print(ans)



n=int(eval(input()))

a=[eval(input())for i in range(n)]

ans=""

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

    cnt=float("inf")

    for j in range(n):

        ven=a[j].count(chr(i))

        cnt=min(cnt,ven)

    ans+=chr(i)*cnt

print(ans)

n = int(eval(input()))
s = [eval(input()) for i in range(n)]
ans = ""
for i in range(97, 97 + 26):
    small = float("inf")
    for j in range(n):
        cnt = 0
        for k in range(len(s[j])):
            if s[j][k] == chr(i):
                cnt += 1
        small = min(small, cnt)
    for l in range(small):
        ans += chr(i)
print(ans)

n = int(eval(input()))
a = [eval(input()) for i in range(n)]
ans = ""
for i in range(97, 97 + 26):
    cnt = float("inf")
    for j in range(n):
        ven = a[j].count(chr(i))
        cnt = min(cnt, ven)
    ans += chr(i) * cnt
print(ans)

-s = [eval(input()) for i in range(n)] +a = [eval(input()) for i in range(n)] -    small = float("inf") +    cnt = float("inf") -        cnt = 0 -        for k in range(len(s[j])): -            if s[j][k] == chr(i): -                cnt += 1 -        small = min(small, cnt) -    for l in range(small): -        ans += chr(i) +        ven = a[j].count(chr(i)) +        cnt = min(cnt, ven) +    ans += chr(i) * cnt