n=int(input())

s=[input() for _ in range(n)]

cnt=[[0]*26 for _ in range(n)]

for i in range(n):

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

        cnt[i][ord(s[i][j])-ord("a")]+=1

ans=""

for j in range(26):

    tmp=10**9

    for i in range(n):

        tmp=min(tmp,cnt[i][j])

    ans+=chr(j+ord("a"))*tmp

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

s = [input() for _ in range(n)]

cnt = [[0] * 26 for _ in range(n)]

for i in range(n):

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

        cnt[i][ord(s[i][j]) - ord("a")] += 1

ans = ""

for j in range(26):

    cntmn = 10**9

    for i in range(n):

        cntmn = min(cntmn, cnt[i][j])

    ans += chr(j + ord("a")) * cntmn

print(ans)
n = int(input())
s = [input() for _ in range(n)]
cnt = [[0] * 26 for _ in range(n)]
for i in range(n):
    for j in range(len(s[i])):
        cnt[i][ord(s[i][j]) - ord("a")] += 1
ans = ""
for j in range(26):
    tmp = 10**9
    for i in range(n):
        tmp = min(tmp, cnt[i][j])
    ans += chr(j + ord("a")) * tmp
print(ans)

n = int(input())
s = [input() for _ in range(n)]
cnt = [[0] * 26 for _ in range(n)]
for i in range(n):
    for j in range(len(s[i])):
        cnt[i][ord(s[i][j]) - ord("a")] += 1
ans = ""
for j in range(26):
    cntmn = 10**9
    for i in range(n):
        cntmn = min(cntmn, cnt[i][j])
    ans += chr(j + ord("a")) * cntmn
print(ans)

-    tmp = 10**9 +    cntmn = 10**9 -        tmp = min(tmp, cnt[i][j]) -    ans += chr(j + ord("a")) * tmp +        cntmn = min(cntmn, cnt[i][j]) +    ans += chr(j + ord("a")) * cntmn